ILIAS  release_7 Revision v7.30-3-g800a261c036
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 42 of file class.ilDclTableHelper.php.

43 {
44 $this->obj_id = $obj_id;
45 $this->ref_id = $ref_id;
46 $this->rbac_review = $rbac_review;
47 $this->user = $user;
48 $this->database = $database;
49 }
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 146 of file class.ilDclTableHelper.php.

147 {
148 $visible_tables_for_data_collection = [];
149 $res = $this->database->queryF(
150 "SELECT * FROM il_dcl_table WHERE obj_id = %s AND is_visible = 1",
151 array('integer'),
152 array($this->obj_id)
153 );
154 while ($rec = $this->database->fetchAssoc($res)) {
155 $visible_tables_for_data_collection[] = $rec;
156 }
157
158 return $visible_tables_for_data_collection;
159 }
foreach($_POST as $key=> $value) $res

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 82 of file class.ilDclTableHelper.php.

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

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView().

+ Here is the caller graph for this function:

◆ getRoleTitlesWithoutReadRightOnAnyStandardView()

ilDclTableHelper::getRoleTitlesWithoutReadRightOnAnyStandardView ( )
Returns
array

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

56 {
57 $visible_tables_for_data_collection = $this->getAllVisibleTablesForDataColleciton();
58 $standard_views_for_data_collection = $this->getStandardViewsByVisibleTables($visible_tables_for_data_collection);
59
60 $roles_ids = $this->getRolesIdsByViews($standard_views_for_data_collection);
61
62 $roles_with_read_acces_ids = $this->getRolesIdsWithReadAccessOnDataCollection();
63
64 //check if there are roles with rbac read right on the datacollection but without read right on any table view
65 $roles_with_no_read_right_on_any_standard_view = array_diff($roles_with_read_acces_ids, $roles_ids);
66
67 $roles_data = $this->rbac_review->getRolesForIDs($roles_with_no_read_right_on_any_standard_view, true);
68 $role_titles = [];
69 if (!empty($roles_data)) {
70 foreach ($roles_data as $role_data) {
71 $role_titles[] = $role_data['title'];
72 }
73 }
74
75 return $role_titles;
76 }
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 128 of file class.ilDclTableHelper.php.

129 {
130 $standard_views_for_data_collection = [];
131 foreach ($visible_tables_for_data_collection as $visible_table) {
132 $standard_views_for_data_collection[] = ilDclTableView::where(
133 [
134 'table_id' => $visible_table['id'],
135 ]
136 )->get();
137 }
138
139 return $standard_views_for_data_collection;
140 }
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 162 of file class.ilDclTableHelper.php.

163 {
164 // admin user has always access to the views of a data collection
165 if ($this->user->getId() == 6) {
166 return true;
167 }
168
169 $visible_tables_for_data_collection = $this->getAllVisibleTablesForDataColleciton();
170 $standard_views_for_data_collection = $this->getStandardViewsByVisibleTables($visible_tables_for_data_collection);
171
172 $roles_ids = $this->getRolesIdsByViews($standard_views_for_data_collection);
173
174 $user_ids_with_read_right_on_any_standard_view = [];
175 foreach ($roles_ids as $role_id) {
176 $assigned_users = $this->rbac_review->assignedUsers($role_id);
177 if (!empty($assigned_users)) {
178 $user_ids_with_read_right_on_any_standard_view[] = array_merge($user_ids_with_read_right_on_any_standard_view, $assigned_users);
179 }
180 }
181
182 //check if current user id is in the array of user ids with read right on standard view
183 if ($this->in_array_r($this->user->getId(), $user_ids_with_read_right_on_any_standard_view)) {
184 return true;
185 } else {
186 return false;
187 }
188 }
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 198 of file class.ilDclTableHelper.php.

199 {
200 foreach ($haystack as $item) {
201 if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) {
202 return true;
203 }
204 }
205
206 return false;
207 }

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 30 of file class.ilDclTableHelper.php.

Referenced by __construct().

◆ $obj_id

ilDclTableHelper::$obj_id = 0
protected

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

Referenced by __construct().

◆ $rbac_review

ilDclTableHelper::$rbac_review
protected

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

Referenced by __construct().

◆ $ref_id

ilDclTableHelper::$ref_id = 0
protected

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

Referenced by __construct().

◆ $user

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: