ILIAS  release_8 Revision v8.24
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 24 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 global $DIC;
75 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
76 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
77 $DIC['ilDB'] = $DIC['ilDB'] ?? $db;
78
79 if (!defined("ROOT_FOLDER_ID")) {
80 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
81 }
82 if (!defined("SYSTEM_FOLDER_ID")) {
83 define("SYSTEM_FOLDER_ID", $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
84 }
85 if (!defined("ILIAS_LOG_ENABLED")) {
86 define("ILIAS_LOG_ENABLED", false);
87 }
88
89 $obj_type_id = $db->nextId("object_data");
90 $values = [
91 'obj_id' => ['integer', $obj_type_id],
92 'type' => ['text', 'typ'],
93 'title' => ['text', $this->type],
94 'description' => ['text', $this->title],
95 'owner' => ['integer', -1],
96 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
97 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
98 ];
99 $db->insert("object_data", $values);
100
101 $obj_id = $db->nextId("object_data");
102 $values = [
103 'obj_id' => ['integer', $obj_id],
104 'type' => ['text', $this->type],
105 'title' => ['text', $this->title],
106 'description' => ['text', $this->title],
107 'owner' => ['integer', -1],
108 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
109 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
110 ];
111 $db->insert("object_data", $values);
112
113 $ref_id = $db->nextId("object_reference");
114 $values = [
115 "obj_id" => ["integer", $obj_id],
116 "ref_id" => ["integer", $ref_id]
117 ];
118 $db->insert("object_reference", $values);
119
120 $tree = new ilTree(
122 0,
123 $db
124 );
125 if ($this->parent_type) {
126 $set = $db->queryF(
127 "SELECT * FROM object_data " .
128 " WHERE type = %s ",
129 ["text"],
130 [$this->parent_type]
131 );
132 $rec = $db->fetchAssoc($set);
133
134 $set = $db->queryF(
135 "SELECT * FROM object_reference " .
136 " WHERE obj_id = %s ",
137 ["integer"],
138 [$rec["obj_id"]]
139 );
140 $rec = $db->fetchAssoc($set);
141 $parent_type_ref_id = $rec["ref_id"];
142
143 $tree->insertNode((int) $ref_id, (int) $parent_type_ref_id);
144 } else {
145 $tree->insertNode((int) $ref_id, (int) SYSTEM_FOLDER_ID);
146 }
147
148 foreach ($this->rbac_ops as $ops_id) {
149 if (ilRbacReview::_isRBACOperation($obj_type_id, $ops_id, $db)) {
150 continue;
151 }
152 $values = [
153 "typ_id" => ["integer", $obj_type_id],
154 "ops_id" => ["integer", $ops_id]
155 ];
156 $db->insert("rbac_ta", $values);
157 }
158 return $environment;
159 }
static _isRBACOperation(int $type_id, int $ops_id, \ilDBInterface $ilDB=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
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:67

References $DIC, $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 161 of file class.ilTreeAdminNodeAddedObjective.php.

161 : bool
162 {
163 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
164 return !((bool) ilObject::_getObjectTypeIdByTitle($this->type, $db));
165 }
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 26 of file class.ilTreeAdminNodeAddedObjective.php.

◆ RBAC_OP_READ

const ilTreeAdminNodeAddedObjective::RBAC_OP_READ = 3
protected

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

◆ RBAC_OP_VISIBLE

const ilTreeAdminNodeAddedObjective::RBAC_OP_VISIBLE = 2
protected

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

◆ RBAC_OP_WRITE

const ilTreeAdminNodeAddedObjective::RBAC_OP_WRITE = 4
protected

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


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