ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUploadFiles Class Reference
+ Collaboration diagram for ilUploadFiles:

Static Public Member Functions

static _getUploadDirectory ()
 Get the directory with uploaded files.
static _getUploadFiles ()
 Get a list of readable files in the upload directory.
static _checkUploadFile ($a_file)
 Check if a file exists in the upload directory and is readable.
static _copyUploadFile ($a_file, $a_target, $a_raise_errors=true)
 copy an uploaded file to the target directory (including virus check)

Detailed Description

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

Member Function Documentation

static ilUploadFiles::_checkUploadFile (   $a_file)
static

Check if a file exists in the upload directory and is readable.

Parameters
stringfile name
Returns
boolean true/false static

Definition at line 107 of file class.ilUploadFiles.php.

References $files, and _getUploadFiles().

Referenced by ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilFileSystemGUI\uploadFile(), and ilObjSAHSLearningModuleGUI\uploadObject().

{
return in_array($a_file, $files);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilUploadFiles::_copyUploadFile (   $a_file,
  $a_target,
  $a_raise_errors = true 
)
static

copy an uploaded file to the target directory (including virus check)

Parameters
stringfile name
stringtarget path and name
Returns
boolean true/false static

Definition at line 122 of file class.ilUploadFiles.php.

References $file, $lng, _getUploadDirectory(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\virusHandling().

Referenced by ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilFileSystemGUI\uploadFile(), and ilObjSAHSLearningModuleGUI\uploadObject().

{
global $lng, $ilias;
$file = self::_getUploadDirectory() . "/". $a_file;
// check if file exists
if (!is_file($file))
{
if ($a_raise_errors)
{
$ilias->raiseError($lng->txt("upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
}
else
{
ilUtil::sendFailure($lng->txt("upload_error_file_not_found"), true);
}
return false;
}
// virus handling
$vir = ilUtil::virusHandling($file, $a_file);
if (!$vir[0])
{
if ($a_raise_errors)
{
$ilias->raiseError($lng->txt("file_is_infected")."<br />".
$vir[1],
$ilias->error_obj->MESSAGE);
}
else
{
ilUtil::sendFailure($lng->txt("file_is_infected")."<br />".
$vir[1], true);
}
return false;
}
else
{
if ($vir[1] != "")
{
ilUtil::sendInfo($vir[1], true);
}
return copy($file, $a_target);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilUploadFiles::_getUploadDirectory ( )
static

Get the directory with uploaded files.

The directory is configured as cont_upload_dir in the settings table. The directory must exist and have read permissions. Currently the user must have admin permissions in ILIAS. Later there may be different directories for different users/roles.

Returns
string full path of upload directory on the server or empty static

Definition at line 47 of file class.ilUploadFiles.php.

Referenced by _copyUploadFile(), ilObjSAHSLearningModuleGUI\createObject(), ilObjSAHSLearningModuleGUI\initUploadForm(), ilFileSystemGUI\listFiles(), and ilObjSCORMLearningModuleGUI\newModuleVersion().

{
global $rbacsystem;
if(!$rbacsystem->checkAccess('write', SYSTEM_FOLDER_ID))
{
return '';
}
$lm_set = new ilSetting("lm");
$upload_dir = $lm_set->get("cont_upload_dir");
if (is_dir($upload_dir) and is_readable($upload_dir))
{
return $upload_dir;
}
else
{
return '';
}
}

+ Here is the caller graph for this function:

static ilUploadFiles::_getUploadFiles ( )
static

Get a list of readable files in the upload directory.

Returns
array list of file names (without path) static

Definition at line 75 of file class.ilUploadFiles.php.

References $file, $files, and $handle.

Referenced by _checkUploadFile(), ilObjSAHSLearningModuleGUI\createObject(), ilObjSAHSLearningModuleGUI\initUploadForm(), ilFileSystemGUI\listFiles(), and ilObjSCORMLearningModuleGUI\newModuleVersion().

{
if (!$upload_dir = self::_getUploadDirectory())
{
return array();
}
// get the sorted content of the upload directory
$handle = opendir($upload_dir);
$files = array();
while (false !== ($file = readdir($handle)))
{
$full_path = $upload_dir . "/". $file;
if (is_file($full_path) and is_readable($full_path))
{
}
}
closedir($handle);
sort($files);
reset($files);
return $files;
}

+ Here is the caller graph for this function:


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