ILIAS  release_8 Revision v8.24
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.

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )
protected

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

250 : bool
251 {
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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFileSize(int $a_size)
ilDBInterface $db
setFileType(string $a_type)
setFileName(string $a_name)
setSessionId(int $a_event_id)
$res
Definition: ltiservices.php:69
$query

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

Referenced by __construct().

+ 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.

220 : bool
221 {
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 }

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

◆ _readFilesByEvent()

static ilSessionFile::_readFilesByEvent ( int  $a_event_id)
static

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

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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

◆ cloneFiles()

ilSessionFile::cloneFiles ( int  $a_target_event_id)

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

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
167 $source->copyFile($this->getAbsolutePath(), $file->getAbsolutePath());
168 }
$source
Definition: metadata.php:93

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

+ Here is the call graph for this function:

◆ create()

ilSessionFile::create ( bool  $a_upload = true)

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

170 : bool
171 {
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 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

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

+ Here is the call graph for this function:

◆ delete()

ilSessionFile::delete ( )

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

206 : bool
207 {
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 }

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

+ Here is the call graph for this function:

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

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

124 : string
125 {
126 return $this->fss_storage->getAbsolutePath() . "/" . $this->getFileId();
127 }

References getFileId().

Referenced by cloneFiles(), and delete().

+ 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.

119 : int
120 {
121 return $this->error_code;
122 }

References $error_code.

Referenced by create(), and validate().

+ Here is the caller graph for this function:

◆ getFileId()

ilSessionFile::getFileId ( )

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

59 : int
60 {
61 return $this->file_id;
62 }

References $file_id.

Referenced by delete(), and getAbsolutePath().

+ Here is the caller graph for this function:

◆ getFileName()

ilSessionFile::getFileName ( )

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

79 : string
80 {
81 return $this->file_name;
82 }

References $file_name.

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getFileSize()

ilSessionFile::getFileSize ( )

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

99 : int
100 {
101 return $this->file_size;
102 }

References $file_size.

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getFileType()

ilSessionFile::getFileType ( )

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

89 : string
90 {
91 return $this->file_type;
92 }

References $file_type.

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionFile::getSessionId ( )

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

64 : int
65 {
66 return $this->event_id;
67 }

References $event_id.

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

+ Here is the caller graph for this function:

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

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

109 : string
110 {
111 return $this->tmp_name;
112 }

References $tmp_name.

Referenced by create().

+ 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.

54 : void
55 {
56 $this->file_id = $a_id;
57 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName ( string  $a_name)

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

74 : void
75 {
76 $this->file_name = $a_name;
77 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize ( int  $a_size)

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

94 : void
95 {
96 $this->file_size = $a_size;
97 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileType()

ilSessionFile::setFileType ( string  $a_type)

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

84 : void
85 {
86 $this->file_type = $a_type;
87 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setSessionId()

ilSessionFile::setSessionId ( int  $a_event_id)

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

69 : void
70 {
71 $this->event_id = $a_event_id;
72 }

Referenced by __read().

+ 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.

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 }

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

+ 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: