ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjDataCollectionAccess Class Reference

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

+ Inheritance diagram for ilObjDataCollectionAccess:
+ Collaboration diagram for ilObjDataCollectionAccess:

Public Member Functions

 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static _getCommands ()
 get commands this method returns an array of all possible commands/permission combinations example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), ); More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _lookupOnline (int $a_id)
 Check wether datacollection is online. More...
 
static checkAccessForDataCollectionId (int $data_collection_id)
 
static checkActionForObjId (string $action, int $obj_id)
 
static hasWriteAccess (int $ref, ?int $user_id=0)
 
static hasEditAccess (int $ref, ?int $user_id=0)
 
static hasAddRecordAccess (int $ref, ?int $user_id=0)
 
static hasReadAccess (int $ref, ?int $user_id=0)
 
static hasAccessToTableView ($tableview, ?int $user_id=0)
 This only checks access to the tableview - if the full access check is required, use hasAccessTo($ref_id, $table_id, $tableview_id) More...
 
static hasAccessToFields (int $ref_id, int $table_id)
 
static hasAccessToEditTable (int $ref_id, int $table_id)
 
static hasAccessToField (int $ref_id, int $table_id, int $field_id)
 
static hasPermissionToAddRecord (int $ref_id, int $table_id)
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 

Static Protected Member Functions

static isTableInDataCollection (ilDclTable $table, int $ref_id)
 
static hasAccessToTable (int $table_id, int $ref_id)
 returns true if either the table is visible for all users, or no tables are visible and this is the table with the lowest order (getFirstVisibleTableId()) More...
 

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.ilObjDataCollectionAccess.php.

Member Function Documentation

◆ _checkAccess()

ilObjDataCollectionAccess::_checkAccess ( string  $cmd,
string  $permission,
int  $ref_id,
int  $obj_id,
?int  $user_id = null 
)

Definition at line 77 of file class.ilObjDataCollectionAccess.php.

References $DIC, $ilUser, $lng, _lookupOnline(), ilAccessInfo\IL_NO_OBJECT_ACCESS, and ilAccessInfo\IL_STATUS_MESSAGE.

77  : bool
78  {
79  global $DIC;
80  $ilUser = $DIC['ilUser'];
81  $lng = $DIC['lng'];
82  $rbacsystem = $DIC['rbacsystem'];
83  $ilAccess = $DIC['ilAccess'];
84 
85  if (is_null($user_id) === true) {
86  $user_id = $ilUser->getId();
87  }
88 
89  switch ($cmd) {
90  case "view":
91 
93  && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)
94  ) {
95  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
96 
97  return false;
98  }
99  break;
100 
101  // for permission query feature
102  case "infoScreen":
104  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
105  } else {
106  $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_MESSAGE, $lng->txt("online"));
107  }
108  break;
109  }
110  switch ($permission) {
111  case "read":
112  case "visible":
114  && (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))
115  ) {
116  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
117 
118  return false;
119  }
120  break;
121  }
122 
123  return true;
124  }
$lng
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$ilUser
Definition: imgupload.php:34
static _lookupOnline(int $a_id)
Check wether datacollection is online.
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjDataCollectionAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Definition at line 45 of file class.ilObjDataCollectionAccess.php.

References $DIC.

45  : bool
46  {
47  global $DIC;
48  $ilAccess = $DIC['ilAccess'];
49 
50  $t_arr = explode("_", $target);
51 
52  if ($t_arr[0] != "dcl" || ((int) $t_arr[1]) <= 0) {
53  return false;
54  }
55 
56  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
57  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
58  return true;
59  }
60 
61  return false;
62  }
global $DIC
Definition: feed.php:28

◆ _getCommands()

static ilObjDataCollectionAccess::_getCommands ( )
static

get commands this method returns an array of all possible commands/permission combinations example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Definition at line 31 of file class.ilObjDataCollectionAccess.php.

Referenced by ilObjDataCollectionListGUI\init().

31  : array
32  {
33  $commands = array(
34  array("permission" => "read", "cmd" => "render", "lang_var" => "show", "default" => true),
35  array("permission" => "write", "cmd" => "listRecords", "lang_var" => "edit_content"),
36  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
37  );
38 
39  return $commands;
40  }
+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjDataCollectionAccess::_lookupOnline ( int  $a_id)
static

Check wether datacollection is online.

Parameters
int$a_idwiki id

Definition at line 130 of file class.ilObjDataCollectionAccess.php.

References $DIC, and $ilDB.

Referenced by _checkAccess(), ilObjDataCollectionListGUI\getProperties(), and ilContainer\legacyOnlineFilter().

130  : bool
131  {
132  global $DIC;
133  $ilDB = $DIC->database();
134 
135  $q = "SELECT * FROM il_dcl_data WHERE id = " . $ilDB->quote($a_id, "integer");
136  $dcl_set = $ilDB->query($q);
137  $dcl_rec = $ilDB->fetchAssoc($dcl_set);
138 
139  return !is_null($dcl_rec) && $dcl_rec["is_online"];
140  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ checkAccessForDataCollectionId()

static ilObjDataCollectionAccess::checkAccessForDataCollectionId ( int  $data_collection_id)
static
Parameters
$data_collection_iduse checkActionForId instead
Returns
bool

Definition at line 151 of file class.ilObjDataCollectionAccess.php.

References $DIC, and ilObject\_getAllReferences().

151  : bool
152  {
153  global $DIC;
154  $ilAccess = $DIC['ilAccess'];
155 
156  $perm = false;
157  $references = ilObject2::_getAllReferences($data_collection_id);
158 
159  if ($ilAccess->checkAccess("add_entry", "", array_shift($references))) {
160  $perm = true;
161  }
162 
163  return $perm;
164  }
static _getAllReferences(int $id)
get all reference ids for object ID
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ checkActionForObjId()

static ilObjDataCollectionAccess::checkActionForObjId ( string  $action,
int  $obj_id 
)
static

Definition at line 166 of file class.ilObjDataCollectionAccess.php.

References $DIC, $ref_id, and ilObject\_getAllReferences().

Referenced by ilDclTableEditGUI\save().

166  : bool
167  {
168  foreach (ilObject2::_getAllReferences($obj_id) as $ref_id) {
169  if (self::checkActionForRefId($action, $ref_id)) {
170  return true;
171  }
172  }
173 
174  return false;
175  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAccessToEditTable()

static ilObjDataCollectionAccess::hasAccessToEditTable ( int  $ref_id,
int  $table_id 
)
static

Definition at line 310 of file class.ilObjDataCollectionAccess.php.

Referenced by ilDclTableViewGUI\checkAccess(), ilDclFieldListGUI\checkAccess(), ilDclTableViewEditGUI\checkAccess(), and ilDclTableEditGUI\checkAccess().

310  : bool
311  {
312  return self::hasAccessToFields($ref_id, $table_id);
313  }
$ref_id
Definition: ltiauth.php:67
+ Here is the caller graph for this function:

◆ hasAccessToField()

static ilObjDataCollectionAccess::hasAccessToField ( int  $ref_id,
int  $table_id,
int  $field_id 
)
static

Definition at line 315 of file class.ilObjDataCollectionAccess.php.

References ilDclCache\getTableCache().

Referenced by ilDclFieldEditGUI\checkAccess().

315  : bool
316  {
317  $table = ilDclCache::getTableCache($table_id);
318 
319  return in_array($field_id, $table->getFieldIds()) && self::hasAccessToFields($ref_id, $table_id);
320  }
$ref_id
Definition: ltiauth.php:67
static getTableCache(int $table_id=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAccessToFields()

static ilObjDataCollectionAccess::hasAccessToFields ( int  $ref_id,
int  $table_id 
)
static

Definition at line 304 of file class.ilObjDataCollectionAccess.php.

References ilDclCache\getTableCache().

Referenced by ilDclFieldEditGUI\checkAccess(), ilDclRecordListGUI\executeCommand(), and ilDclFieldListTableGUI\fillRowFromObject().

304  : bool
305  {
306  return self::isTableInDataCollection(ilDclCache::getTableCache($table_id), $ref_id)
307  && (self::hasWriteAccess($ref_id));
308  }
$ref_id
Definition: ltiauth.php:67
static getTableCache(int $table_id=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAccessToTable()

static ilObjDataCollectionAccess::hasAccessToTable ( int  $table_id,
int  $ref_id 
)
staticprotected

returns true if either the table is visible for all users, or no tables are visible and this is the table with the lowest order (getFirstVisibleTableId())

Parameters
$table_id
Returns
bool

Definition at line 278 of file class.ilObjDataCollectionAccess.php.

References ilDclCache\getTableCache().

278  : bool
279  {
280  $table = ilDclCache::getTableCache($table_id);
281  return self::hasWriteAccess($ref_id) || $table->getIsVisible();
282  }
$ref_id
Definition: ltiauth.php:67
static getTableCache(int $table_id=null)
+ Here is the call graph for this function:

◆ hasAccessToTableView()

static ilObjDataCollectionAccess::hasAccessToTableView (   $tableview,
?int  $user_id = 0 
)
static

This only checks access to the tableview - if the full access check is required, use hasAccessTo($ref_id, $table_id, $tableview_id)

Parameters
integer | ilDclTableView$tableviewcan be object or id

Definition at line 253 of file class.ilObjDataCollectionAccess.php.

References $DIC, and $ilUser.

Referenced by ilDclTable\getVisibleTableViews().

253  : bool
254  {
255  global $DIC;
256  $rbacreview = $DIC['rbacreview'];
257  $ilUser = $DIC['ilUser'];
258  if (!$tableview) {
259  return false;
260  }
261 
262  if (is_numeric($tableview)) {
263  $tableview = ilDclTableView::find($tableview);
264  }
265 
266  $assigned_roles = $rbacreview->assignedRoles($user_id ?: $ilUser->getId());
267  $allowed_roles = $tableview->getRoles();
268 
269  return !empty(array_intersect($assigned_roles, $allowed_roles));
270  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
+ Here is the caller graph for this function:

◆ hasAddRecordAccess()

static ilObjDataCollectionAccess::hasAddRecordAccess ( int  $ref,
?int  $user_id = 0 
)
static
Parameters
$refint the reference id of the datacollection object to check.
Returns
bool whether or not the current user has admin/write access to the referenced datacollection

Definition at line 221 of file class.ilObjDataCollectionAccess.php.

References $DIC.

Referenced by ilDclRecordEditGUI\getRecord(), hasPermissionToAddRecord(), ilDclTable\hasPermissionToDeleteRecord(), ilDclTable\hasPermissionToDeleteRecords(), and ilDclTable\hasPermissionToEditRecord().

221  : bool
222  {
223  global $DIC;
224  $ilAccess = $DIC['ilAccess'];
225 
226  if ($user_id) {
227  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
228  }
229 
230  return $ilAccess->checkAccess("add_entry", "", $ref);
231  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ hasEditAccess()

static ilObjDataCollectionAccess::hasEditAccess ( int  $ref,
?int  $user_id = 0 
)
static

Definition at line 205 of file class.ilObjDataCollectionAccess.php.

References $DIC.

Referenced by ilDclRecordEditGUI\cancelSave(), ilDclTable\getPartialRecords(), ilDclTable\hasPermissionToEditRecord(), and ilDclTable\hasPermissionToViewRecord().

205  : bool
206  {
207  global $DIC;
208  $ilAccess = $DIC['ilAccess'];
209 
210  if ($user_id) {
211  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
212  }
213 
214  return $ilAccess->checkAccess("edit_content", "", $ref);
215  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ hasPermissionToAddRecord()

static ilObjDataCollectionAccess::hasPermissionToAddRecord ( int  $ref_id,
int  $table_id 
)
static

Definition at line 322 of file class.ilObjDataCollectionAccess.php.

References ilDclCache\getTableCache(), hasAddRecordAccess(), and hasWriteAccess().

Referenced by ilDclRecordListGUI\executeCommand(), ilDclReferenceFieldRepresentation\getInputField(), ilDclRecordListGUI\importExcel(), and ilDclRecordEditGUI\save().

322  : bool
323  {
324  $table = ilDclCache::getTableCache($table_id);
325  if (!self::isTableInDataCollection($table, $ref_id)) {
326  return false;
327  }
328 
330  || (ilObjDataCollectionAccess::hasAddRecordAccess($ref_id) && $table->getAddPerm() && $table->checkLimit());
331  }
static hasAddRecordAccess(int $ref, ?int $user_id=0)
$ref_id
Definition: ltiauth.php:67
static getTableCache(int $table_id=null)
static hasWriteAccess(int $ref, ?int $user_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasReadAccess()

static ilObjDataCollectionAccess::hasReadAccess ( int  $ref,
?int  $user_id = 0 
)
static
Parameters
$refint the reference id of the datacollection object to check.
Returns
bool whether or not the current user has read access to the referenced datacollection

Definition at line 237 of file class.ilObjDataCollectionAccess.php.

References $DIC.

Referenced by ilObjDataCollection\_hasReadAccess(), ilSoapDataCollectionAdministration\exportDataCollectionContent(), and ilDclTable\hasPermissionToViewRecord().

237  : bool
238  {
239  global $DIC;
240  $ilAccess = $DIC['ilAccess'];
241 
242  if ($user_id) {
243  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
244  }
245 
246  return $ilAccess->checkAccess("read", "", $ref);
247  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ hasWriteAccess()

static ilObjDataCollectionAccess::hasWriteAccess ( int  $ref,
?int  $user_id = 0 
)
static
Parameters
$refint the reference id of the datacollection object to check.
Returns
bool whether or not the current user has admin/write access to the referenced datacollection

Definition at line 193 of file class.ilObjDataCollectionAccess.php.

References $DIC.

Referenced by ilObjDataCollection\_hasWriteAccess(), ilDclRecordEditGUI\cancelSave(), ilDclTableListGUI\checkAccess(), ilDclTableEditGUI\checkAccess(), ilDclDetailedViewGUI\doExtReplace(), ilObjDataCollection\doUpdate(), ilDclRecordListGUI\getAvailableTables(), ilDclTable\getPartialRecords(), ilDclTable\getVisibleTableViews(), hasPermissionToAddRecord(), ilDclTable\hasPermissionToDeleteRecord(), ilDclTable\hasPermissionToDeleteRecords(), ilDclTable\hasPermissionToEditRecord(), ilDclTable\hasPermissionToViewRecord(), ilDclRecordEditGUI\initForm(), and ilDclRecordEditGUI\save().

193  : bool
194  {
195  global $DIC;
196  $ilAccess = $DIC['ilAccess'];
197 
198  if ($user_id) {
199  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
200  }
201 
202  return $ilAccess->checkAccess("write", "", $ref);
203  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ isTableInDataCollection()

static ilObjDataCollectionAccess::isTableInDataCollection ( ilDclTable  $table,
int  $ref_id 
)
staticprotected

Definition at line 64 of file class.ilObjDataCollectionAccess.php.

References ilObject\_getAllReferences(), and ilDclTable\getObjId().

64  : bool
65  {
66  if ($table->getObjId() !== null) {
67  foreach (ilObjDataCollection::_getAllReferences($table->getObjId()) as $reference) {
68  if ($reference == $ref_id) {
69  return true;
70  }
71  }
72  }
73 
74  return false;
75  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

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