ILIAS  release_8 Revision v8.24
ilDclTableHelper Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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 (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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 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 30 of file class.ilDclTableHelper.php.

36 {
37 $this->obj_id = $obj_id;
38 $this->ref_id = $ref_id;
39 $this->rbac_review = $rbac_review;
40 $this->user = $user;
41 $this->database = $database;
42 }

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getAllVisibleTablesForDataColleciton()

ilDclTableHelper::getAllVisibleTablesForDataColleciton ( )
protected

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

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

References $res.

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView(), and hasUserReadAccessOnAnyVisibleTableView().

+ Here is the caller graph for this function:

◆ getRolesIdsWithReadAccessOnDataCollection()

ilDclTableHelper::getRolesIdsWithReadAccessOnDataCollection ( )
protected

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

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

Referenced by getRoleTitlesWithoutReadRightOnAnyStandardView().

+ Here is the caller graph for this function:

◆ getRoleTitlesWithoutReadRightOnAnyStandardView()

ilDclTableHelper::getRoleTitlesWithoutReadRightOnAnyStandardView ( )

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

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

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

+ Here is the call graph for this function:

◆ getStandardViewsByVisibleTables()

ilDclTableHelper::getStandardViewsByVisibleTables ( array  $visible_tables_for_data_collection)
protected

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

101 : array
102 {
103 $standard_views_for_data_collection = [];
104 foreach ($visible_tables_for_data_collection as $visible_table) {
105 $standard_views_for_data_collection[] = ilDclTableView::where(
106 [
107 'table_id' => $visible_table['id'],
108 ]
109 )->get();
110 }
111
112 return $standard_views_for_data_collection;
113 }
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 130 of file class.ilDclTableHelper.php.

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

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

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

161 : bool
162 {
163 foreach ($haystack as $item) {
164 if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r(
165 $needle,
166 $item,
167 $strict
168 ))) {
169 return true;
170 }
171 }
172
173 return false;
174 }

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

ilDBInterface ilDclTableHelper::$database
protected

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

Referenced by __construct().

◆ $obj_id

int ilDclTableHelper::$obj_id = 0
protected

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

Referenced by __construct().

◆ $rbac_review

ilRbacReview ilDclTableHelper::$rbac_review
protected

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

Referenced by __construct().

◆ $ref_id

int ilDclTableHelper::$ref_id = 0
protected

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

Referenced by __construct().

◆ $user

ilObjUser ilDclTableHelper::$user
protected

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

Referenced by __construct().


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