ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 the next release

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

Member Function Documentation

◆ _checkUploadFile()

static ilUploadFiles::_checkUploadFile ( string  $a_file)
static

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

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

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

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

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

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

◆ _getUploadDirectory()

static ilUploadFiles::_getUploadDirectory ( )
static

Definition at line 20 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().

20  : string
21  {
22  global $DIC;
23  $rbacsystem = $DIC['rbacsystem'];
24 
25  if (!$rbacsystem->checkAccess('write', SYSTEM_FOLDER_ID)) {
26  return '';
27  }
28 
29  $lm_set = new ilSetting("lm");
30  $upload_dir = $lm_set->get("cont_upload_dir");
31 
32  $import_file_factory = new ilImportDirectoryFactory();
33  try {
34  $scorm_import_directory = $import_file_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_SAHS);
35  } catch (InvalidArgumentException $e) {
36  return '';
37  }
38  return $scorm_import_directory->getAbsolutePath();
39  }
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 44 of file class.ilUploadFiles.php.

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

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

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