ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTreeAdminNodeAddedObjective Class Reference
+ Inheritance diagram for ilTreeAdminNodeAddedObjective:
+ Collaboration diagram for ilTreeAdminNodeAddedObjective:

Public Member Functions

 __construct (string $type, string $title, string $parent_type="")
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 
 isApplicable (Environment $environment)
 

Protected Attributes

const RBAC_OP_EDIT_PERMISSIONS = 1
 
const RBAC_OP_VISIBLE = 2
 
const RBAC_OP_READ = 3
 
const RBAC_OP_WRITE = 4
 
array $rbac_ops
 
string $type
 
string $title
 
string $parent_type
 

Detailed Description

Definition at line 25 of file class.ilTreeAdminNodeAddedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilTreeAdminNodeAddedObjective::__construct ( string  $type,
string  $title,
string  $parent_type = "" 
)

Member Function Documentation

◆ achieve()

ilTreeAdminNodeAddedObjective::achieve ( Environment  $environment)

Definition at line 73 of file class.ilTreeAdminNodeAddedObjective.php.

74 {
75 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
76 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
77
78 // ATTENTION: This is a total abomination. It only exists to allow various
79 // sub components of the various readers to run. This is a memento to the
80 // fact, that dependency injection is something we want. Currently, every
81 // component could just service locate the whole world via the global $DIC.
82 $PREVIOUS_DIC = $GLOBALS["DIC"] ?? null;
83 $GLOBALS["DIC"] = new Container();
84 $GLOBALS["DIC"]["ilDB"] = $db;
85
86 try {
87 if (!defined("ROOT_FOLDER_ID")) {
88 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
89 }
90 if (!defined("SYSTEM_FOLDER_ID")) {
91 define("SYSTEM_FOLDER_ID", $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
92 }
93 if (!defined("ILIAS_LOG_ENABLED")) {
94 define("ILIAS_LOG_ENABLED", false);
95 }
96
97 $obj_type_id = $db->nextId("object_data");
98 $values = [
99 'obj_id' => ['integer', $obj_type_id],
100 'type' => ['text', 'typ'],
101 'title' => ['text', $this->type],
102 'description' => ['text', $this->title],
103 'owner' => ['integer', -1],
104 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
105 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
106 ];
107 $db->insert("object_data", $values);
108
109 $obj_id = $db->nextId("object_data");
110 $values = [
111 'obj_id' => ['integer', $obj_id],
112 'type' => ['text', $this->type],
113 'title' => ['text', $this->title],
114 'description' => ['text', $this->title],
115 'owner' => ['integer', -1],
116 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
117 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
118 ];
119 $db->insert("object_data", $values);
120
121 $ref_id = $db->nextId("object_reference");
122 $values = [
123 "obj_id" => ["integer", $obj_id],
124 "ref_id" => ["integer", $ref_id]
125 ];
126 $db->insert("object_reference", $values);
127
128 $tree = new ilTree(
130 0,
131 $db
132 );
133 if ($this->parent_type) {
134 $set = $db->queryF(
135 "SELECT * FROM object_data " .
136 " WHERE type = %s ",
137 ["text"],
138 [$this->parent_type]
139 );
140 $rec = $db->fetchAssoc($set);
141
142 $set = $db->queryF(
143 "SELECT * FROM object_reference " .
144 " WHERE obj_id = %s ",
145 ["integer"],
146 [$rec["obj_id"]]
147 );
148 $rec = $db->fetchAssoc($set);
149 $parent_type_ref_id = $rec["ref_id"];
150
151 $tree->insertNode((int) $ref_id, (int) $parent_type_ref_id);
152 } else {
153 $tree->insertNode((int) $ref_id, (int) SYSTEM_FOLDER_ID);
154 }
155
156 foreach ($this->rbac_ops as $ops_id) {
157 if (ilRbacReview::_isRBACOperation($obj_type_id, $ops_id, $db)) {
158 continue;
159 }
160 $values = [
161 "typ_id" => ["integer", $obj_type_id],
162 "ops_id" => ["integer", $ops_id]
163 ];
164 $db->insert("rbac_ta", $values);
165 }
166 } finally {
167 // reset the abomination again so we don't make objectives flaky.
168 $GLOBALS["DIC"] = $PREVIOUS_DIC;
169 }
170
171 return $environment;
172 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
static _isRBACOperation(int $type_id, int $ops_id, ?\ilDBInterface $ilDB=null)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$ref_id
Definition: ltiauth.php:66
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS, $ref_id, $title, $type, ilRbacReview\_isRBACOperation(), ILIAS\Setup\Environment\getResource(), ROOT_FOLDER_ID, and SYSTEM_FOLDER_ID.

+ Here is the call graph for this function:

◆ getHash()

ilTreeAdminNodeAddedObjective::getHash ( )

Definition at line 50 of file class.ilTreeAdminNodeAddedObjective.php.

50 : string
51 {
52 return hash("sha256", self::class . "::" . $this->type);
53 }

◆ getLabel()

ilTreeAdminNodeAddedObjective::getLabel ( )

Definition at line 55 of file class.ilTreeAdminNodeAddedObjective.php.

55 : string
56 {
57 return "Add new admin node to tree (type=$this->type;title=$this->title)";
58 }

◆ getPreconditions()

ilTreeAdminNodeAddedObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilTreeAdminNodeAddedObjective::isApplicable ( Environment  $environment)

Definition at line 174 of file class.ilTreeAdminNodeAddedObjective.php.

174 : bool
175 {
176 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
177 return !((bool) ilObject::_getObjectTypeIdByTitle($this->type, $db));
178 }
static _getObjectTypeIdByTitle(string $type, ?\ilDBInterface $ilDB=null)

References ilObject\_getObjectTypeIdByTitle(), and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ isNotable()

ilTreeAdminNodeAddedObjective::isNotable ( )

Definition at line 60 of file class.ilTreeAdminNodeAddedObjective.php.

60 : bool
61 {
62 return true;
63 }

Field Documentation

◆ $parent_type

string ilTreeAdminNodeAddedObjective::$parent_type
protected

Definition at line 41 of file class.ilTreeAdminNodeAddedObjective.php.

Referenced by __construct().

◆ $rbac_ops

◆ $title

string ilTreeAdminNodeAddedObjective::$title
protected

Definition at line 40 of file class.ilTreeAdminNodeAddedObjective.php.

Referenced by __construct(), and achieve().

◆ $type

string ilTreeAdminNodeAddedObjective::$type
protected

Definition at line 39 of file class.ilTreeAdminNodeAddedObjective.php.

Referenced by __construct(), and achieve().

◆ RBAC_OP_EDIT_PERMISSIONS

const ilTreeAdminNodeAddedObjective::RBAC_OP_EDIT_PERMISSIONS = 1
protected

Definition at line 27 of file class.ilTreeAdminNodeAddedObjective.php.

◆ RBAC_OP_READ

const ilTreeAdminNodeAddedObjective::RBAC_OP_READ = 3
protected

Definition at line 29 of file class.ilTreeAdminNodeAddedObjective.php.

◆ RBAC_OP_VISIBLE

const ilTreeAdminNodeAddedObjective::RBAC_OP_VISIBLE = 2
protected

Definition at line 28 of file class.ilTreeAdminNodeAddedObjective.php.

◆ RBAC_OP_WRITE

const ilTreeAdminNodeAddedObjective::RBAC_OP_WRITE = 4
protected

Definition at line 30 of file class.ilTreeAdminNodeAddedObjective.php.


The documentation for this class was generated from the following file: