ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilObjDataCollectionAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/Object/classes/class.ilObjectAccess.php");
6 
18 
31  public function _getCommands() {
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  }
40 
41 
45  public function _checkGoto($a_target) {
46  global $ilAccess;
47 
48  $t_arr = explode("_", $a_target);
49 
50  if ($t_arr[0] != "dcl" || ((int)$t_arr[1]) <= 0) {
51  return false;
52  }
53 
54  if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
55  return true;
56  }
57 
58  return false;
59  }
60 
61 
74  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "") {
75  global $ilUser, $lng, $rbacsystem, $ilAccess;
76 
77  if ($a_user_id == "") {
78  $a_user_id = $ilUser->getId();
79  }
80  switch ($a_cmd) {
81  case "view":
82 
84  && ! $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)
85  ) {
86  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
87 
88  return false;
89  }
90  break;
91 
92  // for permission query feature
93  case "infoScreen":
95  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
96  } else {
97  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
98  }
99  break;
100  }
101  switch ($a_permission) {
102  case "read":
103  case "visible":
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 
114  return true;
115  }
116 
117 
123  public function _lookupOnline($a_id) {
124  global $ilDB;
125 
126  $q = "SELECT * FROM il_dcl_data WHERE id = " . $ilDB->quote($a_id, "integer");
127  $dcl_set = $ilDB->query($q);
128  $dcl_rec = $ilDB->fetchAssoc($dcl_set);
129 
130  return $dcl_rec["is_online"];
131  }
132 
133  //
134  // DataCollection specific Access-Checks
135  //
136 
143  public static function checkAccessForDataCollectionId($data_collection_id) {
144  global $ilAccess;
145 
146  $perm = false;
147  $references = ilObject2::_getAllReferences($data_collection_id);
148 
149  if ($ilAccess->checkAccess("add_entry", "", array_shift($references))) {
150  $perm = true;
151  }
152 
153  return $perm;
154  }
155 
156 
163  public static function checkActionForObjId($action, $obj_id) {
164  foreach (ilObject2::_getAllReferences($obj_id) as $ref_id) {
165  if (self::checkActionForRefId($action, $ref_id)) {
166  return true;
167  }
168  }
169 
170  return false;
171  }
172 
173 
180  public static function checkActionForRefId($action, $ref_id) {
181  global $ilAccess;
182 
187  return $ilAccess->checkAccess($action, "", $ref_id);
188  }
189 
190 
196  public static function hasWriteAccess($ref) {
197  global $ilAccess;
198 
199  return $ilAccess->checkAccess("write", "", $ref);
200  }
201 
202 
208  public static function hasAddRecordAccess($ref) {
209  global $ilAccess;
210 
211  return $ilAccess->checkAccess("add_entry", "", $ref);
212  }
213 
214 
220  public static function hasReadAccess($ref) {
221  global $ilAccess;
222 
223  return $ilAccess->checkAccess("read", "", $ref);
224  }
225 }
226 
227 ?>
const IL_NO_OBJECT_ACCESS
_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::checkAcce...
_lookupOnline($a_id)
Check wether datacollection is online.
static _getAllReferences($a_id)
_checkGoto($a_target)
check whether goto script will succeed
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
Class ilObjectAccess.
global $lng
Definition: privfeed.php:40
global $ilDB
static checkAccessForDataCollectionId($data_collection_id)
static checkActionForObjId($action, $obj_id)
Class ilObjDataCollectionAccess.