ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilObjSAHSLearningModuleAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Object/classes/class.ilObjectAccess.php");
6 include_once 'Services/AccessControl/interfaces/interface.ilConditionHandling.php';
7 
18 {
19 
23  public static function getConditionOperators()
24  {
25  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
26  return array(
29  );
30  }
31 
32 
41  public static function checkCondition($a_trigger_obj_id,$a_operator,$a_value,$a_usr_id)
42  {
43  switch($a_operator)
44  {
45 
47  include_once './Services/Tracking/classes/class.ilLPStatus.php';
48  ilLPStatus::_lookupStatus($a_trigger_obj_id, $a_usr_id) == ilLPStatus::LP_STATUS_FAILED_NUM;
49  break;
50 
52  default:
53  include_once './Services/Tracking/classes/class.ilLPStatus.php';
54  return ilLPStatus::_hasUserCompleted($a_trigger_obj_id, $a_usr_id);
55 
56  }
57  return true;
58  }
59 
60 
61 
74  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
75  {
76  global $ilUser, $lng, $rbacsystem, $ilAccess;
77 
78  if ($a_user_id == "")
79  {
80  $a_user_id = $ilUser->getId();
81  }
82 
83  switch ($a_cmd)
84  {
85  case "view":
86 
88  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
89  {
90  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
91  return false;
92  }
93  break;
94  }
95 
96  switch ($a_permission)
97  {
98  case "visible":
100  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
101  {
102  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
103  return false;
104  }
105  break;
106  }
107 
108 
109  return true;
110  }
111 
124  function _getCommands($a_obj_id = null)
125  {
126  $commands = array
127  (
128  array("permission" => "read", "cmd" => "view", "lang_var" => "show","default" => true),
129  array("permission" => "write", "cmd" => "editContent", "lang_var" => "edit_content"),
130  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
131  );
132  // #14866
135  if ($offlineMode == false) {
136  $commands[]=array("permission" => "read", "cmd" => "offlineModeStart", "lang_var" => "offline_mode");
137  }
138  else {
139  $commands[]=array("permission" => "read", "cmd" => "offlineModeStop", "lang_var" => "offline_mode");
140  $commands[0]=array("permission" => "read", "cmd" => "offlineModeView", "lang_var" => "show","default" => true);
141  }
142  }
143 
144  return $commands;
145  }
146 
147  //
148  // access relevant methods
149  //
150 
154  function _lookupOnline($a_id)
155  {
156  global $ilDB;
157 
158  $set = $ilDB->queryF('SELECT c_online FROM sahs_lm WHERE id = %s',
159  array('integer'), array($a_id));
160  $rec = $ilDB->fetchAssoc($set);
161 
162  return ilUtil::yn2tf($rec["c_online"]);
163  }
164 
168  static function _lookupEditable($a_obj_id)
169  {
170  global $ilDB;
171 
172  $set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
173  array('integer'), array($a_obj_id));
174  $rec = $ilDB->fetchAssoc($set);
175 
176  return $rec["editable"];
177  }
178 
179 
183  function _checkGoto($a_target)
184  {
185  global $ilAccess;
186 
187  $t_arr = explode("_", $a_target);
188 
189  if ($t_arr[0] != "sahs" || ((int) $t_arr[1]) <= 0)
190  {
191  return false;
192  }
193 
194  if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
195  {
196  return true;
197  }
198  return false;
199  }
200 
206  function _lookupDiskUsage($a_id)
207  {
208  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
209  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
210 
211  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
212 
213  }
214 
221  public static function _lookupUserCertificate($obj_id, $usr_id = 0)
222  {
223  global $ilUser;
224  $uid = ($usr_id) ? $usr_id : $ilUser->getId();
225 
226  $completed = false;
227  // check for certificates
228  include_once "./Services/Certificate/classes/class.ilCertificate.php";
230  {
231  $lpdata = false;
232  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
234  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
236  {
237  include_once "./Services/Tracking/classes/class.ilLPStatus.php";
238  $completed = ilLPStatus::_hasUserCompleted($obj_id, $uid);
239  $lpdata = true;
240  }
241  switch ($type)
242  {
243  case "scorm":
244  if (!$lpdata)
245  {
246  include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
247  $completed = ilObjSCORMLearningModule::_getCourseCompletionForUser($obj_id, $uid);
248  }
249  break;
250  case "scorm2004":
251  if (!$lpdata)
252  {
253  include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
255  }
256  break;
257  default:
258  break;
259  }
260  }
261  return $completed;
262  }
263 
272  static function _isOffline($a_obj_id)
273  {
274  return !self::_lookupOnline($a_obj_id);
275  }
276 
280  static function _lookupUserIsOfflineMode($a_obj_id)
281  {
282  global $ilDB,$ilUser;
283 
284  $user_id = $ilUser->getId();
285 
286  $set = $ilDB->queryF('SELECT offline_mode FROM sahs_user WHERE obj_id = %s AND user_id = %s',
287  array('integer','integer'),
288  array($a_obj_id, $user_id)
289  );
290  $rec = $ilDB->fetchAssoc($set);
291  if ($rec["offline_mode"] == "offline") return true;
292  return false;
293  }
294 
299  {
300  global $ilDB;
301 
302  $set = $ilDB->queryF('SELECT offline_mode FROM sahs_lm WHERE id = %s',
303  array('integer'), array($a_id));
304  $rec = $ilDB->fetchAssoc($set);
305 
306  return ilUtil::yn2tf($rec["offline_mode"]);
307  }
308 }
309 
310 ?>
static _getCourseCompletionForUser($a_id, $a_user)
Get the completion of a SCORM module for a given user.
const IL_NO_OBJECT_ACCESS
static _isOffline($a_obj_id)
Type-specific implementation of general status.
Interface for condition handling.
_lookupOfflineModeAvailable($a_id)
check wether learning module is online
static _lookupUserIsOfflineMode($a_obj_id)
Checks offlineMode and returns false if.
static checkCondition($a_trigger_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
static _enabledLearningProgress()
check wether learing progress is enabled or not
_lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id...
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
_lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
static _lookupEditable($a_obj_id)
Lookup editable.
static getConditionOperators()
Get possible conditions operaditors.
static dirsize($directory)
get size of a directory or a file.
static isObjectActive($a_obj_id)
_lookupOnline($a_id)
check wether learning module is online
_checkGoto($a_target)
check whether goto script will succeed
global $ilUser
Definition: imgupload.php:15
Class 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::checkAcce...
global $lng
Definition: privfeed.php:40
global $ilDB
static yn2tf($a_yn)
convert "y"/"n" to true/false
static getWebspaceDir($mode="filesystem")
get webspace directory
static _getCourseCompletionForUser($a_id, $a_user)
Get the completion of a SCORM module for a given user.
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
const LP_STATUS_FAILED_NUM
static _lookupUserCertificate($obj_id, $usr_id=0)
Checks whether a certificate exists for the active user or not.