ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilUploadFiles Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilUploadFiles:

Static Public Member Functions

static _getUploadDirectory ()
 
static _getUploadFiles ()
 
static _checkUploadFile (string $a_file)
 
static _copyUploadFile (string $a_file, string $a_target, bool $a_raise_errors=true)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Deprecated:
Will be removed in ILIAS 10. No replacement suggested. This feature is only used in CmiXApi and SCORM and must be implemented there

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

Member Function Documentation

◆ _checkUploadFile()

static ilUploadFiles::_checkUploadFile ( string  $a_file)
static

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

70 : bool
71 {
72 $files = self::_getUploadFiles();
73
74 return in_array($a_file, $files);
75 }

References _getUploadFiles().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _copyUploadFile()

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

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

77 : bool
78 {
79 global $DIC;
80 $main_tpl = $DIC->ui()->mainTemplate();
81 $lng = $DIC['lng'];
82 $ilias = $DIC['ilias'];
83
84 $file = self::_getUploadDirectory() . "/" . $a_file;
85
86 // check if file exists
87 if (!is_file($file)) {
88 if ($a_raise_errors) {
89 $ilias->raiseError($lng->txt("upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
90 } else {
91 $main_tpl->setOnScreenMessage('failure', $lng->txt("upload_error_file_not_found"), true);
92 }
93 return false;
94 }
95
96 // virus handling
97 $vir = ilVirusScanner::virusHandling($file, $a_file);
98 if (!$vir[0]) {
99 if ($a_raise_errors) {
100 $ilias->raiseError(
101 $lng->txt("file_is_infected") . "<br />" .
102 $vir[1],
103 $ilias->error_obj->MESSAGE
104 );
105 } else {
106 $main_tpl->setOnScreenMessage('failure', $lng->txt("file_is_infected") . "<br />" .
107 $vir[1], true);
108 }
109 return false;
110 }
111 if ($vir[1] != "") {
112 $main_tpl->setOnScreenMessage('info', $vir[1], true);
113 }
114 return copy($file, $a_target);
115 }
static _getUploadDirectory()
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26

References $DIC, $lng, _getUploadDirectory(), and ilVirusScanner\virusHandling().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getUploadDirectory()

static ilUploadFiles::_getUploadDirectory ( )
static

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

25 : string
26 {
27 global $DIC;
28 $rbacsystem = $DIC['rbacsystem'];
29
30 if (!$rbacsystem->checkAccess('write', SYSTEM_FOLDER_ID)) {
31 return '';
32 }
33
34 $lm_set = new ilSetting("lm");
35 $upload_dir = $lm_set->get("cont_upload_dir");
36
37 $import_file_factory = new ilImportDirectoryFactory();
38 try {
39 $scorm_import_directory = $import_file_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_SAHS);
40 } catch (InvalidArgumentException) {
41 return '';
42 }
43 return $scorm_import_directory->getAbsolutePath();
44 }
ILIAS Setting Class.
const SYSTEM_FOLDER_ID
Definition: constants.php:35
$lm_set

References $DIC, $lm_set, SYSTEM_FOLDER_ID, and ilImportDirectoryFactory\TYPE_SAHS.

Referenced by _copyUploadFile(), ilObjCmiXapiGUI\afterSave(), ilObjCmiXapiGUI\initCreateForm(), ilObjSAHSLearningModuleGUI\initCreateForm(), ilFileSystemGUI\listFiles(), and ilObjSCORMLearningModuleGUI\newModuleVersion().

+ Here is the caller graph for this function:

◆ _getUploadFiles()

static ilUploadFiles::_getUploadFiles ( )
static
Returns
string[]

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

49 : array
50 {
51 if ($upload_dir = self::_getUploadDirectory() === '' || $upload_dir = self::_getUploadDirectory() === '0') {
52 return [];
53 }
54
55 // get the sorted content of the upload directory
56 $handle = opendir($upload_dir);
57 $files = [];
58 while (false !== ($file = readdir($handle))) {
59 $full_path = $upload_dir . "/" . $file;
60 if (is_file($full_path) && is_readable($full_path)) {
61 $files[] = $file;
62 }
63 }
64 closedir($handle);
65 sort($files);
66
67 return $files;
68 }

References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

Referenced by _checkUploadFile(), ilObjCmiXapiGUI\initCreateForm(), ilObjSAHSLearningModuleGUI\initCreateForm(), ilFileSystemGUI\listFiles(), and ilObjSCORMLearningModuleGUI\newModuleVersion().

+ 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: