ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjFileBasedLMAccess Class Reference

Class ilFileBasedLMAccess. More...

+ Inheritance diagram for ilObjFileBasedLMAccess:
+ Collaboration diagram for ilObjFileBasedLMAccess:

Public Member Functions

 __construct ()
 Constructor. More...
 
 _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::checkAccess) More...
 
- Public Member Functions inherited from 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::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _lookupOnline ($a_id)
 check wether learning module is online More...
 
static _determineStartUrl ($a_id)
 check wether learning module is online More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _lookupDiskUsage ($a_id)
 Returns the number of bytes used on the harddisk by the learning module with the specified object id. More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Static Public Attributes

static $online
 
static $startfile
 

Protected Attributes

 $user
 
 $lng
 
 $rbacsystem
 
 $access
 

Detailed Description

Class ilFileBasedLMAccess.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 16 of file class.ilObjFileBasedLMAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjFileBasedLMAccess::__construct ( )

Constructor.

Definition at line 42 of file class.ilObjFileBasedLMAccess.php.

References $DIC, and user().

43  {
44  global $DIC;
45 
46  $this->user = $DIC->user();
47  $this->lng = $DIC->language();
48  $this->rbacsystem = $DIC->rbac()->system();
49  $this->access = $DIC->access();
50  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ _checkAccess()

ilObjFileBasedLMAccess::_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::checkAccess)

Parameters
string$a_cmdcommand (not permission!)
string$a_permissionpermission
int$a_ref_idreference id
int$a_obj_idobject id
int$a_user_iduser id (if not provided, current user is taken)
Returns
boolean true, if everything is ok

Definition at line 67 of file class.ilObjFileBasedLMAccess.php.

References $access, $ilUser, $lng, $rbacsystem, $user, _determineStartUrl(), _lookupOnline(), and IL_NO_OBJECT_ACCESS.

68  {
70  $lng = $this->lng;
72  $ilAccess = $this->access;
73 
74  if ($a_user_id == "") {
75  $a_user_id = $ilUser->getId();
76  }
77 
78  switch ($a_permission) {
79  case "visible":
80  if (!ilObjFileBasedLMAccess::_lookupOnline($a_obj_id) &&
81  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
82  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
83  return false;
84  }
85  break;
86 
87  case "read":
88 
90  && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) ||
92  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
93  return false;
94  }
95  break;
96  }
97 
98 
99  return true;
100  }
const IL_NO_OBJECT_ACCESS
$ilUser
Definition: imgupload.php:18
static _lookupOnline($a_id)
check wether learning module is online
static _determineStartUrl($a_id)
check wether learning module is online
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjFileBasedLMAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

Definition at line 187 of file class.ilObjFileBasedLMAccess.php.

References $DIC.

188  {
189  global $DIC;
190 
191  $ilAccess = $DIC->access();
192 
193  $t_arr = explode("_", $a_target);
194 
195  if ($t_arr[0] != "htlm" || ((int) $t_arr[1]) <= 0) {
196  return false;
197  }
198 
199  if ($ilAccess->checkAccess("visible", "", $t_arr[1]) ||
200  $ilAccess->checkAccess("read", "", $t_arr[1])) {
201  return true;
202  }
203  return false;
204  }
global $DIC
Definition: saml.php:7

◆ _determineStartUrl()

static ilObjFileBasedLMAccess::_determineStartUrl (   $a_id)
static

check wether learning module is online

Definition at line 154 of file class.ilObjFileBasedLMAccess.php.

References $DIC, $ilDB, and ilUtil\getWebspaceDir().

Referenced by _checkAccess(), ilObjFileBasedLMGUI\executeCommand(), ilObjFileBasedLMListGUI\getProperties(), ilObjFileBasedLMGUI\getSettingsFormValues(), ilObjFileBasedLMGUI\getTabs(), ilObjFileBasedLMGUI\initSettingsForm(), and ilObjFileBasedLMGUI\showLearningModule().

155  {
156  global $DIC;
157 
158  $ilDB = $DIC->database();
159 
160  if (isset(self::$startfile[$a_id])) {
161  $start_file = self::$startfile[$a_id];
162  } else {
163  $q = "SELECT startfile FROM file_based_lm WHERE id = " . $ilDB->quote($a_id, "integer");
164  $set = $ilDB->query($q);
165  $rec = $ilDB->fetchAssoc($set);
166  $start_file = $rec["startfile"];
167  self::$startfile[$a_id] = $start_file . "";
168  }
169 
170  $dir = ilUtil::getWebspaceDir() . "/lm_data/lm_" . $a_id;
171 
172  if (($start_file != "") &&
173  (@is_file($dir . "/" . $start_file))) {
174  return "./" . $dir . "/" . $start_file;
175  } elseif (@is_file($dir . "/index.html")) {
176  return "./" . $dir . "/index.html";
177  } elseif (@is_file($dir . "/index.htm")) {
178  return "./" . $dir . "/index.htm";
179  }
180 
181  return "";
182  }
global $DIC
Definition: saml.php:7
global $ilDB
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getCommands()

static ilObjFileBasedLMAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Definition at line 114 of file class.ilObjFileBasedLMAccess.php.

References array.

Referenced by ilObjFileBasedLMListGUI\init().

115  {
116  $commands = array(
117  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
118  "default" => true),
119  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
120  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
121  );
122 
123  return $commands;
124  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _isOffline()

static ilObjFileBasedLMAccess::_isOffline (   $a_obj_id)
static

Type-specific implementation of general status.

Used in ListGUI and Learning Progress

Parameters
int$a_obj_id
Returns
bool

Definition at line 227 of file class.ilObjFileBasedLMAccess.php.

Referenced by ilObjFileBasedLMListGUI\getProperties().

228  {
229  return !self::_lookupOnline($a_obj_id);
230  }
+ Here is the caller graph for this function:

◆ _lookupDiskUsage()

static ilObjFileBasedLMAccess::_lookupDiskUsage (   $a_id)
static

Returns the number of bytes used on the harddisk by the learning module with the specified object id.

Parameters
intobject id of a file object.

Definition at line 211 of file class.ilObjFileBasedLMAccess.php.

References ilUtil\dirsize(), and ilUtil\getWebspaceDir().

Referenced by ilObjFileBasedLM\getDiskUsage().

212  {
213  $lm_data_dir = ilUtil::getWebspaceDir('filesystem') . "/lm_data";
214  $lm_dir = $lm_data_dir . DIRECTORY_SEPARATOR . "lm_" . $a_id;
215 
216  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
217  }
static dirsize($directory)
get size of a directory or a file.
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjFileBasedLMAccess::_lookupOnline (   $a_id)
static

check wether learning module is online

Definition at line 133 of file class.ilObjFileBasedLMAccess.php.

References $DIC, $ilDB, and ilUtil\yn2tf().

Referenced by _checkAccess().

134  {
135  global $DIC;
136 
137  $ilDB = $DIC->database();
138 
139  if (isset(self::$online[$a_id])) {
140  return self::$online[$a_id];
141  }
142  $q = "SELECT is_online FROM file_based_lm WHERE id = " . $ilDB->quote($a_id, "integer");
143  $set = $ilDB->query($q);
144  $rec = $ilDB->fetchAssoc($set);
145 
146  self::$online[$a_id] = ilUtil::yn2tf($rec["is_online"]);
147 
148  return self::$online[$a_id];
149  }
global $DIC
Definition: saml.php:7
global $ilDB
static yn2tf($a_yn)
convert "y"/"n" to true/false
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _preloadData()

static ilObjFileBasedLMAccess::_preloadData (   $a_obj_ids,
  $a_ref_ids 
)
static

Preload data.

Parameters
array$a_obj_idsarray of object ids

Definition at line 237 of file class.ilObjFileBasedLMAccess.php.

References $DIC, $ilDB, $ilUser, $lm_set, and ilUtil\yn2tf().

238  {
239  global $DIC;
240 
241  $ilDB = $DIC->database();
242  $ilUser = $DIC->user();
243 
244  $q = "SELECT id, is_online, startfile FROM file_based_lm WHERE " .
245  $ilDB->in("id", $a_obj_ids, false, "integer");
246 
247  $lm_set = $ilDB->query($q);
248  while ($rec = $ilDB->fetchAssoc($lm_set)) {
249  self::$online[$rec["id"]] = ilUtil::yn2tf($rec["is_online"]);
250  self::$startfile[$rec["id"]] = $rec["startfile"] . "";
251  }
252  }
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$lm_set
global $ilDB
static yn2tf($a_yn)
convert "y"/"n" to true/false
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjFileBasedLMAccess::$access
protected

Definition at line 36 of file class.ilObjFileBasedLMAccess.php.

Referenced by _checkAccess().

◆ $lng

ilObjFileBasedLMAccess::$lng
protected

Definition at line 26 of file class.ilObjFileBasedLMAccess.php.

Referenced by _checkAccess().

◆ $online

ilObjFileBasedLMAccess::$online
static

Definition at line 52 of file class.ilObjFileBasedLMAccess.php.

◆ $rbacsystem

ilObjFileBasedLMAccess::$rbacsystem
protected

Definition at line 31 of file class.ilObjFileBasedLMAccess.php.

Referenced by _checkAccess().

◆ $startfile

ilObjFileBasedLMAccess::$startfile
static

Definition at line 53 of file class.ilObjFileBasedLMAccess.php.

◆ $user

ilObjFileBasedLMAccess::$user
protected

Definition at line 21 of file class.ilObjFileBasedLMAccess.php.

Referenced by _checkAccess().


The documentation for this class was generated from the following file: