Public Member Functions

ilObjFileAccess Class Reference
[Modules/File]

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

Detailed Description

Access class for file objects.

Author:
Alex Killing <alex.killing@gmx.de>
Version:
Id:
class.ilObjFileAccess.php 11692 2006-07-29 23:35:47Z akill

Definition at line 34 of file class.ilObjFileAccess.php.


Member Function Documentation

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, $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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 "";
        }

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 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);
        }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: