Access class for file objects. More...
Public Member Functions | |
_getCommands () | |
get commands | |
_checkGoto ($a_target) | |
check whether goto script will succeed | |
_lookupVersion ($a_id) | |
lookup version | |
_lookupFileSize ($a_id, $a_as_string=false) | |
lookup size | |
_lookupSuffix ($a_id) | |
lookup suffix |
Access class for file objects.
Definition at line 34 of file class.ilObjFileAccess.php.
ilObjFileAccess::_checkGoto | ( | $ | a_target | ) |
check whether goto script will succeed
Reimplemented from ilObjectAccess.
Definition at line 65 of file class.ilObjFileAccess.php.
{ global $ilAccess; $t_arr = explode("_", $a_target); if ($t_arr[0] != "file" || ((int) $t_arr[1]) <= 0) { return false; } if ($ilAccess->checkAccess("visible", "", $t_arr[1])) { return true; } return false; }
ilObjFileAccess::_getCommands | ( | ) |
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"), );
Reimplemented from ilObjectAccess.
Definition at line 49 of file class.ilObjFileAccess.php.
Referenced by ilObjFileListGUI::init().
{ $commands = array ( array("permission" => "read", "cmd" => "sendfile", "lang_var" => "download", "default" => true), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), array("permission" => "read", "cmd" => "versions", "lang_var" => "versions") ); return $commands; }
ilObjFileAccess::_lookupFileSize | ( | $ | a_id, | |
$ | a_as_string = false | |||
) |
lookup size
Definition at line 100 of file class.ilObjFileAccess.php.
References $file, $q, $row, _lookupVersion(), and ilUtil::getDataDir().
Referenced by ilObjFileListGUI::getProperties().
{ global $ilDB; $q = "SELECT * FROM file_data WHERE file_id = '".$a_id."'"; $r = $ilDB->query($q); $row = $r->fetchRow(DB_FETCHMODE_OBJECT); $file = ilUtil::getDataDir()."/files/file_".$a_id."/".$row->file_name; if (@!is_file($file)) { $version_subdir = "/".sprintf("%03d", ilObjFileAccess::_lookupVersion($a_id)); $file = ilUtil::getDataDir()."/files/file_".$a_id.$version_subdir."/".$row->file_name; } if (is_file($file)) { $size = filesize($file); } else { $size = 0; } if ($a_as_string) { if ($size > 1000000) { return round($size/1000000,1)." MB"; } else if ($size > 1000) { return round($size/1000,1)." KB"; } else { return $size." Bytes"; } } return $size; }
ilObjFileAccess::_lookupSuffix | ( | $ | a_id | ) |
lookup suffix
Definition at line 148 of file class.ilObjFileAccess.php.
References $file, $q, $row, _lookupVersion(), and ilUtil::getDataDir().
Referenced by ilObjFileListGUI::getProperties().
{ global $ilDB; $q = "SELECT * FROM file_data WHERE file_id = '".$a_id."'"; $r = $ilDB->query($q); $row = $r->fetchRow(DB_FETCHMODE_OBJECT); $file = ilUtil::getDataDir()."/files/file_".$a_id."/".$row->file_name; if (@!is_file($file)) { $version_subdir = "/".sprintf("%03d", ilObjFileAccess::_lookupVersion($a_id)); $file = ilUtil::getDataDir()."/files/file_".$a_id.$version_subdir."/".$row->file_name; } if (is_file($file)) { $pi = pathinfo($file); return ".".$pi["extension"]; } return ""; }
ilObjFileAccess::_lookupVersion | ( | $ | a_id | ) |
lookup version
Definition at line 86 of file class.ilObjFileAccess.php.
References $q, $row, and ilUtil::stripSlashes().
Referenced by _lookupFileSize(), _lookupSuffix(), and ilObjFileListGUI::getProperties().
{ global $ilDB; $q = "SELECT * FROM file_data WHERE file_id = '".$a_id."'"; $r = $ilDB->query($q); $row = $r->fetchRow(DB_FETCHMODE_OBJECT); return ilUtil::stripSlashes($row->version); }