ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilDclTableHelper Class Reference
+ Collaboration diagram for ilDclTableHelper:

Public Member Functions

 __construct (int $obj_id, int $ref_id, ilRbacReview $rbac_review, ilObjUser $user, ilDBInterface $database)
 ilDclTableHelper constructor. More...
 
 getRoleTitlesWithoutReadRightOnAnyStandardView ()
 

Protected Member Functions

 getRolesIdsWithReadAccessOnDataCollection ()
 
 getStandardViewsByVisibleTables (array $visible_tables_for_data_collection)
 
 getAllVisibleTablesForDataColleciton ()
 
 hasUserReadAccessOnAnyVisibleTableView ()
 
 in_array_r (string $needle, array $haystack, bool $strict=false)
 

Protected Attributes

int $obj_id = 0
 
int $ref_id = 0
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilDBInterface $database
 

Detailed Description

Definition at line 21 of file class.ilDclTableHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilDclTableHelper::__construct ( int  $obj_id,
int  $ref_id,
ilRbacReview  $rbac_review,
ilObjUser  $user,
ilDBInterface  $database 
)

ilDclTableHelper constructor.

Definition at line 32 of file class.ilDclTableHelper.php.

References $database, $obj_id, $rbac_review, $ref_id, $user, and ILIAS\Repository\user().

38  {
39  $this->obj_id = $obj_id;
40  $this->ref_id = $ref_id;
41  $this->rbac_review = $rbac_review;
42  $this->user = $user;
43  $this->database = $database;
44  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getAllVisibleTablesForDataColleciton()

ilDclTableHelper::getAllVisibleTablesForDataColleciton ( )
protected

Definition at line 117 of file class.ilDclTableHelper.php.

References $res.

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView(), and hasUserReadAccessOnAnyVisibleTableView().

117  : array
118  {
119  $visible_tables_for_data_collection = [];
120  $res = $this->database->queryF(
121  "SELECT * FROM il_dcl_table WHERE obj_id = %s AND is_visible = 1",
122  ['integer'],
123  [$this->obj_id]
124  );
125  while ($rec = $this->database->fetchAssoc($res)) {
126  $visible_tables_for_data_collection[] = $rec;
127  }
128 
129  return $visible_tables_for_data_collection;
130  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getRolesIdsWithReadAccessOnDataCollection()

ilDclTableHelper::getRolesIdsWithReadAccessOnDataCollection ( )
protected

Definition at line 69 of file class.ilDclTableHelper.php.

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView().

69  : array
70  {
71  $rbac_roles = $this->rbac_review->getParentRoleIds($this->ref_id);
72  $roles_with_read_acces_ids = [];
73  //get all roles with read access on data collection
74  foreach ($rbac_roles as $role) {
75  $operations = $this->rbac_review->getActiveOperationsOfRole($this->ref_id, $role['rol_id']);
76  //3 corresponds to the read rbac right
77  if (!empty($operations) && in_array(3, $operations)) {
78  $roles_with_read_acces_ids[] = $role['rol_id'];
79  }
80  }
81 
82  return $roles_with_read_acces_ids;
83  }
+ Here is the caller graph for this function:

◆ getRoleTitlesWithoutReadRightOnAnyStandardView()

ilDclTableHelper::getRoleTitlesWithoutReadRightOnAnyStandardView ( )

Definition at line 46 of file class.ilDclTableHelper.php.

References getAllVisibleTablesForDataColleciton(), getRolesIdsWithReadAccessOnDataCollection(), and getStandardViewsByVisibleTables().

Referenced by ilDclTableListGUI\executeCommand().

46  : array
47  {
48  $visible_tables_for_data_collection = $this->getAllVisibleTablesForDataColleciton();
49  $standard_views_for_data_collection = $this->getStandardViewsByVisibleTables($visible_tables_for_data_collection);
50 
51  $roles_ids = $this->getRolesIdsByViews($standard_views_for_data_collection);
52 
53  $roles_with_read_acces_ids = $this->getRolesIdsWithReadAccessOnDataCollection();
54 
55  //check if there are roles with rbac read right on the datacollection but without read right on any table view
56  $roles_with_no_read_right_on_any_standard_view = array_diff($roles_with_read_acces_ids, $roles_ids);
57 
58  $roles_data = $this->rbac_review->getRolesForIDs($roles_with_no_read_right_on_any_standard_view, true);
59  $role_titles = [];
60  if (!empty($roles_data)) {
61  foreach ($roles_data as $role_data) {
62  $role_titles[] = $role_data['title'];
63  }
64  }
65 
66  return $role_titles;
67  }
getStandardViewsByVisibleTables(array $visible_tables_for_data_collection)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStandardViewsByVisibleTables()

ilDclTableHelper::getStandardViewsByVisibleTables ( array  $visible_tables_for_data_collection)
protected

Definition at line 103 of file class.ilDclTableHelper.php.

References ActiveRecord\where().

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView(), and hasUserReadAccessOnAnyVisibleTableView().

103  : array
104  {
105  $standard_views_for_data_collection = [];
106  foreach ($visible_tables_for_data_collection as $visible_table) {
107  $standard_views_for_data_collection[] = ilDclTableView::where(
108  [
109  'table_id' => $visible_table['id'],
110  ]
111  )->get();
112  }
113 
114  return $standard_views_for_data_collection;
115  }
static where($where, $operator=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasUserReadAccessOnAnyVisibleTableView()

ilDclTableHelper::hasUserReadAccessOnAnyVisibleTableView ( )
protected

Definition at line 132 of file class.ilDclTableHelper.php.

References getAllVisibleTablesForDataColleciton(), getStandardViewsByVisibleTables(), in_array_r(), and ILIAS\Repository\user().

132  : bool
133  {
134  // admin user has always access to the views of a data collection
135  if ($this->user->getId() == 6) {
136  return true;
137  }
138 
139  $visible_tables_for_data_collection = $this->getAllVisibleTablesForDataColleciton();
140  $standard_views_for_data_collection = $this->getStandardViewsByVisibleTables($visible_tables_for_data_collection);
141 
142  $roles_ids = $this->getRolesIdsByViews($standard_views_for_data_collection);
143 
144  $user_ids_with_read_right_on_any_standard_view = [];
145  foreach ($roles_ids as $role_id) {
146  $assigned_users = $this->rbac_review->assignedUsers($role_id);
147  if (!empty($assigned_users)) {
148  $user_ids_with_read_right_on_any_standard_view[] = array_merge(
149  $user_ids_with_read_right_on_any_standard_view,
150  $assigned_users
151  );
152  }
153  }
154 
155  //check if current user id is in the array of user ids with read right on standard view
156  if ($this->in_array_r((string) $this->user->getId(), $user_ids_with_read_right_on_any_standard_view)) {
157  return true;
158  } else {
159  return false;
160  }
161  }
in_array_r(string $needle, array $haystack, bool $strict=false)
getStandardViewsByVisibleTables(array $visible_tables_for_data_collection)
+ Here is the call graph for this function:

◆ in_array_r()

ilDclTableHelper::in_array_r ( string  $needle,
array  $haystack,
bool  $strict = false 
)
protected

Definition at line 163 of file class.ilDclTableHelper.php.

Referenced by hasUserReadAccessOnAnyVisibleTableView().

163  : bool
164  {
165  foreach ($haystack as $item) {
166  if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r(
167  $needle,
168  $item,
169  $strict
170  ))) {
171  return true;
172  }
173  }
174 
175  return false;
176  }
in_array_r(string $needle, array $haystack, bool $strict=false)
+ Here is the caller graph for this function:

Field Documentation

◆ $database

ilDBInterface ilDclTableHelper::$database
protected

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

Referenced by __construct().

◆ $obj_id

int ilDclTableHelper::$obj_id = 0
protected

Definition at line 23 of file class.ilDclTableHelper.php.

Referenced by __construct().

◆ $rbac_review

ilRbacReview ilDclTableHelper::$rbac_review
protected

Definition at line 25 of file class.ilDclTableHelper.php.

Referenced by __construct().

◆ $ref_id

int ilDclTableHelper::$ref_id = 0
protected

Definition at line 24 of file class.ilDclTableHelper.php.

Referenced by __construct().

◆ $user

ilObjUser ilDclTableHelper::$user
protected

Definition at line 26 of file class.ilDclTableHelper.php.

Referenced by __construct().


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