ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB, $ilErr, $lng, and __read().

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  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )

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

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

Referenced by __construct().

256  {
257  global $ilDB;
258 
259  if (!$this->file_id) {
260  return true;
261  }
262 
263  // read file data
264  $query = "SELECT * FROM event_file WHERE file_id = " . $ilDB->quote($this->file_id, 'integer') . "";
265  $res = $this->db->query($query);
266  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
267  $this->setFileName($row->file_name);
268  $this->setFileSize($row->file_size);
269  $this->setFileType($row->file_type);
270  $this->setSessionId($row->event_id);
271  }
272  $this->fss_storage = new ilFSStorageSession($this->getSessionId());
273  return true;
274  }
setSessionId($a_event_id)
foreach($_POST as $key=> $value) $res
$query
+ 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 228 of file class.ilSessionFile.php.

References $ilDB, $query, and $res.

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

◆ _readFilesByEvent()

static ilSessionFile::_readFilesByEvent (   $a_event_id)
static

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

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

Referenced by ilObjSession\initFiles().

242  {
243  global $ilDB;
244 
245  $query = "SELECT * FROM event_file " .
246  "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer') . "";
247 
248  $res = $ilDB->query($query);
249  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
250  $files[] = new ilSessionFile($row->file_id);
251  }
252  return is_array($files) ? $files : array();
253  }
$files
Definition: add-vimline.php:18
class ilEvent
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ 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 164 of file class.ilSessionFile.php.

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

165  {
166  $file = new ilSessionFile();
167  $file->setSessionId($a_target_event_id);
168  $file->setFileName($this->getFileName());
169  $file->setFileType($this->getFileType());
170  $file->setFileSize($this->getFileSize());
171  $file->create(false);
172 
173  // Copy file
174  $source = new ilFSStorageSession($this->getSessionId());
175  $source->copyFile($this->getAbsolutePath(), $file->getAbsolutePath());
176  }
class ilEvent
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
$source
Definition: linkback.php:22
+ Here is the call graph for this function:

◆ create()

ilSessionFile::create (   $a_upload = true)

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

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

179  {
180  global $ilDB;
181 
182  if ($this->getErrorCode() != 0) {
183  return false;
184  }
185 
186  $next_id = $ilDB->nextId('event_file');
187  $query = "INSERT INTO event_file (file_id,event_id,file_name,file_size,file_type) " .
188  "VALUES( " .
189  $ilDB->quote($next_id, 'integer') . ", " .
190  $ilDB->quote($this->getSessionId(), 'integer') . ", " .
191  $ilDB->quote($this->getFileName(), 'text') . ", " .
192  $ilDB->quote($this->getFileSize(), 'integer') . ", " .
193  $ilDB->quote($this->getFileType(), 'text') . " " .
194  ")";
195 
196  $res = $ilDB->manipulate($query);
197  $this->setFileId($next_id);
198 
199  $this->fss_storage = new ilFSStorageSession($this->getSessionId());
200  $this->fss_storage->createDirectory();
201 
202  if ($a_upload) {
203  // now create file
204  ilUtil::moveUploadedFile(
205  $this->getTemporaryName(),
206  $this->getFileName(),
207  $this->fss_storage->getAbsolutePath() . '/' . $this->getFileId()
208  );
209  }
210 
211  return true;
212  }
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:

◆ delete()

ilSessionFile::delete ( )

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

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

215  {
216  global $ilDB;
217 
218  // Delete db entry
219  $query = "DELETE FROM event_file " .
220  "WHERE file_id = " . $ilDB->quote($this->getFileId(), 'integer') . " ";
221  $res = $ilDB->manipulate($query);
222 
223  // Delete file
224  $this->fss_storage->deleteFile($this->getAbsolutePath());
225  return true;
226  }
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

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

References getFileId().

Referenced by cloneFiles(), and delete().

124  {
125  return $this->fss_storage->getAbsolutePath() . "/" . $this->getFileId();
126  }
+ 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.

Referenced by create(), and validate().

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

◆ getFileId()

ilSessionFile::getFileId ( )

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

References $file_id.

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

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

◆ getFileName()

ilSessionFile::getFileName ( )

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

Referenced by cloneFiles(), and create().

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

◆ getFileSize()

ilSessionFile::getFileSize ( )

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

Referenced by cloneFiles(), and create().

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

◆ getFileType()

ilSessionFile::getFileType ( )

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

Referenced by cloneFiles(), and create().

95  {
96  return $this->file_type;
97  }
+ Here is the caller graph for this function:

◆ getSessionId()

ilSessionFile::getSessionId ( )

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

References $event_id.

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

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

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

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

Referenced by create().

111  {
112  return $this->tmp_name;
113  }
+ 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.

Referenced by create().

65  {
66  $this->file_id = $a_id;
67  }
+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName (   $a_name)

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

Referenced by __read().

83  {
84  $this->file_name = $a_name;
85  }
+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize (   $a_size)

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

Referenced by __read().

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

◆ setFileType()

ilSessionFile::setFileType (   $a_type)

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

References $a_type.

Referenced by __read().

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

◆ setSessionId()

ilSessionFile::setSessionId (   $a_event_id)

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

Referenced by __read().

78  {
79  $this->event_id = $a_event_id;
80  }
+ 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.

References getErrorCode().

129  {
130  switch ($this->getErrorCode()) {
131  case UPLOAD_ERR_INI_SIZE:
132  $this->ilErr->appendMessage($this->lng->txt('file_upload_ini_size'));
133  break;
134  case UPLOAD_ERR_FORM_SIZE:
135  $this->ilErr->appendMessage($this->lng->txt('file_upload_form_size'));
136  break;
137 
138  case UPLOAD_ERR_PARTIAL:
139  $this->ilErr->appendMessage($this->lng->txt('file_upload_only_partial'));
140  break;
141 
142  case UPLOAD_ERR_NO_TMP_DIR:
143  $this->ilErr->appendMessage($this->lng->txt('file_upload_no_tmp_dir'));
144  break;
145 
146  #case UPLOAD_ERR_CANT_WRITE:
147  # $this->ilErr->appendMessage($this->lng->txt('file_upload_no_write'));
148  # break;
149 
150  case UPLOAD_ERR_OK:
151  case UPLOAD_ERR_NO_FILE:
152  default:
153  return true;
154  }
155  }
+ 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: