ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSessionFile Class Reference

class ilEvent More...

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

Public Member Functions

 ilSessionFile ($a_file_id=null)
 
 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)
 
 _readFilesByEvent ($a_event_id)
 
 __read ()
 

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.

Member Function Documentation

◆ __read()

ilSessionFile::__read ( )

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

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

Referenced by ilSessionFile().

255  {
256  global $ilDB;
257 
258  if(!$this->file_id)
259  {
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(DB_FETCHMODE_OBJECT))
267  {
268  $this->setFileName($row->file_name);
269  $this->setFileSize($row->file_size);
270  $this->setFileType($row->file_type);
271  $this->setSessionId($row->event_id);
272  }
273  $this->fss_storage = new ilFSStorageSession($this->getSessionId());
274  return true;
275  }
setSessionId($a_event_id)
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ 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 226 of file class.ilSessionFile.php.

References $ilDB, $query, and $res.

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

◆ _readFilesByEvent()

ilSessionFile::_readFilesByEvent (   $a_event_id)

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

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and ilSessionFile().

Referenced by ilObjSession\initFiles().

240  {
241  global $ilDB;
242 
243  $query = "SELECT * FROM event_file ".
244  "WHERE event_id = ".$ilDB->quote($a_event_id ,'integer')."";
245 
246  $res = $ilDB->query($query);
247  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
248  {
249  $files[] =& new ilSessionFile($row->file_id);
250  }
251  return is_array($files) ? $files : array();
252  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
ilSessionFile($a_file_id=null)
+ Here is the call graph for this function:
+ 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 161 of file class.ilSessionFile.php.

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

162  {
163  $file = new ilSessionFile();
164  $file->setSessionId($a_target_event_id);
165  $file->setFileName($this->getFileName());
166  $file->setFileType($this->getFileType());
167  $file->setFileSize($this->getFileSize());
168  $file->create(false);
169 
170  // Copy file
171  $source = new ilFSStorageSession($this->getSessionId());
172  $source->copyFile($this->getAbsolutePath(),$file->getAbsolutePath());
173  }
print $file
ilSessionFile($a_file_id=null)
+ Here is the call graph for this function:

◆ create()

ilSessionFile::create (   $a_upload = true)

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

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

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

◆ delete()

ilSessionFile::delete ( )

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

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

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

◆ getAbsolutePath()

ilSessionFile::getAbsolutePath ( )

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

References getFileId().

Referenced by cloneFiles(), and delete().

120  {
121  return $this->fss_storage->getAbsolutePath()."/".$this->getFileId();
122  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

ilSessionFile::getErrorCode ( )

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

Referenced by create(), and validate().

115  {
116  return $this->error_code;
117  }
+ Here is the caller graph for this function:

◆ getFileId()

ilSessionFile::getFileId ( )

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

References $file_id.

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

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

◆ getFileName()

ilSessionFile::getFileName ( )

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

Referenced by cloneFiles(), and create().

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

◆ getFileSize()

ilSessionFile::getFileSize ( )

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

Referenced by cloneFiles(), and create().

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

◆ getFileType()

ilSessionFile::getFileType ( )

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

Referenced by cloneFiles(), and create().

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

◆ getSessionId()

ilSessionFile::getSessionId ( )

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

References $event_id.

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

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

◆ getTemporaryName()

ilSessionFile::getTemporaryName ( )

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

Referenced by create().

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

◆ ilSessionFile()

ilSessionFile::ilSessionFile (   $a_file_id = null)

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

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

Referenced by _readFilesByEvent(), and cloneFiles().

49  {
50  global $ilErr,$ilDB,$lng;
51 
52  $this->ilErr =& $ilErr;
53  $this->db =& $ilDB;
54  $this->lng =& $lng;
55 
56  $this->file_id = $a_file_id;
57  $this->__read();
58  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setErrorCode()

ilSessionFile::setErrorCode (   $a_code)

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

111  {
112  $this->error_code = $a_code;
113  }

◆ setFileId()

ilSessionFile::setFileId (   $a_id)

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

Referenced by create().

61  {
62  $this->file_id = $a_id;
63  }
+ Here is the caller graph for this function:

◆ setFileName()

ilSessionFile::setFileName (   $a_name)

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

Referenced by __read().

79  {
80  $this->file_name = $a_name;
81  }
+ Here is the caller graph for this function:

◆ setFileSize()

ilSessionFile::setFileSize (   $a_size)

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

Referenced by __read().

95  {
96  $this->file_size = $a_size;
97  }
+ Here is the caller graph for this function:

◆ setFileType()

ilSessionFile::setFileType (   $a_type)

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

Referenced by __read().

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

◆ setSessionId()

ilSessionFile::setSessionId (   $a_event_id)

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

Referenced by __read().

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

◆ setTemporaryName()

ilSessionFile::setTemporaryName (   $a_name)

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

103  {
104  $this->tmp_name = $a_name;
105  }

◆ validate()

ilSessionFile::validate ( )

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

References getErrorCode().

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

◆ $lng

ilSessionFile::$lng

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

Referenced by ilSessionFile().

◆ $tree

ilSessionFile::$tree

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


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