ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilUploadFiles Class Reference
+ 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

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

Member Function Documentation

◆ _checkUploadFile()

static ilUploadFiles::_checkUploadFile ( string  $a_file)
static

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

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

66  : bool
67  {
68  $files = self::_getUploadFiles();
69 
70  return in_array($a_file, $files);
71  }
+ 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 73 of file class.ilUploadFiles.php.

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

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

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

◆ _getUploadDirectory()

static ilUploadFiles::_getUploadDirectory ( )
static

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

References $DIC, Vendor\Package\$e, $lm_set, SYSTEM_FOLDER_ID, and ilImportDirectoryFactory\TYPE_SAHS.

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

21  : string
22  {
23  global $DIC;
24  $rbacsystem = $DIC['rbacsystem'];
25 
26  if (!$rbacsystem->checkAccess('write', SYSTEM_FOLDER_ID)) {
27  return '';
28  }
29 
30  $lm_set = new ilSetting("lm");
31  $upload_dir = $lm_set->get("cont_upload_dir");
32 
33  $import_file_factory = new ilImportDirectoryFactory();
34  try {
35  $scorm_import_directory = $import_file_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_SAHS);
36  } catch (InvalidArgumentException $e) {
37  return '';
38  }
39  return $scorm_import_directory->getAbsolutePath();
40  }
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: feed.php:28
$lm_set
+ Here is the caller graph for this function:

◆ _getUploadFiles()

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

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

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

45  : array
46  {
47  if (!$upload_dir = self::_getUploadDirectory()) {
48  return array();
49  }
50 
51  // get the sorted content of the upload directory
52  $handle = opendir($upload_dir);
53  $files = array();
54  while (false !== ($file = readdir($handle))) {
55  $full_path = $upload_dir . "/" . $file;
56  if (is_file($full_path) and is_readable($full_path)) {
57  $files[] = $file;
58  }
59  }
60  closedir($handle);
61  sort($files);
62 
63  return $files;
64  }
+ Here is the caller graph for this function:

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