5 include_once(
"./Services/Object/classes/class.ilObjectAccess.php");
6 require_once(
'./Services/WebAccessChecker/interfaces/interface.ilWACCheckingClass.php');
23 protected function checkAccessToObjectId($obj_id) {
29 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
45 $re =
'/\/previews\/[\d\/]{0,}\/preview_([\d]{0,})\//uU';
48 preg_match($re, $ilWACPath->
getPath(), $matches);
50 return $this->checkAccessToObjectId($matches[1]);
83 $commands[] =
array(
"permission" =>
"read",
"cmd" =>
"sendfile",
"lang_var" =>
"download",
"default" =>
true);
84 $commands[] =
array(
"permission" =>
"write",
"cmd" =>
"edit",
"lang_var" =>
"edit_content");
85 $commands[] =
array(
"permission" =>
"write",
"cmd" =>
"versions",
"lang_var" =>
"versions");
97 $t_arr = explode(
"_", $a_target);
100 if(isset($t_arr[2]) && $t_arr[2] ==
"wsp")
102 include_once
"Services/PersonalWorkspace/classes/class.ilSharedResourceGUI.php";
106 if ($t_arr[0] !=
"file" || ((
int) $t_arr[1]) <= 0)
111 if ($ilAccess->checkAccess(
"visible",
"", $t_arr[1]) ||
112 $ilAccess->checkAccess(
"read",
"", $t_arr[1]))
127 $q =
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
128 $r = $ilDB->query($q);
141 $q =
"SELECT version FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
142 $r = $ilDB->query($q);
156 $q =
"SELECT file_size FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
157 $r = $ilDB->query($q);
175 $q =
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
176 $r = $ilDB->query($q);
179 require_once(
'Modules/File/classes/class.ilFSStorageFile.php');
181 $file = $fss->getAbsolutePath().
'/'.
$row->file_name;
183 if (@!is_file(
$file))
186 $file = $fss->getAbsolutePath().
'/'.$version_subdir.
'/'.
$row->file_name;
207 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
212 $q =
"SELECT * FROM object_data WHERE obj_id = ".$ilDB->quote($a_id ,
'integer');
213 $r = $ilDB->query($q);
215 require_once
'Modules/File/classes/class.ilObjFile.php';
216 return self::_getFileExtension(
$row->title);
227 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
229 $dir = $fileStorage->getAbsolutePath();
239 if (self::$_inlineFileExtensionsArray === null)
241 require_once
'Services/Administration/classes/class.ilSetting.php';
242 $settings =
new ilSetting(
'file_access');
243 self::$_inlineFileExtensionsArray = preg_split(
'/ /', $settings->get(
'inline_file_extensions'), -1, PREG_SPLIT_NO_EMPTY);
245 $extension = self::_getFileExtension($a_file_name);
246 return in_array($extension, self::$_inlineFileExtensionsArray);
262 if (preg_match(
'/\.([a-z0-9]+)\z/i',$a_file_name,$matches) == 1)
264 return strtolower($matches[1]);
283 return substr($a_file_name,0,1) ==
'.' ||
284 substr($a_file_name,-1,1) ==
'~' ||
285 substr($a_file_name,0,2) ==
'~$' ||
286 $a_file_name ==
'Thumbs.db';
321 $filenameWithoutExtension= $a_file_name;
324 if ($a_handle_extension)
328 if (strlen($extension) > 0)
330 $extension =
'.'.$extension;
331 $filenameWithoutExtension= substr($a_file_name, 0, -strlen($extension));
339 $nthCopyRegex = preg_replace(
'/([\^$.\[\]|()?*+{}])/',
'\\\\${1}',
' '.$lng->txt(
'copy_n_of_suffix'));
340 $nthCopyRegex =
'/'.preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $nthCopyRegex).
'$/';
344 if (preg_match($nthCopyRegex, $filenameWithoutExtension, $matches))
347 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen($matches[0]));
348 if ($nth_copy == null)
350 $nth_copy = $matches[1]+1;
353 else if (substr($filenameWithoutExtension,-strlen(
' '.$lng->txt(
'copy_of_suffix'))) ==
' '.$lng->txt(
'copy_of_suffix'))
356 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen(
' '.$lng->txt(
'copy_of_suffix')));
357 if ($nth_copy == null)
365 $filenameWithoutCopy = $filenameWithoutExtension;
366 if ($nth_copy == null)
377 $newFilename = $filenameWithoutCopy.sprintf(
' '.$lng->txt(
'copy_n_of_suffix'), $nth_copy).$extension;
382 $newFilename = $filenameWithoutCopy.
' '.$lng->txt(
'copy_of_suffix').$extension;
393 include_once(
"./Services/Link/classes/class.ilLink.php");
401 self::$preload_list_gui_data =
array();
403 $set = $ilDB->query(
"SELECT obj_id,max(hdate) latest".
405 " WHERE obj_type = ".$ilDB->quote(
"file",
"text").
406 " AND ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
408 while(
$row = $ilDB->fetchAssoc($set))
410 self::$preload_list_gui_data[
$row[
"obj_id"]][
"date"] = $row[
"latest"];
413 $set = $ilDB->query(
"SELECT file_size,version,file_id".
415 " WHERE ".$ilDB->in(
"file_id", $a_obj_ids,
"",
"integer"));
416 while(
$row = $ilDB->fetchAssoc($set))
418 self::$preload_list_gui_data[
$row[
"file_id"]][
"size"] = $row[
"file_size"];
419 self::$preload_list_gui_data[$row[
"file_id"]][
"version"] = $row[
"version"];
425 if(isset(self::$preload_list_gui_data[$a_obj_id]))
427 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 _getStaticLink($a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
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.
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)