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

Class ilObjDataCollectionAccess. More...

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

Public Member Functions

 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _lookupOnline ($a_id)
 Check wether datacollection is online. More...
 
static checkAccessForDataCollectionId ($data_collection_id)
 
static checkActionForObjId ($action, $obj_id)
 
static hasWriteAccess ($ref, $user_id=0)
 
static hasEditAccess ($ref, $user_id=0)
 Has permission to view and edit all entries event when he is not the owner. More...
 
static hasAddRecordAccess ($ref, $user_id=0)
 
static hasReadAccess ($ref, $user_id=0)
 
static hasAccessToTableView ($tableview, $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 ($ref_id, $table_id)
 
static hasAccessToEditTable ($ref_id, $table_id)
 
static hasAccessToField ($ref_id, $table_id, $field_id)
 
static hasPermissionToAddRecord ($ref_id, $table_id)
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Static Protected Member Functions

static isTableInDataCollection ($table, $ref_id)
 
static hasAccessToTable ($table_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

Member Function Documentation

◆ _checkAccess()

ilObjDataCollectionAccess::_checkAccess (   $a_cmd,
  $a_permission,
  $a_ref_id,
  $a_obj_id,
  $a_user_id = "" 
)

checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)

Parameters
string$a_cmdcommand (not permission!)
string$a_permissionpermission
int$a_ref_idreference id
int$a_obj_idobject id
int$a_user_iduser id (if not provided, current user is taken)
Returns
boolean true, if everything is ok

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

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

91  {
92  global $DIC;
93  $ilUser = $DIC['ilUser'];
94  $lng = $DIC['lng'];
95  $rbacsystem = $DIC['rbacsystem'];
96  $ilAccess = $DIC['ilAccess'];
97 
98  if ($a_user_id == "") {
99  $a_user_id = $ilUser->getId();
100  }
101  switch ($a_cmd) {
102  case "view":
103 
105  && ! $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)
106  ) {
107  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
108 
109  return false;
110  }
111  break;
112 
113  // for permission query feature
114  case "infoScreen":
115  if (! ilObjDataCollectionAccess::_lookupOnline($a_obj_id)) {
116  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
117  } else {
118  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
119  }
120  break;
121  }
122  switch ($a_permission) {
123  case "read":
124  case "visible":
126  && (! $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))
127  ) {
128  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
129 
130  return false;
131  }
132  break;
133  }
134 
135  return true;
136  }
static _lookupOnline($a_id)
Check wether datacollection is online.
const IL_NO_OBJECT_ACCESS
$ilUser
Definition: imgupload.php:18
global $lng
Definition: privfeed.php:17
global $DIC
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjDataCollectionAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

References $DIC.

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

◆ _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.

References array.

Referenced by ilObjDataCollectionListGUI\init().

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

◆ _lookupOnline()

static ilObjDataCollectionAccess::_lookupOnline (   $a_id)
static

Check wether datacollection is online.

Parameters
int$a_idwiki id

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

References $DIC, and $ilDB.

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

144  {
145  global $DIC;
146  $ilDB = $DIC['ilDB'];
147 
148  $q = "SELECT * FROM il_dcl_data WHERE id = " . $ilDB->quote($a_id, "integer");
149  $dcl_set = $ilDB->query($q);
150  $dcl_rec = $ilDB->fetchAssoc($dcl_set);
151 
152  return $dcl_rec["is_online"];
153  }
global $ilDB
global $DIC
+ Here is the caller graph for this function:

◆ checkAccessForDataCollectionId()

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

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

References $DIC, and ilObject2\_getAllReferences().

165  {
166  global $DIC;
167  $ilAccess = $DIC['ilAccess'];
168 
169  $perm = false;
170  $references = ilObject2::_getAllReferences($data_collection_id);
171 
172  if ($ilAccess->checkAccess("add_entry", "", array_shift($references))) {
173  $perm = true;
174  }
175 
176  return $perm;
177  }
static _getAllReferences($a_id)
global $DIC
+ Here is the call graph for this function:

◆ checkActionForObjId()

static ilObjDataCollectionAccess::checkActionForObjId (   $action,
  $obj_id 
)
static
Parameters
$action
$obj_id
Returns
bool

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

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

Referenced by ilDclTableEditGUI\save().

186  {
187  foreach (ilObject2::_getAllReferences($obj_id) as $ref_id) {
188  if (self::checkActionForRefId($action, $ref_id)) {
189  return true;
190  }
191  }
192 
193  return false;
194  }
static _getAllReferences($a_id)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAccessToEditTable()

static ilObjDataCollectionAccess::hasAccessToEditTable (   $ref_id,
  $table_id 
)
static
Parameters
$ref_id
$table_id
Returns
bool

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

References $ref_id.

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

366  {
367  return self::hasAccessToFields($ref_id, $table_id);
368  }
$ref_id
Definition: sahs_server.php:39
+ Here is the caller graph for this function:

◆ hasAccessToField()

static ilObjDataCollectionAccess::hasAccessToField (   $ref_id,
  $table_id,
  $field_id 
)
static
Parameters
$ref_id
$table_id
$field_id
Returns
bool

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

References $ref_id, and ilDclCache\getTableCache().

Referenced by ilDclFieldEditGUI\checkAccess().

378  {
379  $table = ilDclCache::getTableCache($table_id);
380  return in_array($field_id, $table->getFieldIds()) && self::hasAccessToFields($ref_id, $table_id);
381  }
static getTableCache($table_id=0)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAccessToFields()

static ilObjDataCollectionAccess::hasAccessToFields (   $ref_id,
  $table_id 
)
static
Parameters
$ref_id
$table_id
Returns
bool

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

References $ref_id, and ilDclCache\getTableCache().

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

354  {
355  return self::isTableInDataCollection(ilDclCache::getTableCache($table_id), $ref_id)
356  && (self::hasWriteAccess($ref_id));
357  }
static getTableCache($table_id=0)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAccessToTable()

static ilObjDataCollectionAccess::hasAccessToTable (   $table_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 318 of file class.ilObjDataCollectionAccess.php.

References $ref_id, and ilDclCache\getTableCache().

318  {
319  $table = ilDclCache::getTableCache($table_id);
320  return $table->getIsVisible() || ($table_id == $table->getCollectionObject()->getFirstVisibleTableId());
321  }
static getTableCache($table_id=0)
+ Here is the call graph for this function:

◆ hasAccessToTableView()

static ilObjDataCollectionAccess::hasAccessToTableView (   $tableview,
  $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
int$user_id
Returns
bool

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

References $DIC, and $ilUser.

Referenced by ilDclTable\getVisibleTableViews().

290  {
291  global $DIC;
292  $rbacreview = $DIC['rbacreview'];
293  $ilUser = $DIC['ilUser'];
294  if (!$tableview) {
295  return false;
296  }
297 
298 
299  if (is_numeric($tableview)) {
300  $tableview = ilDclTableView::find($tableview);
301  }
302 
303  $assigned_roles = $rbacreview->assignedRoles($user_id ? $user_id : $ilUser->getId());
304  $allowed_roles = $tableview->getRoles();
305 
306  return !empty(array_intersect($assigned_roles, $allowed_roles));
307  }
$ilUser
Definition: imgupload.php:18
global $DIC
+ Here is the caller graph for this function:

◆ hasAddRecordAccess()

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

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

References $DIC.

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

256  {
257  global $DIC;
258  $ilAccess = $DIC['ilAccess'];
259 
260  if ($user_id) {
261  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
262  }
263  return $ilAccess->checkAccess("add_entry", "", $ref);
264  }
global $DIC
+ Here is the caller graph for this function:

◆ hasEditAccess()

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

Has permission to view and edit all entries event when he is not the owner.

Parameters
$ref
int$user_id
Returns
mixed

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

References $DIC.

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

240  {
241  global $DIC;
242  $ilAccess = $DIC['ilAccess'];
243 
244  if ($user_id) {
245  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
246  }
247  return $ilAccess->checkAccess("edit_content", "", $ref);
248  }
global $DIC
+ Here is the caller graph for this function:

◆ hasPermissionToAddRecord()

static ilObjDataCollectionAccess::hasPermissionToAddRecord (   $ref_id,
  $table_id 
)
static
Parameters
int$ref_id
Returns
bool

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

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

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

389  {
390  $table = ilDclCache::getTableCache($table_id);
391  if (!self::isTableInDataCollection($table, $ref_id)){
392  return false;
393  }
394 
396  || (ilObjDataCollectionAccess::hasAddRecordAccess($ref_id) && $table->getAddPerm() && $table->checkLimit());
397  }
static getTableCache($table_id=0)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasReadAccess()

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

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

References $DIC.

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

272  {
273  global $DIC;
274  $ilAccess = $DIC['ilAccess'];
275 
276  if ($user_id) {
277  return $ilAccess->checkAccessOfUser($user_id, "write", "", $ref);
278  }
279  return $ilAccess->checkAccess("read", "", $ref);
280  }
global $DIC
+ Here is the caller graph for this function:

◆ hasWriteAccess()

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

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

References $DIC.

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

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

◆ isTableInDataCollection()

static ilObjDataCollectionAccess::isTableInDataCollection (   $table,
  $ref_id 
)
staticprotected
Parameters
ilDclTable$table
$ref_id
Returns
bool

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

References $ref_id, and ilObject2\_getAllReferences().

69  {
70  foreach (ilObjDataCollection::_getAllReferences($table->getObjId()) as $reference) {
71  if ($reference == $ref_id) {
72  return true;
73  }
74  }
75  return false;
76  }
static _getAllReferences($a_id)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:

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