ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 $settings_factory = $environment->getResource(Environment::RESOURCE_SETTINGS_FACTORY);
77
78 if (!defined("ROOT_FOLDER_ID")) {
79 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
80 }
81 if (!defined("SYSTEM_FOLDER_ID")) {
82 define("SYSTEM_FOLDER_ID", $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
83 }
84 if (!defined("ILIAS_LOG_ENABLED")) {
85 define("ILIAS_LOG_ENABLED", false);
86 }
87
88 $obj_type_id = $db->nextId("object_data");
89 $values = [
90 'obj_id' => ['integer', $obj_type_id],
91 'type' => ['text', 'typ'],
92 'title' => ['text', $this->type],
93 'description' => ['text', $this->title],
94 'owner' => ['integer', -1],
95 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
96 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
97 ];
98 $db->insert("object_data", $values);
99
100 $obj_id = $db->nextId("object_data");
101 $values = [
102 'obj_id' => ['integer', $obj_id],
103 'type' => ['text', $this->type],
104 'title' => ['text', $this->title],
105 'description' => ['text', $this->title],
106 'owner' => ['integer', -1],
107 'create_date' => ['timestamp', date("Y-m-d H:i:s")],
108 'last_update' => ['timestamp', date("Y-m-d H:i:s")]
109 ];
110 $db->insert("object_data", $values);
111
112 $ref_id = $db->nextId("object_reference");
113 $values = [
114 "obj_id" => ["integer", $obj_id],
115 "ref_id" => ["integer", $ref_id]
116 ];
117 $db->insert("object_reference", $values);
118
119 $tree = (new TreeBuilder(ROOT_FOLDER_ID))
120 ->forSetupEnvironment($db, $settings_factory->settingsFor("common"))
121 ->build();
122
123 if ($this->parent_type) {
124 $set = $db->queryF(
125 "SELECT * FROM object_data " .
126 " WHERE type = %s ",
127 ["text"],
128 [$this->parent_type]
129 );
130 $rec = $db->fetchAssoc($set);
131
132 $set = $db->queryF(
133 "SELECT * FROM object_reference " .
134 " WHERE obj_id = %s ",
135 ["integer"],
136 [$rec["obj_id"]]
137 );
138 $rec = $db->fetchAssoc($set);
139 $parent_type_ref_id = $rec["ref_id"];
140
141 $tree->insertNode((int) $ref_id, (int) $parent_type_ref_id);
142 } else {
143 $tree->insertNode((int) $ref_id, (int) SYSTEM_FOLDER_ID);
144 }
145
146 foreach ($this->rbac_ops as $ops_id) {
147 if (ilRbacReview::_isRBACOperation($obj_type_id, $ops_id, $db)) {
148 continue;
149 }
150 $values = [
151 "typ_id" => ["integer", $obj_type_id],
152 "ops_id" => ["integer", $ops_id]
153 ];
154 $db->insert("rbac_ta", $values);
155 }
156
157 return $environment;
158 }
@template-extends \ilTree
Definition: TreeBuilder.php:40
static _isRBACOperation(int $type_id, int $ops_id, ?\ilDBInterface $ilDB=null)
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.

References $title, $type, ilRbacReview\_isRBACOperation(), ILIAS\UI\examples\Symbol\Glyph\Date\date(), ILIAS\Setup\Environment\getResource(), ILIAS\Repository\int(), 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 160 of file class.ilTreeAdminNodeAddedObjective.php.

160 : bool
161 {
162 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
163 return !((bool) ilObject::_getObjectTypeIdByTitle($this->type, $db));
164 }
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: