ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

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  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )

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

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

Referenced by __construct().

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)
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
+ 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.

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query

◆ _readFilesByEvent()

static ilSessionFile::_readFilesByEvent (   $a_event_id)
static

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

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

Referenced by ilObjSession\initFiles().

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  }
$files
Definition: metarefresh.php:49
global $DIC
Definition: saml.php:7
class ilEvent
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the caller graph for this function:

◆ cloneFiles()

ilSessionFile::cloneFiles (   $a_target_event_id)

Clone files.

public

Parameters
intnew event_id

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

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

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
178  $source = new ilFSStorageSession($this->getSessionId());
179  $source->copyFile($this->getAbsolutePath(), $file->getAbsolutePath());
180  }
class ilEvent
$source
Definition: linkback.php:22
+ Here is the call graph for this function:

◆ create()

ilSessionFile::create (   $a_upload = true)

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

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

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
210  ilUtil::moveUploadedFile(
211  $this->getTemporaryName(),
212  $this->getFileName(),
213  $this->fss_storage->getAbsolutePath() . '/' . $this->getFileId()
214  );
215  }
216 
217  return true;
218  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:

◆ delete()

ilSessionFile::delete ( )

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

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

References getFileId().

Referenced by cloneFiles(), and delete().

128  {
129  return $this->fss_storage->getAbsolutePath() . "/" . $this->getFileId();
130  }
+ 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.

Referenced by create(), and validate().

123  {
124  return $this->error_code;
125  }
+ Here is the caller graph for this function:

◆ getFileId()

ilSessionFile::getFileId ( )

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

References $file_id.

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

73  {
74  return $this->file_id;
75  }
+ Here is the caller graph for this function:

◆ getFileName()

ilSessionFile::getFileName ( )

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

Referenced by cloneFiles(), and create().

91  {
92  return $this->file_name;
93  }
+ Here is the caller graph for this function:

◆ getFileSize()

ilSessionFile::getFileSize ( )

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

Referenced by cloneFiles(), and create().

107  {
108  return $this->file_size;
109  }
+ Here is the caller graph for this function:

◆ getFileType()

ilSessionFile::getFileType ( )

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

Referenced by cloneFiles(), and create().

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

◆ getSessionId()

ilSessionFile::getSessionId ( )

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

References $event_id.

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

78  {
79  return $this->event_id;
80  }
+ Here is the caller graph for this function:

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

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

Referenced by create().

115  {
116  return $this->tmp_name;
117  }
+ 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.

Referenced by create().

69  {
70  $this->file_id = $a_id;
71  }
+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName (   $a_name)

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

Referenced by __read().

87  {
88  $this->file_name = $a_name;
89  }
+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize (   $a_size)

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

Referenced by __read().

103  {
104  $this->file_size = $a_size;
105  }
+ Here is the caller graph for this function:

◆ setFileType()

ilSessionFile::setFileType (   $a_type)

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

References $a_type.

Referenced by __read().

95  {
96  $this->file_type = $a_type;
97  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ setSessionId()

ilSessionFile::setSessionId (   $a_event_id)

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

Referenced by __read().

82  {
83  $this->event_id = $a_event_id;
84  }
+ 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.

References getErrorCode().

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