5 include_once(
"./Services/Object/classes/class.ilObjectAccess.php");
6 require_once(
'./Services/WebAccessChecker/interfaces/interface.ilWACCheckingClass.php');
25 protected function checkAccessToObjectId($obj_id)
28 $ilAccess = $DIC[
'ilAccess'];
33 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
51 $re =
'/\/previews\/[\d\/]{0,}\/preview_([\d]{0,})\//uU';
54 preg_match($re, $ilWACPath->
getPath(), $matches);
56 return $this->checkAccessToObjectId($matches[1]);
93 "permission" =>
"read",
95 "lang_var" =>
"download",
99 "permission" =>
"write",
101 "lang_var" =>
"edit_content",
104 "permission" =>
"write",
106 "lang_var" =>
"versions",
119 $ilAccess = $DIC[
'ilAccess'];
121 $t_arr = explode(
"_", $a_target);
124 if (isset($t_arr[2]) && $t_arr[2] ==
"wsp") {
125 include_once
"Services/PersonalWorkspace/classes/class.ilSharedResourceGUI.php";
130 if ($t_arr[0] !=
"file" || ((
int) $t_arr[1]) <= 0) {
134 if ($ilAccess->checkAccess(
"visible",
"", $t_arr[1])
135 || $ilAccess->checkAccess(
"read",
"", $t_arr[1])
151 $ilDB = $DIC[
'ilDB'];
153 $q =
"SELECT * FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
167 $ilDB = $DIC[
'ilDB'];
169 $q =
"SELECT version FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
175 return $striped > 0 ? $striped : 1;
186 $ilDB = $DIC[
'ilDB'];
188 $q =
"SELECT file_size FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
207 $ilDB = $DIC[
'ilDB'];
209 $q =
"SELECT * FROM file_data WHERE file_id = " .
$ilDB->quote($a_id,
'integer');
213 require_once(
'Modules/File/classes/class.ilFSStorageFile.php');
215 $file = $fss->getAbsolutePath() .
'/' .
$row->file_name;
217 if (@!is_file(
$file)) {
219 $file = $fss->getAbsolutePath() .
'/' . $version_subdir .
'/' .
$row->file_name;
222 if (is_file(
$file)) {
237 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
240 $ilDB = $DIC[
'ilDB'];
243 $q =
"SELECT * FROM object_data WHERE obj_id = " .
$ilDB->quote($a_id,
'integer');
246 require_once
'Modules/File/classes/class.ilObjFile.php';
248 return self::_getFileExtension(
$row->title);
261 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
263 $dir = $fileStorage->getAbsolutePath();
276 if (self::$_inlineFileExtensionsArray
279 require_once
'Services/Administration/classes/class.ilSetting.php';
280 $settings =
new ilSetting(
'file_access');
281 self::$_inlineFileExtensionsArray = preg_split(
'/ /', $settings->get(
'inline_file_extensions'), -1, PREG_SPLIT_NO_EMPTY);
283 $extension = self::_getFileExtension($a_file_name);
285 return in_array($extension, self::$_inlineFileExtensionsArray);
303 if (preg_match(
'/\.([a-z0-9]+)\z/i', $a_file_name, $matches) == 1) {
304 return strtolower($matches[1]);
322 return substr($a_file_name, 0, 1) ==
'.' || substr($a_file_name, -1, 1) ==
'~' 323 || substr($a_file_name, 0, 2) ==
'~$' 324 || $a_file_name ==
'Thumbs.db';
361 $filenameWithoutExtension = $a_file_name;
364 if ($a_handle_extension) {
367 if (strlen($extension) > 0) {
368 $extension =
'.' . $extension;
369 $filenameWithoutExtension = substr($a_file_name, 0, -strlen($extension));
377 $nthCopyRegex = preg_replace(
'/([\^$.\[\]|()?*+{}])/',
'\\\\${1}',
' ' 378 .
$lng->txt(
'copy_n_of_suffix'));
379 $nthCopyRegex =
'/' . preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $nthCopyRegex) .
'$/';
383 if (preg_match($nthCopyRegex, $filenameWithoutExtension, $matches)) {
385 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen($matches[0]));
386 if ($nth_copy == null) {
387 $nth_copy = $matches[1] + 1;
390 if (substr($filenameWithoutExtension, -strlen(
' ' .
$lng->txt(
'copy_of_suffix')))
391 ==
' ' .
$lng->txt(
'copy_of_suffix')
394 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen(
' ' 395 .
$lng->txt(
'copy_of_suffix')));
396 if ($nth_copy == null) {
401 $filenameWithoutCopy = $filenameWithoutExtension;
402 if ($nth_copy == null) {
411 $newFilename = $filenameWithoutCopy . sprintf(
' ' 412 .
$lng->txt(
'copy_n_of_suffix'), $nth_copy)
416 $newFilename = $filenameWithoutCopy .
' ' .
$lng->txt(
'copy_of_suffix') . $extension;
444 self::$preload_list_gui_data =
array();
446 $set = $DIC->database()->query(
"SELECT obj_id,max(hdate) latest" .
" FROM history" 447 .
" WHERE obj_type = " . $DIC->database()->quote(
"file",
"text") .
" AND " 448 . $DIC->database()->in(
"obj_id", $a_obj_ids,
"",
"integer") .
" GROUP BY obj_id");
449 while (
$row = $DIC->database()->fetchAssoc($set)) {
450 self::$preload_list_gui_data[
$row[
"obj_id"]][
"date"] = $row[
"latest"];
453 $set = $DIC->database()->query(
"SELECT file_size, version, file_id, page_count" .
" FROM file_data" .
" WHERE " 454 . $DIC->database()->in(
"file_id", $a_obj_ids,
"",
"integer"));
455 while (
$row = $DIC->database()->fetchAssoc($set)) {
456 self::$preload_list_gui_data[
$row[
"file_id"]][
"size"] = $row[
"file_size"];
457 self::$preload_list_gui_data[$row[
"file_id"]][
"version"] = $row[
"version"];
458 self::$preload_list_gui_data[$row[
"file_id"]][
"page_count"] = $row[
"page_count"];
470 if (isset(self::$preload_list_gui_data[$a_obj_id])) {
471 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
static _getAllReferences($a_id)
get all reference ids of object
static _lookupFileSize($a_id)
Quickly looks up the file size from the database and returns the number of bytes. ...
static $preload_list_gui_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.
Create styles array
The data for the language used.
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 _preloadData($a_obj_ids, $a_ref_ids)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $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)