ILIAS  release_4-3 Revision
 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()
81  {
82  $commands = array
83  (
84  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
85  "default" => true),
86  array("permission" => "write", "cmd" => "editContent", "lang_var" => "edit_content"),
87  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
88  );
89 
90  return $commands;
91  }
92 
93  //
94  // access relevant methods
95  //
96 
100  function _lookupOnline($a_id)
101  {
102  global $ilDB;
103 
104  $set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
105  array('integer'), array($a_id));
106  $rec = $ilDB->fetchAssoc($set);
107 
108  return ilUtil::yn2tf($rec["c_online"]);
109  }
110 
114  static function _lookupEditable($a_obj_id)
115  {
116  global $ilDB;
117 
118  $set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
119  array('integer'), array($a_obj_id));
120  $rec = $ilDB->fetchAssoc($set);
121 
122  return $rec["editable"];
123  }
124 
125 
129  function _checkGoto($a_target)
130  {
131  global $ilAccess;
132 
133  $t_arr = explode("_", $a_target);
134 
135  if ($t_arr[0] != "sahs" || ((int) $t_arr[1]) <= 0)
136  {
137  return false;
138  }
139 
140  if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
141  {
142  return true;
143  }
144  return false;
145  }
146 
152  function _lookupDiskUsage($a_id)
153  {
154  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
155  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
156 
157  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
158 
159  }
160 
167  public static function _lookupUserCertificate($obj_id, $usr_id = 0)
168  {
169  global $ilUser;
170  $uid = ($usr_id) ? $usr_id : $ilUser->getId();
171 
172  $completed = false;
173  // check for certificates
174  include_once "./Services/Certificate/classes/class.ilCertificate.php";
176  {
177  $lpdata = false;
178  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
180  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
182  {
183  include_once "./Services/Tracking/classes/class.ilLPStatus.php";
184  $completed = ilLPStatus::_lookupStatus($obj_id, $uid);
185  $completed = ($completed == LP_STATUS_COMPLETED_NUM);
186  $lpdata = true;
187  }
188  switch ($type)
189  {
190  case "scorm":
191  if (!$lpdata)
192  {
193  include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
194  $completed = ilObjSCORMLearningModule::_getCourseCompletionForUser($obj_id, $uid);
195  }
196  break;
197  case "scorm2004":
198  if (!$lpdata)
199  {
200  include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
202  }
203  break;
204  default:
205  break;
206  }
207  }
208  return $completed;
209  }
210 
219  static function _isOffline($a_obj_id)
220  {
221  return !self::_lookupOnline($a_obj_id);
222  }
223 }
224 
225 ?>