ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 22 of file class.ilUploadFiles.php.

Member Function Documentation

◆ _checkUploadFile()

static ilUploadFiles::_checkUploadFile ( string  $a_file)
static

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

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

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

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

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

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

◆ _getUploadDirectory()

static ilUploadFiles::_getUploadDirectory ( )
static

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

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

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

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

◆ _getUploadFiles()

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

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

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

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

48  : array
49  {
50  if ($upload_dir = self::_getUploadDirectory() === '' || $upload_dir = self::_getUploadDirectory() === '0') {
51  return [];
52  }
53 
54  // get the sorted content of the upload directory
55  $handle = opendir($upload_dir);
56  $files = [];
57  while (false !== ($file = readdir($handle))) {
58  $full_path = $upload_dir . "/" . $file;
59  if (is_file($full_path) && is_readable($full_path)) {
60  $files[] = $file;
61  }
62  }
63  closedir($handle);
64  sort($files);
65 
66  return $files;
67  }
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
+ 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: