7 include_once(
"./Services/Object/classes/class.ilObjectAccess.php");
8 require_once(
'./Services/WebAccessChecker/interfaces/interface.ilWACCheckingClass.php');
24 protected function checkAccessToObjectId($obj_id)
27 $ilAccess = $DIC[
'ilAccess'];
32 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
48 $re =
'/\/previews\/[\d\/]{0,}\/preview_([\d]{0,})\//uU';
51 preg_match($re, $ilWACPath->
getPath(), $matches);
53 return $this->checkAccessToObjectId($matches[1]);
85 "permission" =>
"read",
87 "lang_var" =>
"download",
91 "permission" =>
"write",
93 "lang_var" =>
"versions",
96 "permission" =>
"write",
98 "lang_var" =>
"settings",
110 $ilAccess = $DIC[
'ilAccess'];
112 $t_arr = explode(
"_", $a_target);
115 if (isset($t_arr[2]) && $t_arr[2] ==
"wsp") {
116 include_once
"Services/PersonalWorkspace/classes/class.ilSharedResourceGUI.php";
121 if ($t_arr[0] !=
"file" || ((
int) $t_arr[1]) <= 0) {
125 if ($ilAccess->checkAccess(
"visible",
"", $t_arr[1])
126 || $ilAccess->checkAccess(
"read",
"", $t_arr[1])
141 $ilDB = $DIC[
'ilDB'];
143 $q =
"SELECT * FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
144 $r =
$ilDB->query($q);
156 $ilDB = $DIC[
'ilDB'];
158 $q =
"SELECT version FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
159 $r =
$ilDB->query($q);
164 return $striped > 0 ? $striped : 1;
175 $ilDB = $DIC[
'ilDB'];
177 $q =
"SELECT file_size FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
178 $r =
$ilDB->query($q);
181 $size = $row->file_size;
195 $ilDB = $DIC[
'ilDB'];
197 $q =
"SELECT * FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
198 $r =
$ilDB->query($q);
201 require_once(
'Modules/File/classes/class.ilFSStorageFile.php');
203 $file = $fss->getAbsolutePath() .
'/' . $row->file_name;
205 if (@!is_file($file)) {
207 $file = $fss->getAbsolutePath() .
'/' . $version_subdir .
'/' . $row->file_name;
210 if (is_file($file)) {
211 $size = filesize($file);
224 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
227 $ilDB = $DIC[
'ilDB'];
230 $q =
"SELECT * FROM object_data WHERE obj_id = " .
$ilDB->quote($a_id,
'integer');
231 $r =
$ilDB->query($q);
233 require_once
'Modules/File/classes/class.ilObjFile.php';
235 return self::_getFileExtension($row->title);
246 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
248 $dir = $fileStorage->getAbsolutePath();
260 if (self::$_inlineFileExtensionsArray
263 $settings =
new ilSetting(
'file_access');
264 self::$_inlineFileExtensionsArray = preg_split(
'/ /', $settings->get(
'inline_file_extensions'), -1,
265 PREG_SPLIT_NO_EMPTY);
267 $extension = self::_getFileExtension($a_file_name);
269 return in_array($extension, self::$_inlineFileExtensionsArray);
287 if (preg_match(
'/\.([a-z0-9]+)\z/i', $a_file_name, $matches) == 1) {
288 return strtolower($matches[1]);
304 return substr($a_file_name, 0, 1) ==
'.' || substr($a_file_name, -1, 1) ==
'~' 305 || substr($a_file_name, 0, 2) ==
'~$' 306 || $a_file_name ==
'Thumbs.db';
335 $filenameWithoutExtension = $a_file_name;
338 if ($a_handle_extension) {
341 if (strlen($extension) > 0) {
342 $extension =
'.' . $extension;
343 $filenameWithoutExtension = substr($a_file_name, 0, -strlen($extension));
351 $nthCopyRegex = preg_replace(
'/([\^$.\[\]|()?*+{}])/',
'\\\\${1}',
' ' 352 .
$lng->txt(
'copy_n_of_suffix'));
353 $nthCopyRegex =
'/' . preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $nthCopyRegex) .
'$/';
357 if (preg_match($nthCopyRegex, $filenameWithoutExtension, $matches)) {
359 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen($matches[0]));
360 if ($nth_copy == null) {
361 $nth_copy = $matches[1] + 1;
364 if (substr($filenameWithoutExtension, -strlen(
' ' .
$lng->txt(
'copy_of_suffix')))
365 ==
' ' .
$lng->txt(
'copy_of_suffix')
368 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen(
' ' 369 .
$lng->txt(
'copy_of_suffix')));
370 if ($nth_copy == null) {
375 $filenameWithoutCopy = $filenameWithoutExtension;
376 if ($nth_copy == null) {
385 $newFilename = $filenameWithoutCopy . sprintf(
' ' 386 .
$lng->txt(
'copy_n_of_suffix'), $nth_copy)
390 $newFilename = $filenameWithoutCopy .
' ' .
$lng->txt(
'copy_of_suffix') . $extension;
410 public static function _preloadData($a_obj_ids, $a_ref_ids) :
void 414 $DIC->language()->loadLanguageModule(
'file');
419 self::$preload_list_gui_data = array();
421 $set = $DIC->database()->query(
"SELECT obj_id,max(hdate) latest" .
" FROM history" 422 .
" WHERE obj_type = " . $DIC->database()->quote(
"file",
"text") .
" AND " 423 . $DIC->database()->in(
"obj_id", $a_obj_ids,
"",
"integer") .
" GROUP BY obj_id");
424 while ($row = $DIC->database()->fetchAssoc($set)) {
425 self::$preload_list_gui_data[$row[
"obj_id"]][
"date"] = $row[
"latest"];
428 $set = $DIC->database()->query(
"SELECT file_size, version, file_id, page_count, rid" .
" FROM file_data" .
" WHERE " 429 . $DIC->database()->in(
"file_id", $a_obj_ids,
"",
"integer"));
430 while ($row = $DIC->database()->fetchAssoc($set)) {
431 self::$preload_list_gui_data[$row[
"file_id"]][
"size"] = $row[
"file_size"];
432 self::$preload_list_gui_data[$row[
"file_id"]][
"version"] = $row[
"version"];
433 self::$preload_list_gui_data[$row[
"file_id"]][
"page_count"] = $row[
"page_count"];
434 self::$preload_list_gui_data[$row[
"file_id"]][
"rid"] = $row[
"rid"];
437 $res = $DIC->database()->query(
"SELECT rid, file_id FROM file_data WHERE rid IS NOT NULL AND rid !='' AND " . $DIC->database()->in(
'file_id',
441 while ($row = $DIC->database()->fetchObject(
$res)) {
442 $rids[$row->file_id] = $row->rid;
444 $DIC->resourceStorage()->preload($rids);
446 foreach ($rids as $file_id => $rid) {
447 if ($id = $DIC->resourceStorage()->manage()->find($rid)) {
448 $max = $DIC->resourceStorage()->manage()->getResource($id)->getCurrentRevision();
449 self::$preload_list_gui_data[$file_id][
"version"] = $max->getVersionNumber();
450 self::$preload_list_gui_data[$file_id][
"size"] = $max->getInformation()->getSize();
451 self::$preload_list_gui_data[$file_id][
"date"] = $max->getInformation()->getCreationDate()->format(DATE_ATOM);
465 if (isset(self::$preload_list_gui_data[$a_obj_id])) {
466 return self::$preload_list_gui_data[$a_obj_id];
static $_inlineFileExtensionsArray
Contains an array of extensions separated by space.
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id...
static _getPermanentDownloadLink($ref_id)
Gets the permanent download link for the file.
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.
static _appendNumberOfCopyToFilename($a_file_name, $nth_copy=null, $a_handle_extension=false)
Appends the text " - Copy" to a filename in the language of the current user.
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
Access class for file objects.
static _getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...
static _getAllReferences($a_id)
get all reference ids of object
static _lookupFileSize($a_id)
foreach($_POST as $key=> $value) $res
static $preload_list_gui_data
static _preloadData($a_obj_ids, $a_ref_ids)
Preload data.
static hasAccess($a_node_id, $a_is_portfolio=false)
static _lookupFileSizeFromFilesystem($a_id)
Looks up the file size by retrieving it from the filesystem.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _lookupSuffix($a_id)
lookup suffix
Class ilWACCheckingClass.
static _lookupFileData($a_id)
looks up the file_data for the file object with the specified object id as an associative array...
static dirsize($directory)
get size of a directory or a file.
static _checkGoto($a_target)
check whether goto script will succeed
static _lookupVersion($a_id)
lookup version
canBeDelivered(ilWACPath $ilWACPath)
static getListGUIData($a_obj_id)