ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $ilErr,$ilDB,$lng;
55
56 $this->ilErr = $ilErr;
57 $this->db = $ilDB;
58 $this->lng = $lng;
59
60 $this->file_id = $a_file_id;
61 $this->__read();
62 }

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )

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

259 {
260 global $ilDB;
261
262 if(!$this->file_id)
263 {
264 return true;
265 }
266
267 // read file data
268 $query = "SELECT * FROM event_file WHERE file_id = ".$ilDB->quote($this->file_id ,'integer')."";
269 $res = $this->db->query($query);
270 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
271 {
272 $this->setFileName($row->file_name);
273 $this->setFileSize($row->file_size);
274 $this->setFileType($row->file_type);
275 $this->setSessionId($row->event_id);
276 }
277 $this->fss_storage = new ilFSStorageSession($this->getSessionId());
278 return true;
279 }
setSessionId($a_event_id)

References $ilDB, $query, $res, $row, 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 230 of file class.ilSessionFile.php.

231 {
232 global $ilDB;
233
234 // delete all event ids and delete assigned files
235 $query = "DELETE FROM event_file ".
236 "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')."";
237 $res = $ilDB->manipulate($query);
238
239 #$this->fss_storage->delete();
240 return true;
241 }

References $ilDB, $query, and $res.

◆ _readFilesByEvent()

static ilSessionFile::_readFilesByEvent (   $a_event_id)
static

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

244 {
245 global $ilDB;
246
247 $query = "SELECT * FROM event_file ".
248 "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')."";
249
250 $res = $ilDB->query($query);
251 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
252 {
253 $files[] = new ilSessionFile($row->file_id);
254 }
255 return is_array($files) ? $files : array();
256 }
$files
Definition: add-vimline.php:18

References $files, $ilDB, $query, $res, $row, 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 165 of file class.ilSessionFile.php.

166 {
167 $file = new ilSessionFile();
168 $file->setSessionId($a_target_event_id);
169 $file->setFileName($this->getFileName());
170 $file->setFileType($this->getFileType());
171 $file->setFileSize($this->getFileSize());
172 $file->create(false);
173
174 // Copy file
175 $source = new ilFSStorageSession($this->getSessionId());
176 $source->copyFile($this->getAbsolutePath(),$file->getAbsolutePath());
177 }
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

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

+ Here is the call graph for this function:

◆ create()

ilSessionFile::create (   $a_upload = true)

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

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

References $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 216 of file class.ilSessionFile.php.

217 {
218 global $ilDB;
219
220 // Delete db entry
221 $query = "DELETE FROM event_file ".
222 "WHERE file_id = ".$ilDB->quote($this->getFileId() ,'integer')." ";
223 $res = $ilDB->manipulate($query);
224
225 // Delete file
226 $this->fss_storage->deleteFile($this->getAbsolutePath());
227 return true;
228 }

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

+ Here is the call graph for this function:

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

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

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

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

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

Referenced by create(), and validate().

+ Here is the caller graph for this function:

◆ getFileId()

ilSessionFile::getFileId ( )

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

69 {
70 return $this->file_id;
71 }

References $file_id.

Referenced by delete(), and getAbsolutePath().

+ Here is the caller graph for this function:

◆ getFileName()

ilSessionFile::getFileName ( )

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

87 {
88 return $this->file_name;
89 }

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getFileSize()

ilSessionFile::getFileSize ( )

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

103 {
104 return $this->file_size;
105 }

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getFileType()

ilSessionFile::getFileType ( )

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

95 {
96 return $this->file_type;
97 }

Referenced by cloneFiles(), and create().

+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionFile::getSessionId ( )

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

74 {
75 return $this->event_id;
76 }

References $event_id.

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

+ Here is the caller graph for this function:

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

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

111 {
112 return $this->tmp_name;
113 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setErrorCode()

ilSessionFile::setErrorCode (   $a_code)

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

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

◆ setFileId()

ilSessionFile::setFileId (   $a_id)

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

65 {
66 $this->file_id = $a_id;
67 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName (   $a_name)

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

83 {
84 $this->file_name = $a_name;
85 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize (   $a_size)

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

99 {
100 $this->file_size = $a_size;
101 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileType()

ilSessionFile::setFileType (   $a_type)

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

91 {
92 $this->file_type = $a_type;
93 }
$a_type
Definition: workflow.php:93

References $a_type.

Referenced by __read().

+ Here is the caller graph for this function:

◆ setSessionId()

ilSessionFile::setSessionId (   $a_event_id)

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

78 {
79 $this->event_id = $a_event_id;
80 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setTemporaryName()

ilSessionFile::setTemporaryName (   $a_name)

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

107 {
108 $this->tmp_name = $a_name;
109 }

◆ validate()

ilSessionFile::validate ( )

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

129 {
130 switch($this->getErrorCode())
131 {
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_CANT_WRITE:
148 # $this->ilErr->appendMessage($this->lng->txt('file_upload_no_write'));
149 # break;
150
151 case UPLOAD_ERR_OK:
152 case UPLOAD_ERR_NO_FILE:
153 default:
154 return true;
155 }
156 }

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: