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

Public Member Functions

 __construct (string $type, int $src_id, int $dest_id)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 
 isApplicable (Environment $environment)
 

Protected Attributes

string $type
 
int $src_id
 
int $dest_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccessRBACOperationClonedObjective::__construct ( string  $type,
int  $src_id,
int  $dest_id 
)

Member Function Documentation

◆ achieve()

ilAccessRBACOperationClonedObjective::achieve ( Environment  $environment)

Reimplemented in ILIAS\BookingManager\Setup\AccessRBACOperationClonedObjective, and ILIAS\Wiki\Setup\AccessRBACOperationClonedObjective.

Definition at line 62 of file class.ilAccessRBACOperationClonedObjective.php.

63 {
64 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
65
66 $sql =
67 "SELECT rpa.rol_id, rpa.ops_id, rpa.ref_id" . PHP_EOL
68 . "FROM rbac_pa rpa" . PHP_EOL
69 . "JOIN object_reference ref ON (ref.ref_id = rpa.ref_id)" . PHP_EOL
70 . "JOIN object_data od ON (od.obj_id = ref.obj_id AND od.type = " . $db->quote($this->type, "text") . ")" . PHP_EOL
71 . "WHERE (" . $db->like("ops_id", "text", "%i:" . $this->src_id . "%") . PHP_EOL
72 . "OR " . $db->like("ops_id", "text", "%:\"" . $this->src_id . "\";%") . ")" . PHP_EOL
73 ;
74
75 $result = $db->query($sql);
76
77 while ($row = $db->fetchAssoc($result)) {
78 $ops = unserialize($row["ops_id"]);
79 // the query above could match by array KEY, we need extra checks
80 if (in_array($this->src_id, $ops) && !in_array($this->dest_id, $ops)) {
81 $ops[] = $this->dest_id;
82
83 $sql =
84 "UPDATE rbac_pa" . PHP_EOL
85 . "SET ops_id = " . $db->quote(serialize($ops), "text") . PHP_EOL
86 . "WHERE rol_id = " . $db->quote($row["rol_id"], "integer") . PHP_EOL
87 . "AND ref_id = " . $db->quote($row["ref_id"], "integer") . PHP_EOL
88 ;
89
90 $db->manipulate($sql);
91 }
92 }
93
94 // rbac_templates
95 $tmp = [];
96 $sql =
97 "SELECT rol_id, parent, ops_id" . PHP_EOL
98 . "FROM rbac_templates" . PHP_EOL
99 . "WHERE type = " . $db->quote($this->type, "text") . PHP_EOL
100 . "AND (ops_id = " . $db->quote($this->src_id, "integer") . PHP_EOL
101 . "OR ops_id = " . $db->quote($this->dest_id, "integer") . ")" . PHP_EOL
102 ;
103
104 $result = $db->query($sql);
105
106 while ($row = $db->fetchAssoc($result)) {
107 $tmp[$row["rol_id"]][$row["parent"]][] = $row["ops_id"];
108 }
109
110 foreach ($tmp as $role_id => $parents) {
111 foreach ($parents as $parent_id => $ops_ids) {
112 // only if the target op is missing
113 if (sizeof($ops_ids) < 2 && in_array($this->src_id, $ops_ids)) {
114 $values = [
115 "rol_id" => ["integer", $role_id],
116 "type" => ["text", $this->type],
117 "ops_id" => ["integer", $this->dest_id],
118 "parent" => ["integer", $parent_id]
119 ];
120
121 $db->insert("rbac_templates", $values);
122 }
123 }
124 }
125
126 return $environment;
127 }
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 $dest_id, $type, and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ getHash()

ilAccessRBACOperationClonedObjective::getHash ( )

Reimplemented in ILIAS\BookingManager\Setup\AccessRBACOperationClonedObjective.

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

40 : string
41 {
42 return hash("sha256", self::class);
43 }

◆ getLabel()

ilAccessRBACOperationClonedObjective::getLabel ( )

Reimplemented in ILIAS\BookingManager\Setup\AccessRBACOperationClonedObjective, and ILIAS\Wiki\Setup\AccessRBACOperationClonedObjective.

Definition at line 45 of file class.ilAccessRBACOperationClonedObjective.php.

45 : string
46 {
47 return "Clone rbac operation from $this->src_id to $this->dest_id";
48 }

◆ getPreconditions()

ilAccessRBACOperationClonedObjective::getPreconditions ( Environment  $environment)

◆ isApplicable()

ilAccessRBACOperationClonedObjective::isApplicable ( Environment  $environment)

◆ isNotable()

ilAccessRBACOperationClonedObjective::isNotable ( )

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

50 : bool
51 {
52 return true;
53 }

Field Documentation

◆ $dest_id

int ilAccessRBACOperationClonedObjective::$dest_id
protected

Definition at line 31 of file class.ilAccessRBACOperationClonedObjective.php.

Referenced by __construct(), and achieve().

◆ $src_id

int ilAccessRBACOperationClonedObjective::$src_id
protected

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

Referenced by __construct().

◆ $type


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