Access class for file objects. More...
Inheritance diagram for ilObjFileAccess:
Collaboration diagram for ilObjFileAccess: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 | |
| _lookupVersion ($a_id) | |
| lookup version | |
| _lookupFileSize ($a_id, $a_as_string=false) | |
| lookup size | |
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;
}
Here is the caller graph for this function:| ilObjFileAccess::_lookupFileSize | ( | $ | a_id, | |
| $ | a_as_string = false | |||
| ) |
lookup size
Definition at line 100 of file class.ilObjFileAccess.php.
References $file, and _lookupVersion().
Referenced by ilObjFileListGUI::getProperties().
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id);
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
include_once('Modules/File/classes/class.ilFSStorageFile.php');
$fss = new ilFSStorageFile($a_id);
$file = $fss->getAbsolutePath().'/'.$row->file_name;
#$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;
$file = $fss->getAbsolutePath().'/'.$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;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFileAccess::_lookupFileSize | ( | $ | a_id, | |
| $ | a_as_string = false | |||
| ) |
lookup size
Definition at line 44 of file class.ilObjFileAccess.php.
References $file, and _lookupVersion().
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id);
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
include_once('Services/Migration/DBUpdate_904/classes/class.ilFSStorageFile.php');
$fss = new ilFSStorageFile($a_id);
$file = $fss->getAbsolutePath().'/'.$row->file_name;
if (@!is_file($file))
{
$version_subdir = "/".sprintf("%03d", ilObjFileAccess::_lookupVersion($a_id));
$file = $fss->getAbsolutePath().'/'.$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;
}
Here is the call graph for this function:| ilObjFileAccess::_lookupSuffix | ( | $ | a_id | ) |
lookup suffix
Definition at line 153 of file class.ilObjFileAccess.php.
References $file, and _lookupVersion().
Referenced by ilObjFileListGUI::getProperties().
{
include_once('Modules/File/classes/class.ilFSStorageFile.php');
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id);
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
#$file = ilUtil::getDataDir()."/files/file_".$a_id."/".$row->file_name;
$fss = new ilFSStorageFile($a_id);
$file = $fss->getAbsolutePath().'/'.$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;
$file = $fss->getAbsolutePath().'/'.$version_subdir.'/'.$row->file_name;
}
if (is_file($file))
{
$pi = pathinfo($file);
return ".".$pi["extension"];
}
return "";
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFileAccess::_lookupVersion | ( | $ | a_id | ) |
lookup version
Definition at line 30 of file class.ilObjFileAccess.php.
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id);
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
return $row->version;
}
| ilObjFileAccess::_lookupVersion | ( | $ | a_id | ) |
lookup version
Definition at line 86 of file class.ilObjFileAccess.php.
References ilUtil::stripSlashes().
Referenced by _lookupFileSize(), _lookupSuffix(), and ilObjFileListGUI::getProperties().
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id);
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
return ilUtil::stripSlashes($row->version);
}
Here is the call graph for this function:
Here is the caller graph for this function:
1.7.1