ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjSAHSLearningModuleAccess.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
33  public static function getConditionOperators(): array
34  {
35  return array(
38  );
39  }
40 
41  public static function checkCondition(
42  int $a_trigger_obj_id,
43  string $a_operator,
44  string $a_value,
45  int $a_usr_id
46  ): bool {
47  switch ($a_operator) {
49  return ilLPStatus::_lookupStatus($a_trigger_obj_id, $a_usr_id) == ilLPStatus::LP_STATUS_FAILED_NUM;
50  break;
51 
53  default:
54  return ilLPStatus::_hasUserCompleted($a_trigger_obj_id, $a_usr_id);
55  }
56  }
57 
69  public static function _getCommands(?int $a_obj_id = null): array
70  {
71  $commands = array(
72  array("permission" => "read", "cmd" => "view", "lang_var" => "show", "default" => true),
73  // array("permission" => "write", "cmd" => "editContent", "lang_var" => "edit_content"),
74  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
75  );
76  return $commands;
77  }
78 
82  public static function _checkGoto(string $target): bool
83  {
84  global $DIC;
85  $ilAccess = $DIC->access();
86 
87  $t_arr = explode("_", $target);
88 
89  if ($t_arr[0] !== "sahs" || ((int) $t_arr[1]) <= 0) {
90  return false;
91  }
92 
93  if ($ilAccess->checkAccess("visible", "", (int) $t_arr[1]) || $ilAccess->checkAccess("read", "", (int) $t_arr[1])) {
94  return true;
95  }
96  return false;
97  }
98 
99 
105  public static function _lookupDiskUsage(int $a_id): int
106  {
107  $lm_data_dir = ilFileUtils::getWebspaceDir('filesystem') . "/lm_data";
108  $lm_dir = $lm_data_dir . DIRECTORY_SEPARATOR . "lm_" . $a_id;
109 
110  return file_exists($lm_dir) ? ilFileUtils::dirsize($lm_dir) : 0;
111  }
112 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
Interface for condition handling.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static dirsize(string $directory)
get size of a directory or a file.
global $DIC
Definition: shib_login.php:26
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
static getConditionOperators()
Get possible conditions operaditors.
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
check condition for a specific user and object
static _lookupDiskUsage(int $a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id...
static _checkGoto(string $target)
check whether goto script will succeed
static _getCommands(?int $a_obj_id=null)
get commands this method returns an array of all possible commands/permission combinations example: $...
const LP_STATUS_FAILED_NUM