Moodle  2.2.1
http://www.collinsharper.com
stored_file Class Reference

Public Member Functions

 __construct (file_storage $fs, stdClass $file_record, $filedir)
 is_directory ()
 delete ()
 add_to_curl_request (&$curlrequest, $key)
 get_content_file_handle ()
 readfile ()
 get_content ()
 copy_content_to ($pathname)
 list_files (file_packer $packer)
 extract_to_pathname (file_packer $packer, $pathname)
 extract_to_storage (file_packer $packer, $contextid, $component, $filearea, $itemid, $pathbase, $userid=NULL)
 archive_file (file_archive $filearch, $archivepath)
 get_imageinfo ()
 is_valid_image ()
 get_parent_directory ()
 get_contextid ()
 get_component ()
 get_filearea ()
 get_itemid ()
 get_filepath ()
 get_filename ()
 get_userid ()
 get_filesize ()
 get_mimetype ()
 get_timecreated ()
 get_timemodified ()
 get_status ()
 get_id ()
 get_contenthash ()
 get_pathnamehash ()
 get_license ()
 get_author ()
 get_source ()
 get_sortorder ()

Protected Member Functions

 get_content_file_location ()

Detailed Description

Class representing local files stored in a sha1 file pool.

Since Moodle 2.0 file contents are stored in sha1 pool and all other file information is stored in new "files" database table.

Since:
Moodle 2.0

Definition at line 42 of file stored_file.php.


Constructor & Destructor Documentation

__construct ( file_storage fs,
stdClass $  file_record,
filedir 
)

Constructor, this constructor should be called ONLY from the file_storage class!

Parameters:
file_storage$fsfile storage instance
object$file_recorddescription of file
string$filepoollocation of file directory with sh1 named content files

Definition at line 57 of file stored_file.php.


Member Function Documentation

add_to_curl_request ( &$  curlrequest,
key 
)

adds this file path to a curl request (POST only)

Parameters:
curl$curlrequestthe curl request object
string$keywhat key to use in the POST request
Returns:
void

Definition at line 113 of file stored_file.php.

Here is the call graph for this function:

archive_file ( file_archive filearch,
archivepath 
)

Add file/directory into archive.

Parameters:
file_archive$filearch
string$archivepathpathname in archive
Returns:
bool success

Definition at line 227 of file stored_file.php.

Here is the call graph for this function:

copy_content_to ( pathname)

Copy content of file to given pathname.

Parameters:
string$pathnamereal path to the new file
Returns:
bool success

Definition at line 170 of file stored_file.php.

Here is the call graph for this function:

delete ( )

Delete file from files table.

The content of files stored in sha1 pool is reclaimed later - the occupied disk space is reclaimed much later.

Returns:
bool always true or exception if error occurred

Definition at line 84 of file stored_file.php.

extract_to_pathname ( file_packer packer,
pathname 
)

Extract file to given file path (real OS filesystem), existing files are overwritten.

Parameters:
file_packer$file_packer
string$pathnametarget directory
Returns:
array|bool list of processed files; false if error

Definition at line 198 of file stored_file.php.

Here is the call graph for this function:

extract_to_storage ( file_packer packer,
contextid,
component,
filearea,
itemid,
pathbase,
userid = NULL 
)

Extract file to given file path (real OS filesystem), existing files are overwritten.

Parameters:
file_packer$file_packer
int$contextid
string$component
string$filearea
int$itemid
string$pathbase
int$userid
Returns:
array|bool list of processed files; false if error

Definition at line 215 of file stored_file.php.

Here is the call graph for this function:

Returns the author name of the file.

Returns:
string

Definition at line 454 of file stored_file.php.

Returns component name - this is the owner of the areas, nothing else is allowed to read or modify the files directly!!

Returns:
string

Definition at line 318 of file stored_file.php.

Here is the caller graph for this function:

Returns file content as string.

Returns:
string content

Definition at line 154 of file stored_file.php.

Here is the call graph for this function:

Returns file handle - read only mode, no writing allowed into pool files!

When you want to modify a file, create a new file and delete the old one.

Returns:
resource file handle

Definition at line 124 of file stored_file.php.

Here is the call graph for this function:

get_content_file_location ( ) [protected]

Protected - developers must not gain direct access to this function.

NOTE: do not make this public, we must not modify or delete the pool files directly! ;-)

Returns:
string full path to pool file with file content

Definition at line 99 of file stored_file.php.

Here is the caller graph for this function:

Returns sha1 hash of file content.

Returns:
string

Definition at line 427 of file stored_file.php.

Returns context id of the file-

Returns:
int context id

Definition at line 308 of file stored_file.php.

Here is the caller graph for this function:

Returns file area name, this divides files of one component into groups with different access control. All files in one area have the same access control.

Returns:
string

Definition at line 328 of file stored_file.php.

Here is the caller graph for this function:

Returns file name or '.' in case of directories.

Returns:
string

Definition at line 355 of file stored_file.php.

Here is the caller graph for this function:

Returns file path - starts and ends with /, \ are not allowed.

Returns:
string

Definition at line 346 of file stored_file.php.

Here is the caller graph for this function:

Returns the size of file in bytes.

Returns:
int bytes

Definition at line 373 of file stored_file.php.

get_id ( )

Returns file id.

Returns:
int

Definition at line 418 of file stored_file.php.

Here is the caller graph for this function:

Returns information about image, information is determined from the file content

Returns:
mixed array with width, height and mimetype; false if not an image

Definition at line 244 of file stored_file.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns returns item id of file.

Returns:
int

Definition at line 337 of file stored_file.php.

Here is the caller graph for this function:

Returns the license type of the file, it is a short name referred from license table.

Returns:
string

Definition at line 445 of file stored_file.php.

Returns mime type of file.

Returns:
string

Definition at line 382 of file stored_file.php.

Here is the caller graph for this function:

Returns parent directory, creates missing parents if needed.

Returns:
stored_file

Definition at line 283 of file stored_file.php.

Returns sha1 hash of all file path components sha1("contextid/component/filearea/itemid/dir/dir/filename.ext").

Returns:
string

Definition at line 436 of file stored_file.php.

Returns the sort order of file

Returns:
int

Definition at line 472 of file stored_file.php.

Returns the source of the file, usually it is a url.

Returns:
string

Definition at line 463 of file stored_file.php.

Returns file status flag.

Returns:
int 0 means file OK, anything else is a problem and file can not be used

Definition at line 409 of file stored_file.php.

Returns unix timestamp of file creation date.

Returns:
int

Definition at line 391 of file stored_file.php.

Returns unix timestamp of last file modification.

Returns:
int

Definition at line 400 of file stored_file.php.

Returns id of user who created the file.

Returns:
int

Definition at line 364 of file stored_file.php.

Is this a directory?

Directories are only emulated, internally they are stored as empty files with a "." instead of name - this means empty directory contains exactly one empty file with name dot.

Returns:
bool true means directory, false means file

Definition at line 72 of file stored_file.php.

Here is the caller graph for this function:

Verifies the file is a valid web image - gif, png and jpeg only.

It should be ok to serve this image from server without any other security workarounds.

Returns:
bool true if file ok

Definition at line 263 of file stored_file.php.

Here is the call graph for this function:

list_files ( file_packer packer)

List contents of archive.

Parameters:
file_packer$file_packer
Returns:
array of file infos

Definition at line 186 of file stored_file.php.

Here is the call graph for this function:

readfile ( )

Dumps file content to page.

Returns:
void

Definition at line 139 of file stored_file.php.

Here is the call graph for this function:


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations