ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilCourseFile Class Reference
+ Inheritance diagram for ilCourseFile:
+ Collaboration diagram for ilCourseFile:

Public Member Functions

 ilCourseFile ($a_file_id=null)
 
 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 ()
 
 _deleteByCourse ($a_course_id)
 
_readFilesByCourse ($a_course_id)
 
 __read ()
 

Static Public Member Functions

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

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.

Member Function Documentation

◆ __read()

ilCourseFile::__read ( )

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

267 {
268 global $ilDB;
269
270 if(!$this->file_id)
271 {
272 return true;
273 }
274
275 // read file data
276 $query = "SELECT * FROM crs_file WHERE file_id = ".$ilDB->quote($this->file_id,'integer');
277 $res = $this->db->query($query);
278 while($row = $ilDB->fetchObject($res))
279 {
280 $this->setFileName($row->file_name);
281 $this->setFileSize($row->file_size);
282 $this->setFileType($row->file_type);
283 $this->setCourseId($row->course_id);
284 }
285 $this->fss_storage = new ilFSStorageCourse($this->getCourseId());
286 return true;
287 }
setCourseId($a_course_id)

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

Referenced by ilCourseFile().

+ 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 68 of file class.ilCourseFile.php.

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

References _readFilesByCourse(), and ilCourseFile().

Referenced by ilObjCourse\cloneObject().

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

◆ _deleteByCourse()

ilCourseFile::_deleteByCourse (   $a_course_id)

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

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

References $ilDB, $query, and $res.

Referenced by ilObjCourse\delete().

+ Here is the caller graph for this function:

◆ _readFilesByCourse()

& ilCourseFile::_readFilesByCourse (   $a_course_id)

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

252 {
253 global $ilDB;
254
255 $query = "SELECT * FROM crs_file ".
256 "WHERE course_id = ".$ilDB->quote($a_course_id,'integer')."";
257
258 $res = $ilDB->query($query);
259 while($row = $ilDB->fetchObject($res))
260 {
261 $files[] =& new ilCourseFile($row->file_id);
262 }
263 return is_array($files) ? $files : array();
264 }

References $ilDB, $query, $res, $row, and ilCourseFile().

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

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

◆ create()

ilCourseFile::create (   $a_upload = true)

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

187 {
188 global $ilDB;
189
190 if($this->getErrorCode() != 0)
191 {
192 return false;
193 }
194
195 $next_id = $ilDB->nextId('crs_file');
196 $query = "INSERT INTO crs_file (file_id,course_id,file_name,file_size,file_type) ".
197 "VALUES( ".
198 $ilDB->quote($next_id,'integer').", ".
199 $ilDB->quote($this->getCourseId(),'integer').", ".
200 $ilDB->quote($this->getFileName(),'text').", ".
201 $ilDB->quote($this->getFileSize(),'integer').", ".
202 $ilDB->quote($this->getFileType(),'text')." ".
203 ")";
204 $res = $ilDB->manipulate($query);
205 $this->setFileId($next_id);
206
207 $this->fss_storage = new ilFSStorageCourse($this->getCourseId());
208 $this->fss_storage->initInfoDirectory();
209
210 if($a_upload)
211 {
212 // now create file
214 $this->getFileName(),
215 $this->fss_storage->getInfoDirectory().'/'.$this->getFileId());
216
217 }
218 return true;
219 }
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 221 of file class.ilCourseFile.php.

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

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

+ Here is the call graph for this function:

◆ getAbsolutePath()

ilCourseFile::getAbsolutePath ( )

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

147 {
148 if(is_object($this->fss_storage))
149 {
150 return $this->fss_storage->getInfoDirectory().'/'.$this->getFileId();
151 }
152 return false;
153 }

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 96 of file class.ilCourseFile.php.

97 {
98 return $this->course_id;
99 }

References $course_id.

Referenced by __read(), and create().

+ Here is the caller graph for this function:

◆ getErrorCode()

ilCourseFile::getErrorCode ( )

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

142 {
143 return $this->error_code;
144 }

Referenced by create(), and validate().

+ Here is the caller graph for this function:

◆ getFileId()

ilCourseFile::getFileId ( )

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

92 {
93 return $this->file_id;
94 }

References $file_id.

Referenced by delete(), and getAbsolutePath().

+ Here is the caller graph for this function:

◆ getFileName()

ilCourseFile::getFileName ( )

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

110 {
111 return $this->file_name;
112 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getFileSize()

ilCourseFile::getFileSize ( )

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

126 {
127 return $this->file_size;
128 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getFileType()

ilCourseFile::getFileType ( )

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

118 {
119 return $this->file_type;
120 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getTemporaryName()

ilCourseFile::getTemporaryName ( )

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

134 {
135 return $this->tmp_name;
136 }

Referenced by create().

+ Here is the caller graph for this function:

◆ ilCourseFile()

ilCourseFile::ilCourseFile (   $a_file_id = null)

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

48 {
49 global $ilErr,$ilDB,$lng;
50
51 $this->ilErr =& $ilErr;
52 $this->db =& $ilDB;
53 $this->lng =& $lng;
54
55 $this->file_id = $a_file_id;
56 $this->__read();
57 }

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

Referenced by _cloneFiles(), and _readFilesByCourse().

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

◆ setCourseId()

ilCourseFile::setCourseId (   $a_course_id)

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

101 {
102 $this->course_id = $a_course_id;
103 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setErrorCode()

ilCourseFile::setErrorCode (   $a_code)

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

138 {
139 $this->error_code = $a_code;
140 }

◆ setFileId()

ilCourseFile::setFileId (   $a_id)

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

88 {
89 $this->file_id = $a_id;
90 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setFileName()

ilCourseFile::setFileName (   $a_name)

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

106 {
107 $this->file_name = $a_name;
108 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileSize()

ilCourseFile::setFileSize (   $a_size)

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

122 {
123 $this->file_size = $a_size;
124 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setFileType()

ilCourseFile::setFileType (   $a_type)

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

114 {
115 $this->file_type = $a_type;
116 }

Referenced by __read().

+ Here is the caller graph for this function:

◆ setTemporaryName()

ilCourseFile::setTemporaryName (   $a_name)

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

130 {
131 $this->tmp_name = $a_name;
132 }

◆ validate()

ilCourseFile::validate ( )

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

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

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 ilCourseFile().

◆ $lng

ilCourseFile::$lng

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

Referenced by ilCourseFile().

◆ $tree

ilCourseFile::$tree

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


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