ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjFileBasedLMAccess Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct ()
 
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _determineStartUrl (int $a_id)
 
static locateStartFileInArchive (\ZipArchive $archive, string $start_file)
 Returns the stored start file if the archive contains it, otherwise falls back to index.html and index.htm in the root of the archive, as for learning modules which have not been migrated yet. More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _lookupDiskUsage (int $a_id)
 Returns the number of bytes used on the harddisk by the learning module with the specified object id. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 
static isInfoEnabled (int $obj_id)
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 

Static Public Attributes

static array $startfile = []
 

Protected Attributes

ilObjUser $user
 
ilLanguage $lng
 
ilRbacSystem $rbacsystem
 
ilAccessHandler $access
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilObjFileBasedLMAccess::__construct ( )

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

32 {
33 global $DIC;
34
35 $this->user = $DIC->user();
36 $this->lng = $DIC->language();
37 $this->rbacsystem = $DIC->rbac()->system();
38 $this->access = $DIC->access();
39 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _checkAccess()

ilObjFileBasedLMAccess::_checkAccess ( string  $cmd,
string  $permission,
int  $ref_id,
int  $obj_id,
?int  $user_id = null 
)

Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)

Please do not check any preconditions handled by ilConditionHandler here. Also don't do any RBAC checks.

Reimplemented from ilObjectAccess.

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

41 : bool
42 {
44 $ilAccess = $this->access;
45
46 switch ($permission) {
47 case "read":
48
49 if (self::_determineStartUrl($obj_id) === "") {
51 return false;
52 }
53 break;
54 }
55 return true;
56 }
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
addInfoItem(string $a_type, string $a_text, string $a_data="")
add an info item to current info object

References $access, $lng, ilRBACAccessHandler\addInfoItem(), ilAccessInfo\IL_NO_OBJECT_ACCESS, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjFileBasedLMAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

152 : bool
153 {
154 global $DIC;
155
156 $ilAccess = $DIC->access();
157
158 $t_arr = explode("_", $target);
159
160 if ($t_arr[0] !== "htlm" || ((int) $t_arr[1]) <= 0) {
161 return false;
162 }
163
164 if ($ilAccess->checkAccess("visible", "", $t_arr[1]) ||
165 $ilAccess->checkAccess("read", "", $t_arr[1])) {
166 return true;
167 }
168 return false;
169 }

References $DIC, and ILIAS\Scripts\PHPStan\$target.

◆ _determineStartUrl()

static ilObjFileBasedLMAccess::_determineStartUrl ( int  $a_id)
static

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

74 : string
75 {
76 global $DIC;
77
78 static $startfile = [];
79 if (isset($startfile[$a_id])) {
80 return $startfile[$a_id];
81 }
82
83 $ilDB = $DIC->database();
84
85 $q = "SELECT startfile, rid FROM file_based_lm WHERE id = " . $ilDB->quote($a_id, "integer");
86 $set = $ilDB->query($q);
87 $rec = $ilDB->fetchAssoc($set);
88 $start_file = $rec["startfile"] ?? '';
89
90 // Migrated learning module
91 if (!empty($rec['rid'])) {
92 // check if the file is available in the container
93 $rid = $DIC->resourceStorage()->manageContainer()->find($rec['rid']);
94 if (!$rid) {
95 return $startfile[$a_id] = "";
96 }
97 // Locate the single stored path. Unzip::getFiles() yields nothing when the
98 // archive exceeds the decompression-bomb limits, which hides a valid start file.
99 $stream = $DIC->resourceStorage()->consume()->stream($rid)->getStream();
100 $uri = $stream->getMetadata()['uri'] ?? '';
101 $archive = new \ZipArchive();
102 $found = "";
103 if (is_string($uri) && $uri !== '' && $archive->open($uri, \ZipArchive::RDONLY) === true) {
104 $found = self::locateStartFileInArchive($archive, $start_file);
105 $archive->close();
106 }
107 return $startfile[$a_id] = $found;
108 }
109
110 // Old learning module
111 $dir = realpath(__DIR__ . '/../../../../public/' . ilFileUtils::getWebspaceDir() . "/lm_data/lm_" . $a_id);
112
113 if (($start_file !== "") && (is_file($dir . "/" . $start_file))) {
114 return $startfile[$a_id] = str_replace(
115 realpath(__DIR__ . '/../../../../public/'),
116 "",
117 $dir . "/" . $start_file
118 );
119 }
120
121 if (is_file($dir . "/index.html")) {
122 return $startfile[$a_id] = str_replace(
123 realpath(__DIR__ . '/../../../../public/'),
124 "",
125 $dir . "/index.html"
126 );
127 }
128
129 if (is_file($dir . "/index.htm")) {
130 return $startfile[$a_id] = str_replace(realpath(__DIR__ . '/../../../../public/'), "", $dir . "/index.htm");
131 }
132
133 return $startfile[$a_id] = "";
134 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static locateStartFileInArchive(\ZipArchive $archive, string $start_file)
Returns the stored start file if the archive contains it, otherwise falls back to index....

References $DIC, $ilDB, $startfile, ilFileUtils\getWebspaceDir(), and locateStartFileInArchive().

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

+ 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"), );

Returns
array{permission?:string, cmd?:string, lang_var?:string, default?:bool}[]

Reimplemented from ilObjectAccess.

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

58 : array
59 {
60 return [
61 [
62 "permission" => "read", "cmd" => "view", "lang_var" => "show",
63 "default" => true
64 ],
65 ["permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"],
66 ["permission" => "write", "cmd" => "properties", "lang_var" => "settings"]
67 ];
68 }

Referenced by ilObjFileBasedLMListGUI\init().

+ Here is the caller graph for this function:

◆ _lookupDiskUsage()

static ilObjFileBasedLMAccess::_lookupDiskUsage ( int  $a_id)
static

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

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

175 : int
176 {
177 $lm_data_dir = ilFileUtils::getWebspaceDir('filesystem') . "/lm_data";
178 $lm_dir = $lm_data_dir . DIRECTORY_SEPARATOR . "lm_" . $a_id;
179
180 return file_exists($lm_dir) ? ilFileUtils::dirsize($lm_dir) : 0;
181 }
static dirsize(string $directory)
get size of a directory or a file.

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

+ Here is the call graph for this function:

◆ _preloadData()

static ilObjFileBasedLMAccess::_preloadData ( array  $obj_ids,
array  $ref_ids 
)
static

Preload data.

Reimplemented from ilObjectAccess.

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

183 : void
184 {
185 global $DIC;
186
187 $ilDB = $DIC->database();
188
189 $q = "SELECT id, startfile FROM file_based_lm WHERE " .
190 $ilDB->in("id", $obj_ids, false, "integer");
191
192 $lm_set = $ilDB->query($q);
193 while ($rec = $ilDB->fetchAssoc($lm_set)) {
194 self::$startfile[$rec["id"]] = $rec["startfile"] . "";
195 }
196 }
$lm_set

References $DIC, $ilDB, and $lm_set.

◆ isInfoEnabled()

static ilObjFileBasedLMAccess::isInfoEnabled ( int  $obj_id)
static

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

198 : bool
199 {
201 $obj_id,
203 true
204 );
205 }
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)

References ilContainer\_lookupContainerSetting(), and ilObjectServiceSettingsGUI\INFO_TAB_VISIBILITY.

Referenced by ilObjFileBasedLMListGUI\getInfoScreenStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ locateStartFileInArchive()

static ilObjFileBasedLMAccess::locateStartFileInArchive ( \ZipArchive  $archive,
string  $start_file 
)
static

Returns the stored start file if the archive contains it, otherwise falls back to index.html and index.htm in the root of the archive, as for learning modules which have not been migrated yet.

Many learning modules have no start file stored at all.

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

141 : string
142 {
143 $candidates = array_filter([$start_file, 'index.html', 'index.htm'], static fn(string $c): bool => $c !== '');
144 foreach ($candidates as $candidate) {
145 if ($archive->locateName($candidate) !== false) {
146 return $candidate;
147 }
148 }
149 return "";
150 }

References Vendor\Package\$c.

Referenced by _determineStartUrl(), and StartFileFallbackTest\testLocateStartFileInArchive().

+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilObjFileBasedLMAccess::$access
protected

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

Referenced by _checkAccess().

◆ $lng

ilLanguage ilObjFileBasedLMAccess::$lng
protected

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

Referenced by _checkAccess().

◆ $rbacsystem

ilRbacSystem ilObjFileBasedLMAccess::$rbacsystem
protected

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

◆ $startfile

array ilObjFileBasedLMAccess::$startfile = []
static

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

Referenced by _determineStartUrl().

◆ $user

ilObjUser ilObjFileBasedLMAccess::$user
protected

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


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