ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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/Conditions/interfaces/interface.ilConditionHandling.php';
7 
18 {
19 
23  public static function getConditionOperators()
24  {
25  include_once './Services/Conditions/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 
46  include_once './Services/Tracking/classes/class.ilLPStatus.php';
47  return ilLPStatus::_lookupStatus($a_trigger_obj_id, $a_usr_id) == ilLPStatus::LP_STATUS_FAILED_NUM;
48  break;
49 
51  default:
52  include_once './Services/Tracking/classes/class.ilLPStatus.php';
53  return ilLPStatus::_hasUserCompleted($a_trigger_obj_id, $a_usr_id);
54 
55  }
56  return true;
57  }
58 
59 
60 
73  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "") //UK weg?
74  {
75  global $DIC;
76  $ilUser = $DIC['ilUser'];
77  $lng = $DIC['lng'];
78  $rbacsystem = $DIC['rbacsystem'];
79  $ilAccess = $DIC['ilAccess'];
80 
81  if ($a_user_id == "") {
82  $a_user_id = $ilUser->getId();
83  }
84 
85  // switch ($a_cmd)
86  // {
87  // case "view":
88 
89  // if(!ilObjSAHSLearningModuleAccess::_lookupOnline($a_obj_id)
90  // && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
91  // {
92  // $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
93  // return false;
94  // }
95  // break;
96  // }
97 
98  // switch ($a_permission)
99  // {
100  // case "visible":
101  // if (!ilObjSAHSLearningModuleAccess::_lookupOnline($a_obj_id) &&
102  // (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
103  // {
104  // $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
105  // return false;
106  // }
107  // break;
108  // }
109 
110 
111  return true;
112  }
113 
126  public static function _getCommands($a_obj_id = null)
127  {
128  $commands = array(
129  array("permission" => "read", "cmd" => "view", "lang_var" => "show","default" => true),
130  array("permission" => "write", "cmd" => "editContent", "lang_var" => "edit_content"),
131  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
132  );
133  // #14866
136  if ($offlineMode == false) {
137  $commands[] = array("permission" => "read", "cmd" => "offlineModeStart", "lang_var" => "offline_mode");
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 
151 
155  public static function _lookupEditable($a_obj_id)
156  {
157  global $DIC;
158  $ilDB = $DIC['ilDB'];
159 
160  $set = $ilDB->queryF(
161  'SELECT * FROM sahs_lm WHERE id = %s',
162  array('integer'),
163  array($a_obj_id)
164  );
165  $rec = $ilDB->fetchAssoc($set);
166 
167  return $rec["editable"];
168  }
169 
170 
174  public static function _checkGoto($a_target)
175  {
176  global $DIC;
177  $ilAccess = $DIC['ilAccess'];
178 
179  $t_arr = explode("_", $a_target);
180 
181  if ($t_arr[0] != "sahs" || ((int) $t_arr[1]) <= 0) {
182  return false;
183  }
184 
185  if ($ilAccess->checkAccess("visible", "", $t_arr[1]) || $ilAccess->checkAccess("read", "", $t_arr[1])) {
186  return true;
187  }
188  return false;
189  }
190 
196  public static function _lookupDiskUsage($a_id)
197  {
198  $lm_data_dir = ilUtil::getWebspaceDir('filesystem') . "/lm_data";
199  $lm_dir = $lm_data_dir . DIRECTORY_SEPARATOR . "lm_" . $a_id;
200 
201  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
202  }
203 
204 
208  public static function _lookupUserIsOfflineMode($a_obj_id)
209  {
210  global $DIC;
211  $ilDB = $DIC['ilDB'];
212  $ilUser = $DIC['ilUser'];
213 
214  $user_id = $ilUser->getId();
215 
216  $set = $ilDB->queryF(
217  'SELECT offline_mode FROM sahs_user WHERE obj_id = %s AND user_id = %s',
218  array('integer','integer'),
219  array($a_obj_id, $user_id)
220  );
221  $rec = $ilDB->fetchAssoc($set);
222  if ($rec["offline_mode"] == "offline") {
223  return true;
224  }
225  return false;
226  }
227 
231  public static function _lookupOfflineModeAvailable($a_id)
232  {
233  global $DIC;
234  $ilDB = $DIC['ilDB'];
235 
236  $set = $ilDB->queryF(
237  'SELECT offline_mode FROM sahs_lm WHERE id = %s',
238  array('integer'),
239  array($a_id)
240  );
241  $rec = $ilDB->fetchAssoc($set);
242 
243  return ilUtil::yn2tf($rec["offline_mode"]);
244  }
245 }
global $DIC
Definition: saml.php:7
Interface for condition handling.
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id...
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 _lookupOfflineModeAvailable($a_id)
check wether learning module is online
$lng
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
$ilUser
Definition: imgupload.php:18
static _lookupEditable($a_obj_id)
Lookup editable.
static getConditionOperators()
Get possible conditions operaditors.
static dirsize($directory)
get size of a directory or a file.
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 $ilDB
static _getCommands($a_obj_id=null)
get commands
static _checkGoto($a_target)
check whether goto script will succeed
static yn2tf($a_yn)
convert "y"/"n" to true/false
static getWebspaceDir($mode="filesystem")
get webspace directory
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
const LP_STATUS_FAILED_NUM