ILIAS  release_8 Revision v8.23
ilSessionFile 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 ilSessionFile:

Public Member Functions

 __construct (int $a_file_id=0)
 
 setFileId (int $a_id)
 
 getFileId ()
 
 getSessionId ()
 
 setSessionId (int $a_event_id)
 
 setFileName (string $a_name)
 
 getFileName ()
 
 setFileType (string $a_type)
 
 getFileType ()
 
 setFileSize (int $a_size)
 
 getFileSize ()
 
 setTemporaryName (string $a_name)
 
 getTemporaryName ()
 
 setErrorCode (int $a_code)
 
 getErrorCode ()
 
 getAbsolutePath ()
 
 validate ()
 
 cloneFiles (int $a_target_event_id)
 
 create (bool $a_upload=true)
 
 delete ()
 
 _deleteByEvent (int $a_event_id)
 

Static Public Member Functions

static _readFilesByEvent (int $a_event_id)
 

Protected Member Functions

 __read ()
 

Protected Attributes

ilErrorHandling $ilErr
 
ilDBInterface $db
 
ilLanguage $lng
 
int $event_id = 0
 
int $file_id = 0
 
string $file_name = ""
 
string $file_type = ""
 
int $file_size = 0
 
string $tmp_name = ""
 
int $error_code = 0
 
ilFSStorageSession $fss_storage
 

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 class ilSessionFile

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 28 of file class.ilSessionFile.php.

Constructor & Destructor Documentation

◆ __construct()

ilSessionFile::__construct ( int  $a_file_id = 0)

Definition at line 42 of file class.ilSessionFile.php.

References $DIC, __read(), and ILIAS\Repository\lng().

43  {
44  global $DIC;
45 
46  $this->ilErr = $DIC['ilErr'];
47  $this->db = $DIC->database();
48  $this->lng = $DIC->language();
49 
50  $this->file_id = $a_file_id;
51  $this->__read();
52  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )
protected

Definition at line 250 of file class.ilSessionFile.php.

References $db, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, getSessionId(), setFileName(), setFileSize(), setFileType(), and setSessionId().

Referenced by __construct().

250  : bool
251  {
252  $ilDB = $this->db;
253 
254  if (!$this->file_id) {
255  return true;
256  }
257 
258  // read file data
259  $query = "SELECT * FROM event_file WHERE file_id = " . $ilDB->quote($this->file_id, 'integer');
260  $res = $this->db->query($query);
261  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
262  $this->setFileName($row->file_name);
263  $this->setFileSize($row->file_size);
264  $this->setFileType($row->file_type);
265  $this->setSessionId($row->event_id);
266  }
267  $this->fss_storage = new ilFSStorageSession($this->getSessionId());
268  return true;
269  }
$res
Definition: ltiservices.php:69
setFileSize(int $a_size)
setSessionId(int $a_event_id)
$query
setFileName(string $a_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilDBInterface $db
setFileType(string $a_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteByEvent()

ilSessionFile::_deleteByEvent ( int  $a_event_id)

Definition at line 220 of file class.ilSessionFile.php.

References $db, $ilDB, $query, and $res.

220  : bool
221  {
222  $ilDB = $this->db;
223 
224  // delete all event ids and delete assigned files
225  $query = "DELETE FROM event_file " .
226  "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer');
227  $res = $ilDB->manipulate($query);
228 
229  #$this->fss_storage->delete();
230  return true;
231  }
$res
Definition: ltiservices.php:69
$query
ilDBInterface $db

◆ _readFilesByEvent()

static ilSessionFile::_readFilesByEvent ( int  $a_event_id)
static

Definition at line 233 of file class.ilSessionFile.php.

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

233  : array
234  {
235  global $DIC;
236 
237  $ilDB = $DIC->database();
238 
239  $query = "SELECT * FROM event_file " .
240  "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer');
241 
242  $res = $ilDB->query($query);
243  $files = [];
244  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
245  $files[] = new ilSessionFile($row->file_id);
246  }
247  return $files;
248  }
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$query

◆ cloneFiles()

ilSessionFile::cloneFiles ( int  $a_target_event_id)

Definition at line 156 of file class.ilSessionFile.php.

References $source, getAbsolutePath(), getFileName(), getFileSize(), getFileType(), and getSessionId().

156  : void
157  {
158  $file = new ilSessionFile();
159  $file->setSessionId($a_target_event_id);
160  $file->setFileName($this->getFileName());
161  $file->setFileType($this->getFileType());
162  $file->setFileSize($this->getFileSize());
163  $file->create(false);
164 
165  // Copy file
166  $source = new ilFSStorageSession($this->getSessionId());
167  $source->copyFile($this->getAbsolutePath(), $file->getAbsolutePath());
168  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$source
Definition: metadata.php:93
+ Here is the call graph for this function:

◆ create()

ilSessionFile::create ( bool  $a_upload = true)

Definition at line 170 of file class.ilSessionFile.php.

References $db, $ilDB, $query, $res, getErrorCode(), getFileId(), getFileName(), getFileSize(), getFileType(), getSessionId(), getTemporaryName(), ilFileUtils\moveUploadedFile(), and setFileId().

170  : bool
171  {
172  $ilDB = $this->db;
173 
174  if ($this->getErrorCode() != 0) {
175  return false;
176  }
177 
178  $next_id = $ilDB->nextId('event_file');
179  $query = "INSERT INTO event_file (file_id,event_id,file_name,file_size,file_type) " .
180  "VALUES( " .
181  $ilDB->quote($next_id, 'integer') . ", " .
182  $ilDB->quote($this->getSessionId(), 'integer') . ", " .
183  $ilDB->quote($this->getFileName(), 'text') . ", " .
184  $ilDB->quote($this->getFileSize(), 'integer') . ", " .
185  $ilDB->quote($this->getFileType(), 'text') . " " .
186  ")";
187 
188  $res = $ilDB->manipulate($query);
189  $this->setFileId($next_id);
190 
191  $this->fss_storage = new ilFSStorageSession($this->getSessionId());
192  $this->fss_storage->createDirectory();
193 
194  if ($a_upload) {
195  // now create file
197  $this->getTemporaryName(),
198  $this->getFileName(),
199  $this->fss_storage->getAbsolutePath() . '/' . $this->getFileId()
200  );
201  }
202 
203  return true;
204  }
$res
Definition: ltiservices.php:69
$query
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilDBInterface $db
+ Here is the call graph for this function:

◆ delete()

ilSessionFile::delete ( )

Definition at line 206 of file class.ilSessionFile.php.

References $db, $ilDB, $query, $res, getAbsolutePath(), and getFileId().

206  : bool
207  {
208  $ilDB = $this->db;
209 
210  // Delete db entry
211  $query = "DELETE FROM event_file " .
212  "WHERE file_id = " . $ilDB->quote($this->getFileId(), 'integer') . " ";
213  $res = $ilDB->manipulate($query);
214 
215  // Delete file
216  $this->fss_storage->deleteFile($this->getAbsolutePath());
217  return true;
218  }
$res
Definition: ltiservices.php:69
$query
ilDBInterface $db
+ Here is the call graph for this function:

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

Definition at line 124 of file class.ilSessionFile.php.

References getFileId().

Referenced by cloneFiles(), and delete().

124  : string
125  {
126  return $this->fss_storage->getAbsolutePath() . "/" . $this->getFileId();
127  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

ilSessionFile::getErrorCode ( )

Definition at line 119 of file class.ilSessionFile.php.

References $error_code.

Referenced by create(), and validate().

119  : int
120  {
121  return $this->error_code;
122  }
+ Here is the caller graph for this function:

◆ getFileId()

ilSessionFile::getFileId ( )

Definition at line 59 of file class.ilSessionFile.php.

References $file_id.

Referenced by create(), delete(), and getAbsolutePath().

59  : int
60  {
61  return $this->file_id;
62  }
+ Here is the caller graph for this function:

◆ getFileName()

ilSessionFile::getFileName ( )

Definition at line 79 of file class.ilSessionFile.php.

References $file_name.

Referenced by cloneFiles(), and create().

79  : string
80  {
81  return $this->file_name;
82  }
+ Here is the caller graph for this function:

◆ getFileSize()

ilSessionFile::getFileSize ( )

Definition at line 99 of file class.ilSessionFile.php.

References $file_size.

Referenced by cloneFiles(), and create().

99  : int
100  {
101  return $this->file_size;
102  }
+ Here is the caller graph for this function:

◆ getFileType()

ilSessionFile::getFileType ( )

Definition at line 89 of file class.ilSessionFile.php.

References $file_type.

Referenced by cloneFiles(), and create().

89  : string
90  {
91  return $this->file_type;
92  }
+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionFile::getSessionId ( )

Definition at line 64 of file class.ilSessionFile.php.

References $event_id.

Referenced by __read(), cloneFiles(), and create().

64  : int
65  {
66  return $this->event_id;
67  }
+ Here is the caller graph for this function:

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

Definition at line 109 of file class.ilSessionFile.php.

References $tmp_name.

Referenced by create().

109  : string
110  {
111  return $this->tmp_name;
112  }
+ Here is the caller graph for this function:

◆ setErrorCode()

ilSessionFile::setErrorCode ( int  $a_code)

Definition at line 114 of file class.ilSessionFile.php.

114  : void
115  {
116  $this->error_code = $a_code;
117  }

◆ setFileId()

ilSessionFile::setFileId ( int  $a_id)

Definition at line 54 of file class.ilSessionFile.php.

Referenced by create().

54  : void
55  {
56  $this->file_id = $a_id;
57  }
+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName ( string  $a_name)

Definition at line 74 of file class.ilSessionFile.php.

Referenced by __read().

74  : void
75  {
76  $this->file_name = $a_name;
77  }
+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize ( int  $a_size)

Definition at line 94 of file class.ilSessionFile.php.

Referenced by __read().

94  : void
95  {
96  $this->file_size = $a_size;
97  }
+ Here is the caller graph for this function:

◆ setFileType()

ilSessionFile::setFileType ( string  $a_type)

Definition at line 84 of file class.ilSessionFile.php.

Referenced by __read().

84  : void
85  {
86  $this->file_type = $a_type;
87  }
+ Here is the caller graph for this function:

◆ setSessionId()

ilSessionFile::setSessionId ( int  $a_event_id)

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

Referenced by __read().

69  : void
70  {
71  $this->event_id = $a_event_id;
72  }
+ Here is the caller graph for this function:

◆ setTemporaryName()

ilSessionFile::setTemporaryName ( string  $a_name)

Definition at line 104 of file class.ilSessionFile.php.

104  : void
105  {
106  $this->tmp_name = $a_name;
107  }

◆ validate()

ilSessionFile::validate ( )

Definition at line 129 of file class.ilSessionFile.php.

References getErrorCode(), and ILIAS\Repository\lng().

129  : bool
130  {
131  switch ($this->getErrorCode()) {
132  case UPLOAD_ERR_INI_SIZE:
133  $this->ilErr->appendMessage($this->lng->txt('file_upload_ini_size'));
134  break;
135  case UPLOAD_ERR_FORM_SIZE:
136  $this->ilErr->appendMessage($this->lng->txt('file_upload_form_size'));
137  break;
138 
139  case UPLOAD_ERR_PARTIAL:
140  $this->ilErr->appendMessage($this->lng->txt('file_upload_only_partial'));
141  break;
142 
143  case UPLOAD_ERR_NO_TMP_DIR:
144  $this->ilErr->appendMessage($this->lng->txt('file_upload_no_tmp_dir'));
145  break;
146 
147  case UPLOAD_ERR_OK:
148  case UPLOAD_ERR_NO_FILE:
149  default:
150  return true;
151  }
152 
153  return false;
154  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilSessionFile::$db
protected

Definition at line 31 of file class.ilSessionFile.php.

Referenced by __read(), _deleteByEvent(), create(), and delete().

◆ $error_code

int ilSessionFile::$error_code = 0
protected

Definition at line 39 of file class.ilSessionFile.php.

Referenced by getErrorCode().

◆ $event_id

int ilSessionFile::$event_id = 0
protected

Definition at line 33 of file class.ilSessionFile.php.

Referenced by getSessionId().

◆ $file_id

int ilSessionFile::$file_id = 0
protected

Definition at line 34 of file class.ilSessionFile.php.

Referenced by getFileId().

◆ $file_name

string ilSessionFile::$file_name = ""
protected

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

Referenced by getFileName().

◆ $file_size

int ilSessionFile::$file_size = 0
protected

Definition at line 37 of file class.ilSessionFile.php.

Referenced by getFileSize().

◆ $file_type

string ilSessionFile::$file_type = ""
protected

Definition at line 36 of file class.ilSessionFile.php.

Referenced by getFileType().

◆ $fss_storage

ilFSStorageSession ilSessionFile::$fss_storage
protected

Definition at line 40 of file class.ilSessionFile.php.

◆ $ilErr

ilErrorHandling ilSessionFile::$ilErr
protected

Definition at line 30 of file class.ilSessionFile.php.

◆ $lng

ilLanguage ilSessionFile::$lng
protected

Definition at line 32 of file class.ilSessionFile.php.

◆ $tmp_name

string ilSessionFile::$tmp_name = ""
protected

Definition at line 38 of file class.ilSessionFile.php.

Referenced by getTemporaryName().


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