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

Public Member Functions

 upload_manager ($inputname='', $deleteothers=false, $handlecollisions=false, $course=null, $recoverifmultiple=false, $modbytes=0, $silent=false, $allownull=false, $allownullmultiple=true)
 preprocess_files ()
 validate_file (&$file)
 save_files ($destination)
 process_file_uploads ($destination)
 delete_other_files ($destination, $exceptions=null)
 handle_filename_collision ($destination, &$file)
 check_before_renaming ($destination, $nametocheck, $file)
 get_file_upload_error (&$file)
 print_upload_log ($return=false, $skipemptyifmultiple=false)
 get_new_filename ()
 get_new_filepath ()
 get_original_filename ()
 get_errors ()

Data Fields

 $files
 $config
 $status
 $course
 $inputname
 $notify

Detailed Description

Definition at line 36 of file uploadlib.php.


Member Function Documentation

check_before_renaming ( destination,
nametocheck,
file 
)

This function checks a potential filename against what's on the filesystem already and what's been saved already.

Parameters:
string$destinationDestination directory (to check existing files against)
string$nametocheckThe filename to be compared.
object$fileThe current file from $files we're processing. return boolean

Definition at line 364 of file uploadlib.php.

Here is the caller graph for this function:

delete_other_files ( destination,
exceptions = null 
)

Deletes all the files in a given directory except for the files in $exceptions (full paths)

Parameters:
string$destinationThe directory to clean up.
array$exceptionsFull paths of files to KEEP.

Definition at line 299 of file uploadlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

This function returns any errors wrapped up in red.

Returns:
string

Definition at line 493 of file uploadlib.php.

Here is the call graph for this function:

get_file_upload_error ( &$  file)

?

Parameters:
object$filePassed in by reference. The current file from $files we're processing.
Returns:
string
Todo:
Finish documenting this function

probably a dud file name

Definition at line 389 of file uploadlib.php.

If we're only handling one file (if inputname was given in the constructor) this will return the (possibly changed) filename of the file.

Returns:
boolean

Definition at line 460 of file uploadlib.php.

If we're only handling one file (if input name was given in the constructor) this will return the full path to the saved file.

Returns:
boolean

Definition at line 471 of file uploadlib.php.

If we're only handling one file (if inputname was given in the constructor) this will return the ORIGINAL filename of the file.

Returns:
boolean

Definition at line 482 of file uploadlib.php.

handle_filename_collision ( destination,
&$  file 
)

Handles filename collisions - if the desired filename exists it will rename it according to the pattern in $format

Parameters:
string$destinationDestination directory (to check existing files against)
object$filePassed in by reference. The current file from $files we're processing.
Returns:
void - modifies &$file parameter.

Definition at line 326 of file uploadlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Gets all entries out of $_FILES and stores them locally in $files and then checks each one against get_max_upload_file_size() and calls cleanfilename() and scans them for viruses etc. $CFG $_FILES

Returns:
boolean

Definition at line 120 of file uploadlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

print_upload_log ( return = false,
skipemptyifmultiple = false 
)

prints a log of everything that happened (of interest) to each file in _FILES

Parameters:
$return- optional, defaults to false (log is echoed)

Definition at line 440 of file uploadlib.php.

process_file_uploads ( destination)

Wrapper function that calls preprocess_files() and viruscheck_files() and then save_files() Modules that require the insert id in the filepath should not use this and call these functions seperately in the required order. string $destination Where to save the uploaded files to.

Returns:
boolean

Definition at line 286 of file uploadlib.php.

Here is the call graph for this function:

save_files ( destination)

Moves all the files to the destination directory.

$CFG $USER

Parameters:
string$destinationThe destination directory.
Returns:
boolean status;

Definition at line 212 of file uploadlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

upload_manager ( inputname = '',
deleteothers = false,
handlecollisions = false,
course = null,
recoverifmultiple = false,
modbytes = 0,
silent = false,
allownull = false,
allownullmultiple = true 
)

Constructor, sets up configuration stuff so we know how to act.

Note: destination not taken as parameter as some modules want to use the insertid in the path and we need to check the other stuff first.

$CFG

Parameters:
string$inputnameIf this is given the upload manager will only process the file in $_FILES with this name.
boolean$deleteothersWhether to delete other files in the destination directory (optional, defaults to false)
boolean$handlecollisionsWhether to use handle_filename_collision() or not. (optional, defaults to false)
course$courseThe course the files are being uploaded for (for logging and virus notifications) $COURSE
boolean$recoverifmultipleIf we come across a virus, or if a file doesn't validate or whatever, do we continue? optional, defaults to true.
int$modbytesMax bytes for this module - this and $course->maxbytes are used to get the maxbytes from get_max_upload_file_size().
boolean$silentWhether to notify errors or not.
boolean$allownullWhether we care if there's no file when we've set the input name.
boolean$allownullmultipleWhether we care if there's no files AT ALL when we've got multiples. This won't complain if we have file 1 and file 3 but not file 2, only for NO FILES AT ALL.

Definition at line 89 of file uploadlib.php.

Here is the call graph for this function:

validate_file ( &$  file)

Validates a single file entry from _FILES

Parameters:
object$fileThe entry from _FILES to validate
Returns:
boolean True if ok.

Definition at line 189 of file uploadlib.php.

Here is the caller graph for this function:


Field Documentation

array $config

Holds all configuration stuff

Definition at line 47 of file uploadlib.php.

The course this file has been uploaded for. $COURSE (for logging and virus notifications)

Definition at line 59 of file uploadlib.php.

array $files

Array to hold local copies of stuff in $_FILES

Definition at line 42 of file uploadlib.php.

string $inputname

If we're only getting one file. (for logging and virus notifications)

Definition at line 65 of file uploadlib.php.

string $notify

If we're given silent=true in the constructor, this gets built up to hold info about the process.

Definition at line 71 of file uploadlib.php.

boolean $status

Keep track of if we're ok (errors for each file are kept in $files['whatever']['uploadlog']

Definition at line 53 of file uploadlib.php.


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