ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCourseFile Class Reference
+ Inheritance diagram for ilCourseFile:
+ Collaboration diagram for ilCourseFile:

Public Member Functions

 __construct ($a_file_id=null)
 Constructor. More...
 
 setFileId ($a_id)
 
 getFileId ()
 
 getCourseId ()
 
 setCourseId ($a_course_id)
 
 setFileName ($a_name)
 
 getFileName ()
 
 setFileType ($a_type)
 
 getFileType ()
 
 setFileSize ($a_size)
 
 getFileSize ()
 
 setTemporaryName ($a_name)
 
 getTemporaryName ()
 
 setErrorCode ($a_code)
 
 getErrorCode ()
 
 getAbsolutePath ()
 
 validate ()
 
 create ($a_upload=true)
 
 delete ()
 
 __read ()
 

Static Public Member Functions

static _cloneFiles ($a_source_id, $a_target_id)
 Clone course files. More...
 
static _deleteByCourse ($a_course_id)
 
static _readFilesByCourse ($a_course_id)
 

Data Fields

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

Private Attributes

 $fss_storage = null
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 35 of file class.ilCourseFile.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseFile::__construct (   $a_file_id = null)

Constructor.

Parameters
int$a_file_id

Definition at line 51 of file class.ilCourseFile.php.

52 {
53 global $ilErr,$ilDB,$lng;
54
55 $this->ilErr = $ilErr;
56 $this->db = $ilDB;
57 $this->lng = $lng;
58
59 $this->file_id = $a_file_id;
60 $this->__read();
61 }

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilCourseFile::__read ( )

Definition at line 275 of file class.ilCourseFile.php.

276 {
277 global $ilDB;
278
279 if(!$this->file_id)
280 {
281 return true;
282 }
283
284 // read file data
285 $query = "SELECT * FROM crs_file WHERE file_id = ".$ilDB->quote($this->file_id,'integer');
286 $res = $this->db->query($query);
287 while($row = $ilDB->fetchObject($res))
288 {
289 $this->setFileName($row->file_name);
290 $this->setFileSize($row->file_size);
291 $this->setFileType($row->file_type);
292 $this->setCourseId($row->course_id);
293 }
294 $this->fss_storage = new ilFSStorageCourse($this->getCourseId());
295 return true;
296 }
setCourseId($a_course_id)

References $ilDB, $query, $res, $row, getCourseId(), setCourseId(), setFileName(), setFileSize(), and setFileType().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _cloneFiles()

static ilCourseFile::_cloneFiles (   $a_source_id,
  $a_target_id 
)
static

Clone course files.

@access public

Parameters
intsource id
inttarget_id

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

73 {
74 $source = new ilFSStorageCourse($a_source_id);
75
76 foreach(ilCourseFile::_readFilesByCourse($a_source_id) as $file_obj)
77 {
78 $new_file = new ilCourseFile();
79 $new_file->setCourseId($a_target_id);
80 $new_file->setFileName($file_obj->getFileName());
81 $new_file->setFileSize($file_obj->getFileSize());
82 $new_file->setFileType($file_obj->getFileType());
83 $new_file->create(false);
84
85 $target = new ilFSStorageCourse($a_target_id);
86 $target->initInfoDirectory();
87 $source->copyFile($file_obj->getAbsolutePath(),$new_file->getAbsolutePath());
88 }
89 }
static _readFilesByCourse($a_course_id)

References $target, and _readFilesByCourse().

Referenced by ilObjCourse\cloneObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteByCourse()

static ilCourseFile::_deleteByCourse (   $a_course_id)
static

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

244 {
245 global $ilDB;
246
247 // delete all course ids and delete assigned files
248 $query = "DELETE FROM crs_file ".
249 "WHERE course_id = ".$ilDB->quote($a_course_id,'integer')."";
250 $res = $ilDB->manipulate($query);
251
252 return true;
253 }

References $ilDB, $query, and $res.

Referenced by ilObjCourse\delete().

+ Here is the caller graph for this function:

◆ _readFilesByCourse()

static ilCourseFile::_readFilesByCourse (   $a_course_id)
static
Parameters
int$a_course_idobj_id of course
Returns
ilCourseFile[]

Definition at line 260 of file class.ilCourseFile.php.

261 {
262 global $ilDB;
263
264 $query = "SELECT * FROM crs_file ".
265 "WHERE course_id = ".$ilDB->quote($a_course_id,'integer')."";
266
267 $res = $ilDB->query($query);
268 while($row = $ilDB->fetchObject($res))
269 {
270 $files[] = new ilCourseFile($row->file_id);
271 }
272 return is_array($files) ? $files : array();
273 }
$files
Definition: add-vimline.php:18

References $files, $ilDB, $query, $res, and $row.

Referenced by _cloneFiles(), ilObjCourseGUI\editInfoObject(), and ilObjCourseGUI\infoScreen().

+ Here is the caller graph for this function:

◆ create()

ilCourseFile::create (   $a_upload = true)

Definition at line 190 of file class.ilCourseFile.php.

191 {
192 global $ilDB;
193
194 if($this->getErrorCode() != 0)
195 {
196 return false;
197 }
198
199 $next_id = $ilDB->nextId('crs_file');
200 $query = "INSERT INTO crs_file (file_id,course_id,file_name,file_size,file_type) ".
201 "VALUES( ".
202 $ilDB->quote($next_id,'integer').", ".
203 $ilDB->quote($this->getCourseId(),'integer').", ".
204 $ilDB->quote($this->getFileName(),'text').", ".
205 $ilDB->quote($this->getFileSize(),'integer').", ".
206 $ilDB->quote($this->getFileType(),'text')." ".
207 ")";
208 $res = $ilDB->manipulate($query);
209 $this->setFileId($next_id);
210
211 $this->fss_storage = new ilFSStorageCourse($this->getCourseId());
212 $this->fss_storage->initInfoDirectory();
213
214 if($a_upload)
215 {
216 // now create file
218 $this->getFileName(),
219 $this->fss_storage->getInfoDirectory().'/'.$this->getFileId());
220
221 }
222 return true;
223 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

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

+ Here is the call graph for this function:

◆ delete()

ilCourseFile::delete ( )

Definition at line 225 of file class.ilCourseFile.php.

226 {
227 global $ilDB;
228
229 // Delete db entry
230 $query = "DELETE FROM crs_file ".
231 "WHERE file_id = ".$ilDB->quote($this->getFileId(),'integer')."";
232 $res = $ilDB->manipulate($query);
233
234 // Delete file
235 if(file_exists($this->getAbsolutePath()))
236 {
237 unlink($this->getAbsolutePath());
238 }
239
240 return true;
241 }

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

+ Here is the call graph for this function:

◆ getAbsolutePath()

ilCourseFile::getAbsolutePath ( )

Definition at line 150 of file class.ilCourseFile.php.

151 {
152 if(is_object($this->fss_storage))
153 {
154 return $this->fss_storage->getInfoDirectory().'/'.$this->getFileId();
155 }
156 return false;
157 }

References getFileId().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCourseId()

ilCourseFile::getCourseId ( )

Definition at line 100 of file class.ilCourseFile.php.

101 {
102 return $this->course_id;
103 }

References $course_id.

Referenced by __read(), and create().

+ Here is the caller graph for this function:

◆ getErrorCode()

ilCourseFile::getErrorCode ( )

Definition at line 145 of file class.ilCourseFile.php.

146 {
147 return $this->error_code;
148 }

Referenced by create(), and validate().

+ Here is the caller graph for this function:

◆ getFileId()

ilCourseFile::getFileId ( )

Definition at line 95 of file class.ilCourseFile.php.

96 {
97 return $this->file_id;
98 }

References $file_id.

Referenced by delete(), and getAbsolutePath().

+ Here is the caller graph for this function:

◆ getFileName()

ilCourseFile::getFileName ( )

Definition at line 113 of file class.ilCourseFile.php.

114 {
115 return $this->file_name;
116 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getFileSize()

ilCourseFile::getFileSize ( )

Definition at line 129 of file class.ilCourseFile.php.

130 {
131 return $this->file_size;
132 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getFileType()

ilCourseFile::getFileType ( )

Definition at line 121 of file class.ilCourseFile.php.

122 {
123 return $this->file_type;
124 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getTemporaryName()

ilCourseFile::getTemporaryName ( )

Definition at line 137 of file class.ilCourseFile.php.

138 {
139 return $this->tmp_name;
140 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setCourseId()

ilCourseFile::setCourseId (   $a_course_id)

Definition at line 104 of file class.ilCourseFile.php.

105 {
106 $this->course_id = $a_course_id;
107 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setErrorCode()

ilCourseFile::setErrorCode (   $a_code)

Definition at line 141 of file class.ilCourseFile.php.

142 {
143 $this->error_code = $a_code;
144 }

◆ setFileId()

ilCourseFile::setFileId (   $a_id)

Definition at line 91 of file class.ilCourseFile.php.

92 {
93 $this->file_id = $a_id;
94 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setFileName()

ilCourseFile::setFileName (   $a_name)

Definition at line 109 of file class.ilCourseFile.php.

110 {
111 $this->file_name = $a_name;
112 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileSize()

ilCourseFile::setFileSize (   $a_size)

Definition at line 125 of file class.ilCourseFile.php.

126 {
127 $this->file_size = $a_size;
128 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileType()

ilCourseFile::setFileType (   $a_type)

Definition at line 117 of file class.ilCourseFile.php.

118 {
119 $this->file_type = $a_type;
120 }
$a_type
Definition: workflow.php:93

References $a_type.

Referenced by __read().

+ Here is the caller graph for this function:

◆ setTemporaryName()

ilCourseFile::setTemporaryName (   $a_name)

Definition at line 133 of file class.ilCourseFile.php.

134 {
135 $this->tmp_name = $a_name;
136 }

◆ validate()

ilCourseFile::validate ( )

Definition at line 159 of file class.ilCourseFile.php.

160 {
161 switch($this->getErrorCode())
162 {
163 case UPLOAD_ERR_INI_SIZE:
164 $this->ilErr->appendMessage($this->lng->txt('file_upload_ini_size'));
165 break;
166 case UPLOAD_ERR_FORM_SIZE:
167 $this->ilErr->appendMessage($this->lng->txt('file_upload_form_size'));
168 break;
169
170 case UPLOAD_ERR_PARTIAL:
171 $this->ilErr->appendMessage($this->lng->txt('file_upload_only_partial'));
172 break;
173
174 case UPLOAD_ERR_NO_TMP_DIR:
175 $this->ilErr->appendMessage($this->lng->txt('file_upload_no_tmp_dir'));
176 break;
177
178 // not possible with php 4
179 #case UPLOAD_ERR_CANT_WRITE:
180 # $this->ilErr->appendMessage($this->lng->txt('file_upload_no_write'));
181 # break;
182
183 case UPLOAD_ERR_OK:
184 case UPLOAD_ERR_NO_FILE:
185 default:
186 return true;
187 }
188 }

References getErrorCode().

+ Here is the call graph for this function:

Field Documentation

◆ $course_id

ilCourseFile::$course_id = null

Definition at line 42 of file class.ilCourseFile.php.

Referenced by getCourseId().

◆ $file_id

ilCourseFile::$file_id = null

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

Referenced by getFileId().

◆ $fss_storage

ilCourseFile::$fss_storage = null
private

Definition at line 45 of file class.ilCourseFile.php.

◆ $ilDB

ilCourseFile::$ilDB

◆ $ilErr

ilCourseFile::$ilErr

Definition at line 37 of file class.ilCourseFile.php.

Referenced by __construct().

◆ $lng

ilCourseFile::$lng

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

Referenced by __construct().

◆ $tree

ilCourseFile::$tree

Definition at line 39 of file class.ilCourseFile.php.


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