ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilFileObjectRBACDatabaseSteps Class Reference
+ Inheritance diagram for ilFileObjectRBACDatabaseSteps:
+ Collaboration diagram for ilFileObjectRBACDatabaseSteps:

Public Member Functions

 prepare (ilDBInterface $db)
 
 step_1 ()
 assign to all roles which already have the "edit" operation assigned fo files More...
 
 step_2 ()
 add to all templates which already have the "edit" operation assigned fo files More...
 
 step_3 ()
 
- Public Member Functions inherited from ilDatabaseUpdateSteps
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Data Fields

const EDIT_FILE = "edit_file"
 

Protected Member Functions

 getOpsID (ilDBInterface $db, string $operation)
 

Private Attributes

ilDBInterface $database = null
 

Detailed Description

Member Function Documentation

◆ getOpsID()

ilFileObjectRBACDatabaseSteps::getOpsID ( ilDBInterface  $db,
string  $operation 
)
protected

Definition at line 36 of file class.ilFileObjectRBACDatabaseSteps.php.

References $res, ilDBInterface\fetchAssoc(), null, and ilDBInterface\queryF().

Referenced by step_1(), and step_2().

36  : ?int
37  {
38  $res = $db->queryF(
39  "SELECT ops_id FROM rbac_operations WHERE operation = %s",
40  ["text"],
41  [self::EDIT_FILE]
42  );
43 
44  return $db->fetchAssoc($res)['ops_id'] ?? null;
45  }
$res
Definition: ltiservices.php:66
fetchAssoc(ilDBStatement $statement)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepare()

ilFileObjectRBACDatabaseSteps::prepare ( ilDBInterface  $db)

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

31  : void
32  {
33  $this->database = $db;
34  }

◆ step_1()

ilFileObjectRBACDatabaseSteps::step_1 ( )

assign to all roles which already have the "edit" operation assigned fo files

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

References $q, $res, and getOpsID().

50  : void
51  {
52  $edit_file_ops_id = $this->getOpsID($this->database, self::EDIT_FILE);
53 
54  $q = "SELECT
55  rbac_pa.rol_id,
56  rbac_pa.ops_id,
57  rbac_pa.ref_id
58  FROM rbac_pa
59  JOIN object_reference ON rbac_pa.ref_id = object_reference.ref_id
60  JOIN object_data ON object_reference.obj_id = object_data.obj_id
61  WHERE object_data.type = 'file';
62  ";
63 
64  $res = $this->database->query($q);
65  while ($row = $this->database->fetchAssoc($res)) {
66  $ops_ids = unserialize($row['ops_id'], ['allowed_classes' => false]);
67  if (in_array(4, $ops_ids, false) && !in_array($edit_file_ops_id, $ops_ids, false)) {
68  $ops_ids[] = $edit_file_ops_id;
69  $ops_ids = array_unique($ops_ids);
70  $new_ops_ids = serialize($ops_ids);
71  $this->database->update(
72  "rbac_pa",
73  [
74  'ops_id' => ['text', $new_ops_ids]
75  ],
76  [
77  'rol_id' => ['integer', $row['rol_id']],
78  'ref_id' => ['integer', $row['ref_id']]
79  ]
80  );
81  }
82  }
83  }
getOpsID(ilDBInterface $db, string $operation)
$res
Definition: ltiservices.php:66
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ step_2()

ilFileObjectRBACDatabaseSteps::step_2 ( )

add to all templates which already have the "edit" operation assigned fo files

Definition at line 88 of file class.ilFileObjectRBACDatabaseSteps.php.

References $q, $res, and getOpsID().

88  : void
89  {
90  $edit_file_ops_id = $this->getOpsID($this->database, self::EDIT_FILE);
91 
92  $q = "SELECT * from rbac_templates WHERE type = %s AND ops_id = %s";
93  $res = $this->database->queryF(
94  $q,
95  ['text', 'integer'],
96  ['file', 4]
97  );
98  while ($row = $this->database->fetchAssoc($res)) {
99  try {
100  $this->database->insert(
101  "rbac_templates",
102  [
103  'type' => ['text', 'file'],
104  'ops_id' => ['integer', $edit_file_ops_id],
105  'rol_id' => ['integer', $row['rol_id']],
106  'parent' => ['integer', $row['parent']]
107  ]
108  );
109  } catch (Throwable) {
110  };
111  }
112  }
getOpsID(ilDBInterface $db, string $operation)
$res
Definition: ltiservices.php:66
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ step_3()

ilFileObjectRBACDatabaseSteps::step_3 ( )

Definition at line 114 of file class.ilFileObjectRBACDatabaseSteps.php.

114  : void
115  {
116  $read_position = $this->database->fetchAssoc(
117  $this->database->queryF(
118  "SELECT op_order FROM rbac_operations WHERE operation = %s",
119  ['text'],
120  [Permissions::READ->value]
121  )
122  )['op_order'] ?? 2000;
123 
124  // update position of view_content operation
125  $this->database->update(
126  "rbac_operations",
127  [
128  'op_order' => ['integer', $read_position + 1]
129  ],
130  [
131  'operation' => ['text', Permissions::VIEW_CONTENT->value]
132  ]
133  );
134  }

Field Documentation

◆ $database

ilDBInterface ilFileObjectRBACDatabaseSteps::$database = null
private

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

◆ EDIT_FILE

const ilFileObjectRBACDatabaseSteps::EDIT_FILE = "edit_file"

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


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