ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDclTableHelper Class Reference

Class ilDclTableHelper. More...

+ 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 ($visible_tables_for_data_collection)
 
 getAllVisibleTablesForDataColleciton ()
 
 hasUserReadAccessOnAnyVisibleTableView ()
 
 in_array_r ($needle, $haystack, $strict=false)
 

Protected Attributes

 $obj_id = 0
 
 $ref_id = 0
 
 $rbac_review
 
 $user
 
 $database
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilDclTableHelper constructor.

Parameters
int$obj_id
int$ref_id
ilRbacReview$rbac_review
ilObjUser$user
ilDBInterface$database

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

41 {
42 $this->obj_id = $obj_id;
43 $this->ref_id = $ref_id;
44 $this->rbac_review = $rbac_review;
45 $this->user = $user;
46 $this->database = $database;
47 }
user()
Definition: user.php:4

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getAllVisibleTablesForDataColleciton()

ilDclTableHelper::getAllVisibleTablesForDataColleciton ( )
protected
Returns
array

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

140 {
141 $visible_tables_for_data_collection = [];
142 $res = $this->database->queryF(
143 "SELECT * FROM il_dcl_table WHERE obj_id = %s AND is_visible = 1", array('integer'), array($this->obj_id)
144 );
145 while ($rec = $this->database->fetchAssoc($res)) {
146 $visible_tables_for_data_collection[] = $rec;
147 }
148
149 return $visible_tables_for_data_collection;
150 }

References $res.

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView(), and hasUserReadAccessOnAnyVisibleTableView().

+ Here is the caller graph for this function:

◆ getRolesIdsWithReadAccessOnDataCollection()

ilDclTableHelper::getRolesIdsWithReadAccessOnDataCollection ( )
protected
Returns
array $roles_with_read_acces_ids

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

79 {
80 $rbac_roles = $this->rbac_review->getParentRoleIds($this->ref_id);
81 $roles_with_read_acces_ids = [];
82 //get all roles with read access on data collection
83 foreach ($rbac_roles as $role) {
84 $operations = $this->rbac_review->getActiveOperationsOfRole($this->ref_id, $role['rol_id']);
85 //3 corresponds to the read rbac right
86 if (!empty($operations) && in_array(3, $operations)) {
87 $roles_with_read_acces_ids[] = $role['rol_id'];
88 }
89 }
90
91 return $roles_with_read_acces_ids;
92 }

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView().

+ Here is the caller graph for this function:

◆ getRoleTitlesWithoutReadRightOnAnyStandardView()

ilDclTableHelper::getRoleTitlesWithoutReadRightOnAnyStandardView ( )
Returns
array

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

53 {
54 $visible_tables_for_data_collection = $this->getAllVisibleTablesForDataColleciton();
55 $standard_views_for_data_collection = $this->getStandardViewsByVisibleTables($visible_tables_for_data_collection);
56
57 $roles_ids = $this->getRolesIdsByViews($standard_views_for_data_collection);
58
59 $roles_with_read_acces_ids = $this->getRolesIdsWithReadAccessOnDataCollection();
60
61 //check if there are roles with rbac read right on the datacollection but without read right on any table view
62 $roles_with_no_read_right_on_any_standard_view = array_diff($roles_with_read_acces_ids, $roles_ids);
63
64 $roles_data = $this->rbac_review->getRolesForIDs($roles_with_no_read_right_on_any_standard_view, true);
65 $role_titles = [];
66 if (!empty($roles_data)) {
67 foreach ($roles_data as $role_data) {
68 $role_titles[] = $role_data['title'];
69 }
70 }
71
72 return $role_titles;
73 }
getStandardViewsByVisibleTables($visible_tables_for_data_collection)

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

+ Here is the call graph for this function:

◆ getStandardViewsByVisibleTables()

ilDclTableHelper::getStandardViewsByVisibleTables (   $visible_tables_for_data_collection)
protected
Parameters
array$visible_tables_for_data_collection
Returns
array

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

123 {
124 $standard_views_for_data_collection = [];
125 foreach ($visible_tables_for_data_collection as $visible_table) {
126 $standard_views_for_data_collection[] = ilDclTableView::where(
127 [
128 'table_id' => $visible_table['id']
129 ]
130 )->get();
131 }
132
133 return $standard_views_for_data_collection;
134 }
static where($where, $operator=null)

References ActiveRecord\where().

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView(), and hasUserReadAccessOnAnyVisibleTableView().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasUserReadAccessOnAnyVisibleTableView()

ilDclTableHelper::hasUserReadAccessOnAnyVisibleTableView ( )
protected

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

153 {
154 // admin user has always access to the views of a data collection
155 if ($this->user->getId() == 6) {
156 return true;
157 }
158
159 $visible_tables_for_data_collection = $this->getAllVisibleTablesForDataColleciton();
160 $standard_views_for_data_collection = $this->getStandardViewsByVisibleTables($visible_tables_for_data_collection);
161
162 $roles_ids = $this->getRolesIdsByViews($standard_views_for_data_collection);
163
164 $user_ids_with_read_right_on_any_standard_view = [];
165 foreach ($roles_ids as $role_id) {
166 $assigned_users = $this->rbac_review->assignedUsers($role_id);
167 if (!empty($assigned_users)) {
168 $user_ids_with_read_right_on_any_standard_view[] = array_merge($user_ids_with_read_right_on_any_standard_view, $assigned_users);
169 }
170 }
171
172 //check if current user id is in the array of user ids with read right on standard view
173 if ($this->in_array_r($this->user->getId(), $user_ids_with_read_right_on_any_standard_view)) {
174 return true;
175 } else {
176 return false;
177 }
178 }
in_array_r($needle, $haystack, $strict=false)

References getAllVisibleTablesForDataColleciton(), getStandardViewsByVisibleTables(), in_array_r(), and user().

+ Here is the call graph for this function:

◆ in_array_r()

ilDclTableHelper::in_array_r (   $needle,
  $haystack,
  $strict = false 
)
protected
Parameters
$needle
$haystack
bool$strict
Returns
bool

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

188 {
189 foreach ($haystack as $item) {
190 if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) {
191 return true;
192 }
193 }
194
195 return false;
196 }

References in_array_r().

Referenced by hasUserReadAccessOnAnyVisibleTableView(), and in_array_r().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $database

ilDclTableHelper::$database
protected

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

Referenced by __construct().

◆ $obj_id

ilDclTableHelper::$obj_id = 0
protected

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

Referenced by __construct().

◆ $rbac_review

ilDclTableHelper::$rbac_review
protected

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

Referenced by __construct().

◆ $ref_id

ilDclTableHelper::$ref_id = 0
protected

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

Referenced by __construct().

◆ $user

ilDclTableHelper::$user
protected

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

Referenced by __construct().


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