ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
17 {
30  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
31  {
32  global $ilUser, $lng, $rbacsystem, $ilAccess;
33 
34  if ($a_user_id == "")
35  {
36  $a_user_id = $ilUser->getId();
37  }
38 
39  switch ($a_cmd)
40  {
41  case "view":
42 
44  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
45  {
46  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
47  return false;
48  }
49  break;
50  }
51 
52  switch ($a_permission)
53  {
54  case "visible":
56  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
57  {
58  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
59  return false;
60  }
61  break;
62  }
63 
64 
65  return true;
66  }
67 
80  function _getCommands($a_obj_id = null)
81  {
82  $commands = array
83  (
84  array("permission" => "read", "cmd" => "view", "lang_var" => "show","default" => true),
85  array("permission" => "write", "cmd" => "editContent", "lang_var" => "edit_content"),
86  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
87  );
88  // #14866
91  if ($offlineMode == false) {
92  $commands[]=array("permission" => "read", "cmd" => "offlineModeStart", "lang_var" => "offline_mode");
93  }
94  else {
95  $commands[]=array("permission" => "read", "cmd" => "offlineModeStop", "lang_var" => "offline_mode");
96  $commands[0]=array("permission" => "read", "cmd" => "offlineModeView", "lang_var" => "show","default" => true);
97  }
98  }
99 
100  return $commands;
101  }
102 
103  //
104  // access relevant methods
105  //
106 
110  function _lookupOnline($a_id)
111  {
112  global $ilDB;
113 
114  $set = $ilDB->queryF('SELECT c_online FROM sahs_lm WHERE id = %s',
115  array('integer'), array($a_id));
116  $rec = $ilDB->fetchAssoc($set);
117 
118  return ilUtil::yn2tf($rec["c_online"]);
119  }
120 
124  static function _lookupEditable($a_obj_id)
125  {
126  global $ilDB;
127 
128  $set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
129  array('integer'), array($a_obj_id));
130  $rec = $ilDB->fetchAssoc($set);
131 
132  return $rec["editable"];
133  }
134 
135 
139  function _checkGoto($a_target)
140  {
141  global $ilAccess;
142 
143  $t_arr = explode("_", $a_target);
144 
145  if ($t_arr[0] != "sahs" || ((int) $t_arr[1]) <= 0)
146  {
147  return false;
148  }
149 
150  if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
151  {
152  return true;
153  }
154  return false;
155  }
156 
162  function _lookupDiskUsage($a_id)
163  {
164  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
165  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
166 
167  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
168 
169  }
170 
177  public static function _lookupUserCertificate($obj_id, $usr_id = 0)
178  {
179  global $ilUser;
180  $uid = ($usr_id) ? $usr_id : $ilUser->getId();
181 
182  $completed = false;
183  // check for certificates
184  include_once "./Services/Certificate/classes/class.ilCertificate.php";
186  {
187  $lpdata = false;
188  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
190  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
192  {
193  include_once "./Services/Tracking/classes/class.ilLPStatus.php";
194  $completed = ilLPStatus::_hasUserCompleted($obj_id, $uid);
195  $lpdata = true;
196  }
197  switch ($type)
198  {
199  case "scorm":
200  if (!$lpdata)
201  {
202  include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
203  $completed = ilObjSCORMLearningModule::_getCourseCompletionForUser($obj_id, $uid);
204  }
205  break;
206  case "scorm2004":
207  if (!$lpdata)
208  {
209  include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
211  }
212  break;
213  default:
214  break;
215  }
216  }
217  return $completed;
218  }
219 
228  static function _isOffline($a_obj_id)
229  {
230  return !self::_lookupOnline($a_obj_id);
231  }
232 
236  static function _lookupUserIsOfflineMode($a_obj_id)
237  {
238  global $ilDB,$ilUser;
239 
240  $user_id = $ilUser->getId();
241 
242  $set = $ilDB->queryF('SELECT offline_mode FROM sahs_user WHERE obj_id = %s AND user_id = %s',
243  array('integer','integer'),
244  array($a_obj_id, $user_id)
245  );
246  $rec = $ilDB->fetchAssoc($set);
247  if ($rec["offline_mode"] == "offline") return true;
248  return false;
249  }
250 
255  {
256  global $ilDB;
257 
258  $set = $ilDB->queryF('SELECT offline_mode FROM sahs_lm WHERE id = %s',
259  array('integer'), array($a_id));
260  $rec = $ilDB->fetchAssoc($set);
261 
262  return ilUtil::yn2tf($rec["offline_mode"]);
263  }
264 }
265 
266 ?>