ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilObjContentObjectAccess.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
6include_once("./Services/Object/classes/class.ilObjectAccess.php");
7
18{
19 static $online;
20 static $lo_access;
21
34 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
35 {
36 global $ilUser, $lng, $rbacsystem, $ilAccess;
37
38 if ($a_user_id == "")
39 {
40 $a_user_id = $ilUser->getId();
41 }
42
43 switch ($a_cmd)
44 {
45 case "view":
46
48 && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
49 {
50 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
51 return false;
52 }
53 break;
54
55 case "continue":
56
57 // no continue command for anonymous user
58 if ($ilUser->getId() == ANONYMOUS_USER_ID)
59 {
60 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("lm_no_continue_for_anonym"));
61 return false;
62 }
63
65 && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
66 {
67 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
68 return false;
69 }
70
71 if (ilObjContentObjectAccess::_getLastAccessedPage($a_ref_id,$a_user_id) <= 0)
72 {
73 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("not_accessed_yet"));
74 return false;
75 }
76 break;
77
78 // for permission query feature
79 case "info":
81 {
82 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
83 }
84 else
85 {
86 $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
87 }
88 break;
89
90 }
91
92 switch ($a_permission)
93 {
94 case "read":
95 case "visible":
97 (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
98 {
99 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
100 return false;
101 }
102 break;
103 }
104
105
106 return true;
107 }
108
109 //
110 // access relevant methods
111 //
112
118 function _lookupOnline($a_id)
119 {
120 global $ilDB;
121
122 if (isset(self::$online[$a_id]))
123 {
124 return self::$online[$a_id];
125 }
126
127 $q = "SELECT is_online FROM content_object WHERE id = ".$ilDB->quote($a_id, "integer");
128 $lm_set = $ilDB->query($q);
129 $lm_rec = $ilDB->fetchAssoc($lm_set);
130
131 self::$online[$a_id] = ilUtil::yn2tf($lm_rec["is_online"]);
132 return ilUtil::yn2tf($lm_rec["is_online"]);
133 }
134
141 function _getLastAccessedPage($a_ref_id, $a_user_id = "")
142 {
143 global $ilDB, $ilUser;
144
145 if ($a_user_id == "")
146 {
147 $a_user_id = $ilUser->getId();
148 }
149
150 if (isset(self::$lo_access[$a_ref_id]))
151 {
152 $acc_rec["obj_id"] = self::$lo_access[$a_ref_id];
153 }
154 else
155 {
156 $q = "SELECT * FROM lo_access WHERE ".
157 "usr_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
158 "lm_id = ".$ilDB->quote($a_ref_id, "integer");
159
160 $acc_set = $ilDB->query($q);
161 $acc_rec = $ilDB->fetchAssoc($acc_set);
162 }
163
164 if ($acc_rec["obj_id"] > 0)
165 {
166 $lm_id = ilObject::_lookupObjId($a_ref_id);
167 $mtree = new ilTree($lm_id);
168 $mtree->setTableNames('lm_tree','lm_data');
169 $mtree->setTreeTablePK("lm_id");
170 if ($mtree->isInTree($acc_rec["obj_id"]))
171 {
172 return $acc_rec["obj_id"];
173 }
174 }
175
176 return 0;
177 }
178
182 function _checkGoto($a_target)
183 {
184 global $ilAccess;
185
186 $t_arr = explode("_", $a_target);
187
188 if (($t_arr[0] != "lm" && $t_arr[0] != "dbk" && $t_arr[0] != "st"
189 && $t_arr[0] != "pg")
190 || ((int) $t_arr[1]) <= 0)
191 {
192 return false;
193 }
194
195 if ($t_arr[0] == "lm" || $t_arr[0] == "dbk")
196 {
197 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
198 $ilAccess->checkAccess("visible", "", $t_arr[1]))
199 {
200 return true;
201 }
202 }
203 else
204 {
205 if ($t_arr[2] > 0)
206 {
207 $ref_ids = array($t_arr[2]);
208 }
209 else
210 {
211 // determine learning object
212 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
213 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
214 $ref_ids = ilObject::_getAllReferences($lm_id);
215 }
216 // check read permissions
217 foreach ($ref_ids as $ref_id)
218 {
219 // Permission check
220 if ($ilAccess->checkAccess("read", "", $ref_id))
221 {
222 return true;
223 }
224 }
225
226 }
227 return false;
228 }
229
238 static function _isOffline($a_obj_id)
239 {
240 return !self::_lookupOnline($a_obj_id);
241 }
242
248 function _preloadData($a_obj_ids, $a_ref_ids)
249 {
250 global $ilDB, $ilUser;
251
252 $q = "SELECT id, is_online FROM content_object WHERE ".
253 $ilDB->in("id", $a_obj_ids, false, "integer");
254
255 $lm_set = $ilDB->query($q);
256 while ($rec = $ilDB->fetchAssoc($lm_set))
257 {
258 self::$online[$rec["id"]] = ilUtil::yn2tf($rec["is_online"]);
259 }
260
261 $q = "SELECT obj_id, lm_id FROM lo_access WHERE ".
262 "usr_id = ".$ilDB->quote($ilUser->getId(), "integer")." AND ".
263 $ilDB->in("lm_id", $a_ref_ids, false, "integer");;
264 $set = $ilDB->query($q);
265 foreach ($a_ref_ids as $r)
266 {
267 self::$lo_access[$r] = 0;
268 }
269 while ($rec = $ilDB->fetchAssoc($set))
270 {
271 self::$lo_access[$rec["lm_id"]] = $rec["obj_id"];
272 }
273
274 }
275
276}
277
278?>
const IL_NO_OBJECT_ACCESS
_lookupContObjID($a_id)
get learning module / digibook id for lm object
Class ilObjContentObjectAccess.
_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...
static _isOffline($a_obj_id)
Type-specific implementation of general status.
_lookupOnline($a_id)
check wether learning module is online
_preloadData($a_obj_ids, $a_ref_ids)
Preload data.
_checkGoto($a_target)
check whether goto script will succeed
_getLastAccessedPage($a_ref_id, $a_user_id="")
get last accessed page
Class ilObjectAccess.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static yn2tf($a_yn)
convert "y"/"n" to true/false
global $lng
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
global $ilDB
$lm_set
global $ilUser
Definition: imgupload.php:15