ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 72 of file class.ilTreeAdminNodeAddedObjective.php.

73 {
74 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
75 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
76
77 // ATTENTION: This is a total abomination. It only exists to allow various
78 // sub components of the various readers to run. This is a memento to the
79 // fact, that dependency injection is something we want. Currently, every
80 // component could just service locate the whole world via the global $DIC.
81 $PREVIOUS_DIC = $GLOBALS["DIC"] ?? null;
82 $GLOBALS["DIC"] = new Container();
83 $GLOBALS["DIC"]["ilDB"] = $db;
84
85 try {
86 if (!defined("ROOT_FOLDER_ID")) {
87 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
88 }
89 if (!defined("SYSTEM_FOLDER_ID")) {
90 define("SYSTEM_FOLDER_ID", $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
91 }
92 if (!defined("ILIAS_LOG_ENABLED")) {
93 define("ILIAS_LOG_ENABLED", false);
94 }
95
96 $obj_type_id = $db->nextId("object_data");
97 $values = [
98 'obj_id' => ['integer', $obj_type_id],
99 'type' => ['text', 'typ'],
100 'title' => ['text', $this->type],
101 'description' => ['text', $this->title],
102 'owner' => ['integer', -1],
103 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
104 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
105 ];
106 $db->insert("object_data", $values);
107
108 $obj_id = $db->nextId("object_data");
109 $values = [
110 'obj_id' => ['integer', $obj_id],
111 'type' => ['text', $this->type],
112 'title' => ['text', $this->title],
113 'description' => ['text', $this->title],
114 'owner' => ['integer', -1],
115 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
116 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
117 ];
118 $db->insert("object_data", $values);
119
120 $ref_id = $db->nextId("object_reference");
121 $values = [
122 "obj_id" => ["integer", $obj_id],
123 "ref_id" => ["integer", $ref_id]
124 ];
125 $db->insert("object_reference", $values);
126
127 $tree = new ilTree(
129 0,
130 $db
131 );
132 if ($this->parent_type) {
133 $set = $db->queryF(
134 "SELECT * FROM object_data " .
135 " WHERE type = %s ",
136 ["text"],
137 [$this->parent_type]
138 );
139 $rec = $db->fetchAssoc($set);
140
141 $set = $db->queryF(
142 "SELECT * FROM object_reference " .
143 " WHERE obj_id = %s ",
144 ["integer"],
145 [$rec["obj_id"]]
146 );
147 $rec = $db->fetchAssoc($set);
148 $parent_type_ref_id = $rec["ref_id"];
149
150 $tree->insertNode((int) $ref_id, (int) $parent_type_ref_id);
151 } else {
152 $tree->insertNode((int) $ref_id, (int) SYSTEM_FOLDER_ID);
153 }
154
155 foreach ($this->rbac_ops as $ops_id) {
156 if (ilRbacReview::_isRBACOperation($obj_type_id, $ops_id, $db)) {
157 continue;
158 }
159 $values = [
160 "typ_id" => ["integer", $obj_type_id],
161 "ops_id" => ["integer", $ops_id]
162 ];
163 $db->insert("rbac_ta", $values);
164 }
165 } finally {
166 // reset the abomination again so we don't make objectives flaky.
167 $GLOBALS["DIC"] = $PREVIOUS_DIC;
168 }
169
170 return $environment;
171 }
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 49 of file class.ilTreeAdminNodeAddedObjective.php.

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

◆ getLabel()

ilTreeAdminNodeAddedObjective::getLabel ( )

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

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

◆ getPreconditions()

ilTreeAdminNodeAddedObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilTreeAdminNodeAddedObjective::isApplicable ( Environment  $environment)

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

173 : bool
174 {
175 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
176 return !((bool) ilObject::_getObjectTypeIdByTitle($this->type, $db));
177 }
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 59 of file class.ilTreeAdminNodeAddedObjective.php.

59 : bool
60 {
61 return true;
62 }

Field Documentation

◆ $parent_type

string ilTreeAdminNodeAddedObjective::$parent_type
protected

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

Referenced by __construct().

◆ $rbac_ops

◆ $title

string ilTreeAdminNodeAddedObjective::$title
protected

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

Referenced by __construct(), and achieve().

◆ $type

string ilTreeAdminNodeAddedObjective::$type
protected

Definition at line 38 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: