ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSessionFile Class Reference

class ilEvent More...

+ Inheritance diagram for ilSessionFile:
+ Collaboration diagram for ilSessionFile:

Public Member Functions

 __construct ($a_file_id=null)
 Constructor. More...
 
 setFileId ($a_id)
 
 getFileId ()
 
 getSessionId ()
 
 setSessionId ($a_event_id)
 
 setFileName ($a_name)
 
 getFileName ()
 
 setFileType ($a_type)
 
 getFileType ()
 
 setFileSize ($a_size)
 
 getFileSize ()
 
 setTemporaryName ($a_name)
 
 getTemporaryName ()
 
 setErrorCode ($a_code)
 
 getErrorCode ()
 
 getAbsolutePath ()
 
 validate ()
 
 cloneFiles ($a_target_event_id)
 Clone files. More...
 
 create ($a_upload=true)
 
 delete ()
 
 _deleteByEvent ($a_event_id)
 
 __read ()
 

Static Public Member Functions

static _readFilesByEvent ($a_event_id)
 

Data Fields

 $ilErr
 
 $ilDB
 
 $tree
 
 $lng
 
 $event_id = null
 
 $file_id = null
 

Private Attributes

 $fss_storage = null
 

Detailed Description

class ilEvent

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSessionFile::__construct (   $a_file_id = null)

Constructor.

Parameters
int$a_file_id

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

53 {
54 global $DIC;
55
56 $ilErr = $DIC['ilErr'];
57 $ilDB = $DIC['ilDB'];
58 $lng = $DIC['lng'];
59
60 $this->ilErr = $ilErr;
61 $this->db = $ilDB;
62 $this->lng = $lng;
63
64 $this->file_id = $a_file_id;
65 $this->__read();
66 }
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, $ilErr, $lng, and __read().

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )

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

268 {
269 global $DIC;
270
271 $ilDB = $DIC['ilDB'];
272
273 if (!$this->file_id) {
274 return true;
275 }
276
277 // read file data
278 $query = "SELECT * FROM event_file WHERE file_id = " . $ilDB->quote($this->file_id, 'integer') . "";
279 $res = $this->db->query($query);
280 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
281 $this->setFileName($row->file_name);
282 $this->setFileSize($row->file_size);
283 $this->setFileType($row->file_type);
284 $this->setSessionId($row->event_id);
285 }
286 $this->fss_storage = new ilFSStorageSession($this->getSessionId());
287 return true;
288 }
setSessionId($a_event_id)
$query
foreach($_POST as $key=> $value) $res

References $DIC, $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 (   $a_event_id)

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

237 {
238 global $DIC;
239
240 $ilDB = $DIC['ilDB'];
241
242 // delete all event ids and delete assigned files
243 $query = "DELETE FROM event_file " .
244 "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer') . "";
245 $res = $ilDB->manipulate($query);
246
247 #$this->fss_storage->delete();
248 return true;
249 }

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

◆ _readFilesByEvent()

static ilSessionFile::_readFilesByEvent (   $a_event_id)
static

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

252 {
253 global $DIC;
254
255 $ilDB = $DIC['ilDB'];
256
257 $query = "SELECT * FROM event_file " .
258 "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer') . "";
259
260 $res = $ilDB->query($query);
261 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
262 $files[] = new ilSessionFile($row->file_id);
263 }
264 return is_array($files) ? $files : array();
265 }

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

Referenced by ilObjSession\initFiles().

+ Here is the caller graph for this function:

◆ cloneFiles()

ilSessionFile::cloneFiles (   $a_target_event_id)

Clone files.

@access public

Parameters
intnew event_id

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

169 {
170 $file = new ilSessionFile();
171 $file->setSessionId($a_target_event_id);
172 $file->setFileName($this->getFileName());
173 $file->setFileType($this->getFileType());
174 $file->setFileSize($this->getFileSize());
175 $file->create(false);
176
177 // Copy file
179 $source->copyFile($this->getAbsolutePath(), $file->getAbsolutePath());
180 }
$source
Definition: metadata.php:76

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

+ Here is the call graph for this function:

◆ create()

ilSessionFile::create (   $a_upload = true)

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

183 {
184 global $DIC;
185
186 $ilDB = $DIC['ilDB'];
187
188 if ($this->getErrorCode() != 0) {
189 return false;
190 }
191
192 $next_id = $ilDB->nextId('event_file');
193 $query = "INSERT INTO event_file (file_id,event_id,file_name,file_size,file_type) " .
194 "VALUES( " .
195 $ilDB->quote($next_id, 'integer') . ", " .
196 $ilDB->quote($this->getSessionId(), 'integer') . ", " .
197 $ilDB->quote($this->getFileName(), 'text') . ", " .
198 $ilDB->quote($this->getFileSize(), 'integer') . ", " .
199 $ilDB->quote($this->getFileType(), 'text') . " " .
200 ")";
201
202 $res = $ilDB->manipulate($query);
203 $this->setFileId($next_id);
204
205 $this->fss_storage = new ilFSStorageSession($this->getSessionId());
206 $this->fss_storage->createDirectory();
207
208 if ($a_upload) {
209 // now create file
211 $this->getTemporaryName(),
212 $this->getFileName(),
213 $this->fss_storage->getAbsolutePath() . '/' . $this->getFileId()
214 );
215 }
216
217 return true;
218 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

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

+ Here is the call graph for this function:

◆ delete()

ilSessionFile::delete ( )

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

221 {
222 global $DIC;
223
224 $ilDB = $DIC['ilDB'];
225
226 // Delete db entry
227 $query = "DELETE FROM event_file " .
228 "WHERE file_id = " . $ilDB->quote($this->getFileId(), 'integer') . " ";
229 $res = $ilDB->manipulate($query);
230
231 // Delete file
232 $this->fss_storage->deleteFile($this->getAbsolutePath());
233 return true;
234 }

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

+ Here is the call graph for this function:

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

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

128 {
129 return $this->fss_storage->getAbsolutePath() . "/" . $this->getFileId();
130 }

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 122 of file class.ilSessionFile.php.

123 {
124 return $this->error_code;
125 }

Referenced by create(), and validate().

+ Here is the caller graph for this function:

◆ getFileId()

ilSessionFile::getFileId ( )

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

73 {
74 return $this->file_id;
75 }

References $file_id.

Referenced by delete(), and getAbsolutePath().

+ Here is the caller graph for this function:

◆ getFileName()

ilSessionFile::getFileName ( )

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

91 {
92 return $this->file_name;
93 }

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getFileSize()

ilSessionFile::getFileSize ( )

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

107 {
108 return $this->file_size;
109 }

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getFileType()

ilSessionFile::getFileType ( )

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

99 {
100 return $this->file_type;
101 }

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionFile::getSessionId ( )

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

78 {
79 return $this->event_id;
80 }

References $event_id.

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

+ Here is the caller graph for this function:

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

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

115 {
116 return $this->tmp_name;
117 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setErrorCode()

ilSessionFile::setErrorCode (   $a_code)

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

119 {
120 $this->error_code = $a_code;
121 }

◆ setFileId()

ilSessionFile::setFileId (   $a_id)

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

69 {
70 $this->file_id = $a_id;
71 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName (   $a_name)

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

87 {
88 $this->file_name = $a_name;
89 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize (   $a_size)

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

103 {
104 $this->file_size = $a_size;
105 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileType()

ilSessionFile::setFileType (   $a_type)

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

95 {
96 $this->file_type = $a_type;
97 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by __read().

+ Here is the caller graph for this function:

◆ setSessionId()

ilSessionFile::setSessionId (   $a_event_id)

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

82 {
83 $this->event_id = $a_event_id;
84 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setTemporaryName()

ilSessionFile::setTemporaryName (   $a_name)

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

111 {
112 $this->tmp_name = $a_name;
113 }

◆ validate()

ilSessionFile::validate ( )

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

133 {
134 switch ($this->getErrorCode()) {
135 case UPLOAD_ERR_INI_SIZE:
136 $this->ilErr->appendMessage($this->lng->txt('file_upload_ini_size'));
137 break;
138 case UPLOAD_ERR_FORM_SIZE:
139 $this->ilErr->appendMessage($this->lng->txt('file_upload_form_size'));
140 break;
141
142 case UPLOAD_ERR_PARTIAL:
143 $this->ilErr->appendMessage($this->lng->txt('file_upload_only_partial'));
144 break;
145
146 case UPLOAD_ERR_NO_TMP_DIR:
147 $this->ilErr->appendMessage($this->lng->txt('file_upload_no_tmp_dir'));
148 break;
149
150 #case UPLOAD_ERR_CANT_WRITE:
151 # $this->ilErr->appendMessage($this->lng->txt('file_upload_no_write'));
152 # break;
153
154 case UPLOAD_ERR_OK:
155 case UPLOAD_ERR_NO_FILE:
156 default:
157 return true;
158 }
159 }

References getErrorCode().

+ Here is the call graph for this function:

Field Documentation

◆ $event_id

ilSessionFile::$event_id = null

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

Referenced by getSessionId().

◆ $file_id

ilSessionFile::$file_id = null

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

Referenced by getFileId().

◆ $fss_storage

ilSessionFile::$fss_storage = null
private

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

◆ $ilDB

ilSessionFile::$ilDB

◆ $ilErr

ilSessionFile::$ilErr

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

Referenced by __construct().

◆ $lng

ilSessionFile::$lng

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

Referenced by __construct().

◆ $tree

ilSessionFile::$tree

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


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