ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilIndividualAssessmentFileStorage Class Reference

Handles the fileupload and folder creation for files uploaded in grading form. More...

+ Inheritance diagram for ilIndividualAssessmentFileStorage:
+ Collaboration diagram for ilIndividualAssessmentFileStorage:

Public Member Functions

 isEmpty ()
 Is the webdir folder for this IA empty. More...
 
 setUserId ($user_id)
 Set the user id for an extra folder of each participant in the IA. More...
 
 create ()
 creates the folder structure More...
 
 getAbsolutePath ()
 Get the absolute path for files. More...
 
 readDir ()
 Read the dir. More...
 
 uploadFile (UploadResult $result)
 Upload the file. More...
 
 deleteCurrentFile ()
 Delete the existing file. More...
 
 getFilePath ()
 Get the path of file. More...
 
 deleteFileByName ($file_name)
 Delete a file by name. More...
 
- Public Member Functions inherited from ilFileSystemStorage
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 
 getPath ()
 Get path. More...
 
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 getShortPath ()
 
 rename ($from, $to)
 

Static Public Member Functions

static getInstance ($a_container_id=0)
 
- Static Public Member Functions inherited from ilFileSystemStorage
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
static _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 

Protected Member Functions

 getPathPostfix ()
 part of the folder structure in ILIAS webdir. More...
 
 getPathPrefix ()
 part of the folder structure in ILIAS webdir. More...
 
- Protected Member Functions inherited from ilFileSystemStorage
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 init ()
 Read path info. More...
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 

Additional Inherited Members

- Data Fields inherited from ilFileSystemStorage
const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 
const SECURED_DIRECTORY = "sec"
 
- Protected Attributes inherited from ilFileSystemStorage
 $path
 

Detailed Description

Handles the fileupload and folder creation for files uploaded in grading form.

Author
Stefan Hecken stefa.nosp@m.n.he.nosp@m.cken@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 13 of file class.ilIndividualAssessmentFileStorage.php.

Member Function Documentation

◆ create()

ilIndividualAssessmentFileStorage::create ( )

creates the folder structure

Returns
boolen

Implements IndividualAssessmentFileStorage.

Definition at line 67 of file class.ilIndividualAssessmentFileStorage.php.

References getAbsolutePath(), and ilUtil\makeDirParents().

Referenced by readDir().

68  {
69  if (!file_exists($this->getAbsolutePath())) {
71  }
72  return true;
73  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteCurrentFile()

ilIndividualAssessmentFileStorage::deleteCurrentFile ( )

Delete the existing file.

Implements IndividualAssessmentFileStorage.

Definition at line 140 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemStorage\deleteFile(), getAbsolutePath(), and readDir().

141  {
142  $files = $this->readDir();
143  $this->deleteFile($this->getAbsolutePath() . "/" . $files[0]);
144  }
deleteFile($a_abs_name)
Delete file.
+ Here is the call graph for this function:

◆ deleteFileByName()

ilIndividualAssessmentFileStorage::deleteFileByName (   $file_name)

Delete a file by name.

Parameters
string$file_name

Definition at line 162 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemStorage\deleteFile(), and getAbsolutePath().

163  {
164  $this->deleteFile($this->getAbsolutePath() . "/" . $file_name);
165  }
deleteFile($a_abs_name)
Delete file.
+ Here is the call graph for this function:

◆ getAbsolutePath()

ilIndividualAssessmentFileStorage::getAbsolutePath ( )

Get the absolute path for files.

Returns
string

Definition at line 80 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemStorage\$path.

Referenced by create(), deleteCurrentFile(), deleteFileByName(), getFilePath(), readDir(), and uploadFile().

81  {
82  $path = parent::getAbsolutePath();
83 
84  if ($this->user_id) {
85  $path .= "/user_" . $this->user_id;
86  }
87 
88  return $path;
89  }
+ Here is the caller graph for this function:

◆ getFilePath()

ilIndividualAssessmentFileStorage::getFilePath ( )

Get the path of file.

Returns
string

Implements IndividualAssessmentFileStorage.

Definition at line 151 of file class.ilIndividualAssessmentFileStorage.php.

References getAbsolutePath(), and readDir().

152  {
153  $files = $this->readDir();
154  return $this->getAbsolutePath() . "/" . $files[0];
155  }
+ Here is the call graph for this function:

◆ getInstance()

static ilIndividualAssessmentFileStorage::getInstance (   $a_container_id = 0)
static

Definition at line 15 of file class.ilIndividualAssessmentFileStorage.php.

Referenced by ilObjIndividualAssessment\getFileStorage().

16  {
17  return new self(self::STORAGE_WEB, true, $a_container_id);
18  }
+ Here is the caller graph for this function:

◆ getPathPostfix()

ilIndividualAssessmentFileStorage::getPathPostfix ( )
protected

part of the folder structure in ILIAS webdir.

Returns
string

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

26  {
27  return 'iass';
28  }

◆ getPathPrefix()

ilIndividualAssessmentFileStorage::getPathPrefix ( )
protected

part of the folder structure in ILIAS webdir.

Returns
string

Definition at line 35 of file class.ilIndividualAssessmentFileStorage.php.

36  {
37  return 'IASS';
38  }

◆ isEmpty()

ilIndividualAssessmentFileStorage::isEmpty ( )

Is the webdir folder for this IA empty.

Returns
boolean

Implements IndividualAssessmentFileStorage.

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

References readDir().

46  {
47  $files = $this->readDir();
48 
49  return (count($files) == 0) ? true : false;
50  }
+ Here is the call graph for this function:

◆ readDir()

ilIndividualAssessmentFileStorage::readDir ( )

Read the dir.

Returns
string[]

Definition at line 96 of file class.ilIndividualAssessmentFileStorage.php.

References create(), and getAbsolutePath().

Referenced by deleteCurrentFile(), getFilePath(), and isEmpty().

97  {
98  if (!is_dir($this->getAbsolutePath())) {
99  $this->create();
100  }
101 
102  $fh = opendir($this->getAbsolutePath());
103  $files = array();
104  while ($file = readdir($fh)) {
105  if ($file != "." && $file != ".." && !is_dir($this->getAbsolutePath() . "/" . $file)) {
106  $files[] = $file;
107  }
108  }
109  closedir($fh);
110 
111  return $files;
112  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUserId()

ilIndividualAssessmentFileStorage::setUserId (   $user_id)

Set the user id for an extra folder of each participant in the IA.

Parameters
int$user_id

Implements IndividualAssessmentFileStorage.

Definition at line 57 of file class.ilIndividualAssessmentFileStorage.php.

58  {
59  $this->user_id = $user_id;
60  }

◆ uploadFile()

ilIndividualAssessmentFileStorage::uploadFile ( UploadResult  $result)

Upload the file.

Parameters
string[]
Returns
bool

Implements IndividualAssessmentFileStorage.

Definition at line 121 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemStorage\$path, getAbsolutePath(), ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getPath(), and ilUtil\moveUploadedFile().

122  {
123  $path = $this->getAbsolutePath();
124 
125  $clean_name = preg_replace("/[^a-zA-Z0-9\_\.\-]/", "", $result->getName());
126  $new_file = $path . "/" . $clean_name;
127 
129  $result->getPath(),
130  $clean_name, // This parameter does not do a thing
131  $new_file
132  );
133 
134  return true;
135  }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

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