ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 
- 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 34 of file class.ilFileObjectRBACDatabaseSteps.php.

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

Referenced by step_1(), and step_2().

34  : ?int
35  {
36  $res = $db->queryF(
37  "SELECT ops_id FROM rbac_operations WHERE operation = %s",
38  ["text"],
39  [self::EDIT_FILE]
40  );
41 
42  return $db->fetchAssoc($res)['ops_id'] ?? null;
43  }
$res
Definition: ltiservices.php:69
fetchAssoc(ilDBStatement $statement)
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 29 of file class.ilFileObjectRBACDatabaseSteps.php.

29  : void
30  {
31  $this->database = $db;
32  }

◆ step_1()

ilFileObjectRBACDatabaseSteps::step_1 ( )

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

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

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

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

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

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

Field Documentation

◆ $database

ilDBInterface ilFileObjectRBACDatabaseSteps::$database = null
private

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

◆ EDIT_FILE

const ilFileObjectRBACDatabaseSteps::EDIT_FILE = "edit_file"

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