ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjFileBasedLMAccess Class Reference

Class ilFileBasedLMAccess. More...

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

Public Member Functions

 _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
 

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.

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 33 of file class.ilObjFileBasedLMAccess.php.

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

34  {
35  global $ilUser, $lng, $rbacsystem, $ilAccess;
36 
37  if ($a_user_id == "")
38  {
39  $a_user_id = $ilUser->getId();
40  }
41 
42  switch ($a_permission)
43  {
44  case "visible":
45  if (!ilObjFileBasedLMAccess::_lookupOnline($a_obj_id) &&
46  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
47  {
48  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
49  return false;
50  }
51  break;
52 
53  case "read":
54 
56  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id)) ||
58  {
59  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
60  return false;
61  }
62  break;
63  }
64 
65 
66  return true;
67  }
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
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjFileBasedLMAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

161  {
162  global $ilAccess;
163 
164  $t_arr = explode("_", $a_target);
165 
166  if ($t_arr[0] != "htlm" || ((int) $t_arr[1]) <= 0)
167  {
168  return false;
169  }
170 
171  if ($ilAccess->checkAccess("visible", "", $t_arr[1]) ||
172  $ilAccess->checkAccess("read", "", $t_arr[1]))
173  {
174  return true;
175  }
176  return false;
177  }

◆ _determineStartUrl()

static ilObjFileBasedLMAccess::_determineStartUrl (   $a_id)
static

check wether learning module is online

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

References $ilDB, and ilUtil\getWebspaceDir().

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

122  {
123  global $ilDB;
124 
125  if (isset(self::$startfile[$a_id]))
126  {
127  $start_file = self::$startfile[$a_id];
128  }
129  else
130  {
131  $q = "SELECT startfile FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
132  $set = $ilDB->query($q);
133  $rec = $ilDB->fetchAssoc($set);
134  $start_file = $rec["startfile"];
135  self::$startfile[$a_id] = $start_file."";
136  }
137 
138  $dir = ilUtil::getWebspaceDir()."/lm_data/lm_".$a_id;
139 
140  if (($start_file != "") &&
141  (@is_file($dir."/".$start_file)))
142  {
143  return "./".$dir."/".$start_file;
144  }
145  else if (@is_file($dir."/index.html"))
146  {
147  return "./".$dir."/index.html";
148  }
149  else if (@is_file($dir."/index.htm"))
150  {
151  return "./".$dir."/index.htm";
152  }
153 
154  return "";
155  }
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 81 of file class.ilObjFileBasedLMAccess.php.

References array.

Referenced by ilObjFileBasedLMListGUI\init().

82  {
83  $commands = array
84  (
85  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
86  "default" => true),
87  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
88  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
89  );
90 
91  return $commands;
92  }
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 200 of file class.ilObjFileBasedLMAccess.php.

Referenced by ilObjFileBasedLMListGUI\getProperties().

201  {
202  return !self::_lookupOnline($a_obj_id);
203  }
+ 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 184 of file class.ilObjFileBasedLMAccess.php.

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

Referenced by ilObjFileBasedLM\getDiskUsage().

185  {
186  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
187  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
188 
189  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
190  }
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 101 of file class.ilObjFileBasedLMAccess.php.

References $ilDB, and ilUtil\yn2tf().

Referenced by _checkAccess().

102  {
103  global $ilDB;
104 
105  if (isset(self::$online[$a_id]))
106  {
107  return self::$online[$a_id];
108  }
109  $q = "SELECT is_online FROM file_based_lm WHERE id = ".$ilDB->quote($a_id, "integer");
110  $set = $ilDB->query($q);
111  $rec = $ilDB->fetchAssoc($set);
112 
113  self::$online[$a_id] = ilUtil::yn2tf($rec["is_online"]);
114 
115  return self::$online[$a_id];
116  }
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 210 of file class.ilObjFileBasedLMAccess.php.

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

211  {
212  global $ilDB, $ilUser;
213 
214  $q = "SELECT id, is_online, startfile FROM file_based_lm WHERE ".
215  $ilDB->in("id", $a_obj_ids, false, "integer");
216 
217  $lm_set = $ilDB->query($q);
218  while ($rec = $ilDB->fetchAssoc($lm_set))
219  {
220  self::$online[$rec["id"]] = ilUtil::yn2tf($rec["is_online"]);
221  self::$startfile[$rec["id"]] = $rec["startfile"]."";
222  }
223  }
$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

◆ $online

ilObjFileBasedLMAccess::$online
static

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

◆ $startfile

ilObjFileBasedLMAccess::$startfile
static

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


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