ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjContentObjectAccess Class Reference

Class ilObjContentObjectAccess. More...

+ Inheritance diagram for ilObjContentObjectAccess:
+ Collaboration diagram for ilObjContentObjectAccess:

Public Member Functions

 __construct ()
 Constructor. More...
 
 _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 _lookupOnline ($a_id)
 check wether learning module is online More...
 
static _getLastAccessedPage ($a_ref_id, $a_user_id="")
 get last accessed page More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 
- 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 Public Attributes

static $online
 
static $lo_access
 

Protected Attributes

 $user
 
 $lng
 
 $rbacsystem
 
 $access
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjContentObjectAccess::__construct ( )

Constructor.

Reimplemented in ilObjLearningModuleAccess.

Definition at line 43 of file class.ilObjContentObjectAccess.php.

44 {
45 global $DIC;
46
47 $this->user = $DIC->user();
48 $this->lng = $DIC->language();
49 $this->rbacsystem = $DIC->rbac()->system();
50 $this->access = $DIC->access();
51 }
user()
Definition: user.php:4
global $DIC
Definition: saml.php:7

References $DIC, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _checkAccess()

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::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

Reimplemented from ilObjectAccess.

Definition at line 68 of file class.ilObjContentObjectAccess.php.

69 {
73 $ilAccess = $this->access;
74
75 if ($a_user_id == "") {
76 $a_user_id = $ilUser->getId();
77 }
78
79 switch ($a_cmd) {
80 case "view":
81
83 && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
84 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
85 return false;
86 }
87 break;
88
89 case "continue":
90 if (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
92 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
93 return false;
94 }
95 }
96
97 // continue is now default and works all the time
98 // see ilLMPresentationGUI::resume()
99 /*
100 if ($ilUser->getId() == ANONYMOUS_USER_ID)
101 {
102 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("lm_no_continue_for_anonym"));
103 return false;
104 }
105 if (ilObjContentObjectAccess::_getLastAccessedPage($a_ref_id,$a_user_id) <= 0)
106 {
107 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("not_accessed_yet"));
108 return false;
109 }
110 */
111 break;
112
113 // for permission query feature
114 case "info":
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 }
123
124 switch ($a_permission) {
125 case "read":
126 case "visible":
128 (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
129 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
130 return false;
131 }
132 break;
133 }
134
135
136 return true;
137 }
const IL_STATUS_MESSAGE
const IL_NO_OBJECT_ACCESS
static _lookupOnline($a_id)
check wether learning module is online
$ilUser
Definition: imgupload.php:18

References $access, $ilUser, $lng, $rbacsystem, $user, _lookupOnline(), IL_NO_OBJECT_ACCESS, and IL_STATUS_MESSAGE.

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjContentObjectAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 210 of file class.ilObjContentObjectAccess.php.

211 {
212 global $DIC;
213
214 $ilAccess = $DIC->access();
215
216 $t_arr = explode("_", $a_target);
217
218 if (($t_arr[0] != "lm" && $t_arr[0] != "st"
219 && $t_arr[0] != "pg")
220 || ((int) $t_arr[1]) <= 0) {
221 return false;
222 }
223
224 if ($t_arr[0] == "lm") {
225 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
226 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
227 return true;
228 }
229 } else {
230 if ($t_arr[2] > 0) {
231 $ref_ids = array($t_arr[2]);
232 } else {
233 // determine learning object
234 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
235 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
236 $ref_ids = ilObject::_getAllReferences($lm_id);
237 }
238 // check read permissions
239 foreach ($ref_ids as $ref_id) {
240 // Permission check
241 if ($ilAccess->checkAccess("read", "", $ref_id)) {
242 return true;
243 }
244 }
245 }
246 return false;
247 }
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static _getAllReferences($a_id)
get all reference ids of object

References $DIC, ilObject\_getAllReferences(), and ilLMObject\_lookupContObjID().

+ Here is the call graph for this function:

◆ _getLastAccessedPage()

static ilObjContentObjectAccess::_getLastAccessedPage (   $a_ref_id,
  $a_user_id = "" 
)
static

get last accessed page

Parameters
int$a_obj_idcontent object id
int$a_user_iduser object id

Definition at line 172 of file class.ilObjContentObjectAccess.php.

173 {
174 global $DIC;
175
176 $ilDB = $DIC->database();
177 $ilUser = $DIC->user();
178
179 if ($a_user_id == "") {
180 $a_user_id = $ilUser->getId();
181 }
182
183 if (isset(self::$lo_access[$a_ref_id])) {
184 $acc_rec["obj_id"] = self::$lo_access[$a_ref_id];
185 } else {
186 $q = "SELECT * FROM lo_access WHERE " .
187 "usr_id = " . $ilDB->quote($a_user_id, "integer") . " AND " .
188 "lm_id = " . $ilDB->quote($a_ref_id, "integer");
189
190 $acc_set = $ilDB->query($q);
191 $acc_rec = $ilDB->fetchAssoc($acc_set);
192 }
193
194 if ($acc_rec["obj_id"] > 0) {
195 $lm_id = ilObject::_lookupObjId($a_ref_id);
196 $mtree = new ilTree($lm_id);
197 $mtree->setTableNames('lm_tree', 'lm_data');
198 $mtree->setTreeTablePK("lm_id");
199 if ($mtree->isInTree($acc_rec["obj_id"])) {
200 return $acc_rec["obj_id"];
201 }
202 }
203
204 return 0;
205 }
static _lookupObjId($a_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
global $ilDB

References $DIC, $ilDB, $ilUser, and ilObject\_lookupObjId().

Referenced by ilLMPresentationGUI\resume().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isOffline()

static ilObjContentObjectAccess::_isOffline (   $a_obj_id)
static

Type-specific implementation of general status.

Used in ListGUI and Learning Progress

Parameters
int$a_obj_id
Returns
bool

Reimplemented from ilObjectAccess.

Definition at line 257 of file class.ilObjContentObjectAccess.php.

258 {
259 return !self::_lookupOnline($a_obj_id);
260 }

References _lookupOnline().

Referenced by ilObjLearningModuleListGUI\getProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjContentObjectAccess::_lookupOnline (   $a_id)
static

check wether learning module is online

Parameters
int$a_idlearning object id

Definition at line 148 of file class.ilObjContentObjectAccess.php.

149 {
150 global $DIC;
151
152 $ilDB = $DIC->database();
153
154 if (isset(self::$online[$a_id])) {
155 return self::$online[$a_id];
156 }
157
158 $q = "SELECT is_online FROM content_object WHERE id = " . $ilDB->quote($a_id, "integer");
159 $lm_set = $ilDB->query($q);
160 $lm_rec = $ilDB->fetchAssoc($lm_set);
161
162 self::$online[$a_id] = ilUtil::yn2tf($lm_rec["is_online"]);
163 return ilUtil::yn2tf($lm_rec["is_online"]);
164 }
static yn2tf($a_yn)
convert "y"/"n" to true/false
$lm_set

References $DIC, $ilDB, $lm_set, and ilUtil\yn2tf().

Referenced by _checkAccess(), and _isOffline().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _preloadData()

static ilObjContentObjectAccess::_preloadData (   $a_obj_ids,
  $a_ref_ids 
)
static

Preload data.

Parameters
array$a_obj_idsarray of object ids

Reimplemented from ilObjectAccess.

Definition at line 267 of file class.ilObjContentObjectAccess.php.

268 {
269 global $DIC;
270
271 $ilDB = $DIC->database();
272 $ilUser = $DIC->user();
273
274 $q = "SELECT id, is_online FROM content_object WHERE " .
275 $ilDB->in("id", $a_obj_ids, false, "integer");
276
277 $lm_set = $ilDB->query($q);
278 while ($rec = $ilDB->fetchAssoc($lm_set)) {
279 self::$online[$rec["id"]] = ilUtil::yn2tf($rec["is_online"]);
280 }
281
282 $q = "SELECT obj_id, lm_id FROM lo_access WHERE " .
283 "usr_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " .
284 $ilDB->in("lm_id", $a_ref_ids, false, "integer");
285 ;
286 $set = $ilDB->query($q);
287 foreach ($a_ref_ids as $r) {
288 self::$lo_access[$r] = 0;
289 }
290 while ($rec = $ilDB->fetchAssoc($set)) {
291 self::$lo_access[$rec["lm_id"]] = $rec["obj_id"];
292 }
293 }
$r
Definition: example_031.php:79

References $DIC, $ilDB, $ilUser, $lm_set, $r, and ilUtil\yn2tf().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjContentObjectAccess::$access
protected

Definition at line 37 of file class.ilObjContentObjectAccess.php.

Referenced by _checkAccess().

◆ $lng

ilObjContentObjectAccess::$lng
protected

Definition at line 27 of file class.ilObjContentObjectAccess.php.

Referenced by _checkAccess().

◆ $lo_access

ilObjContentObjectAccess::$lo_access
static

Definition at line 54 of file class.ilObjContentObjectAccess.php.

◆ $online

ilObjContentObjectAccess::$online
static

Definition at line 53 of file class.ilObjContentObjectAccess.php.

◆ $rbacsystem

ilObjContentObjectAccess::$rbacsystem
protected

Definition at line 32 of file class.ilObjContentObjectAccess.php.

Referenced by _checkAccess().

◆ $user

ilObjContentObjectAccess::$user
protected

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

Referenced by _checkAccess().


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