ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 71 of file class.ilUploadFiles.php.

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

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 78 of file class.ilUploadFiles.php.

78 : bool
79 {
80 global $DIC;
81 $main_tpl = $DIC->ui()->mainTemplate();
82 $lng = $DIC['lng'];
83 $ilias = $DIC['ilias'];
84
85 $file = self::_getUploadDirectory() . "/" . $a_file;
86
87 // check if file exists
88 if (!is_file($file)) {
89 if ($a_raise_errors) {
90 $ilias->raiseError($lng->txt("upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
91 } else {
92 $main_tpl->setOnScreenMessage('failure', $lng->txt("upload_error_file_not_found"), true);
93 }
94 return false;
95 }
96
97 // virus handling
98 $vir = ilVirusScanner::virusHandling($file, $a_file);
99 if (!$vir[0]) {
100 if ($a_raise_errors) {
101 $ilias->raiseError(
102 $lng->txt("file_is_infected") . "<br />" .
103 $vir[1],
104 $ilias->error_obj->MESSAGE
105 );
106 } else {
107 $main_tpl->setOnScreenMessage('failure', $lng->txt("file_is_infected") . "<br />" .
108 $vir[1], true);
109 }
110 return false;
111 }
112 if ($vir[1] != "") {
113 $main_tpl->setOnScreenMessage('info', $vir[1], true);
114 }
115 return copy($file, $a_target);
116 }
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(), _getUploadFiles(), 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 $upload_dir = self::_getUploadDirectory();
52 if ($upload_dir === '' || $upload_dir === '0') {
53 return [];
54 }
55
56 // get the sorted content of the upload directory
57 $handle = opendir($upload_dir);
58 $files = [];
59 while (false !== ($file = readdir($handle))) {
60 $full_path = $upload_dir . "/" . $file;
61 if (is_file($full_path) && is_readable($full_path)) {
62 $files[] = $file;
63 }
64 }
65 closedir($handle);
66 sort($files);
67
68 return $files;
69 }

References _getUploadDirectory(), and 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: