ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilFileDataCourse Class Reference

This class handles all operations of archive files for the course object. More...

+ Inheritance diagram for ilFileDataCourse:
+ Collaboration diagram for ilFileDataCourse:

Public Member Functions

 ilFileDataCourse ($a_course_id)
 Constructor call base constructors checks if directory is writable and sets the optional obj_id. More...
 
 getArchiveFile ($a_rel_name)
 
 getMemberExportFiles ()
 Get all member export files. More...
 
 deleteMemberExportFile ($a_name)
 
 getMemberExportFile ($a_name)
 
 deleteArchive ($a_rel_name)
 
 deleteZipFile ($a_abs_name)
 
 deleteDirectory ($a_abs_name)
 
 deletePdf ($a_abs_name)
 
 copy ($a_from, $a_to)
 
 rCopy ($a_from, $a_to)
 
 addDirectory ($a_rel_name)
 
 writeToFile ($a_data, $a_rel_name)
 
 zipFile ($a_rel_name, $a_zip_name)
 
 getCoursePath ()
 get exercise path @access public More...
 
 createOnlineVersion ($a_rel_name)
 
 getOnlineLink ($a_rel_name)
 
 createImportFile ($a_tmp_name, $a_name)
 
 unpackImportFile ()
 
 validateImportFile ()
 
 getImportFile ()
 
 __checkPath ()
 
 __checkImportPath ()
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class @access private More...
 
 __initDirectory ()
 init directory overwritten method @access public More...
 
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object @access public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path @access public More...
 
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object @access public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Data Fields

 $course_path
 
- Data Fields inherited from ilFile
 $path
 
 $ilias
 

Private Attributes

 $course_id
 

Detailed Description

This class handles all operations of archive files for the course object.

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

Definition at line 34 of file class.ilFileDataCourse.php.

Member Function Documentation

◆ __checkImportPath()

ilFileDataCourse::__checkImportPath ( )

Definition at line 304 of file class.ilFileDataCourse.php.

305 {
306 if(!@file_exists($this->getCoursePath().'/import'))
307 {
308 ilUtil::makeDir($this->getCoursePath().'/import');
309 }
310
311 if(!is_writable($this->getCoursePath().'/import') or !is_readable($this->getCoursePath().'/import'))
312 {
313 $this->ilias->raiseError("Course import path is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
314 }
315 }
getCoursePath()
get exercise path @access public
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
redirection script todo: (a better solution should control the processing via a xml file)

References getCoursePath(), and ilUtil\makeDir().

Referenced by ilFileDataCourse().

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

◆ __checkPath()

ilFileDataCourse::__checkPath ( )

Definition at line 287 of file class.ilFileDataCourse.php.

288 {
289 if(!@file_exists($this->getCoursePath()))
290 {
291 return false;
292 }
293 if(!@file_exists(CLIENT_WEB_DIR.'/courses'))
294 {
295 ilUtil::makeDir(CLIENT_WEB_DIR.'/courses');
296 }
297
298
299 $this->__checkReadWrite();
300
301 return true;
302 }
__checkReadWrite()
check if directory is writable overwritten method from base class @access private

References __checkReadWrite(), getCoursePath(), and ilUtil\makeDir().

Referenced by ilFileDataCourse().

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

◆ __checkReadWrite()

ilFileDataCourse::__checkReadWrite ( )

check if directory is writable overwritten method from base class @access private

Returns
bool

Definition at line 323 of file class.ilFileDataCourse.php.

324 {
325 if(is_writable($this->course_path) && is_readable($this->course_path))
326 {
327 return true;
328 }
329 else
330 {
331 $this->ilias->raiseError("Course directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
332 }
333 }

Referenced by __checkPath().

+ Here is the caller graph for this function:

◆ __initDirectory()

ilFileDataCourse::__initDirectory ( )

init directory overwritten method @access public

Returns
string path

Definition at line 340 of file class.ilFileDataCourse.php.

341 {
342 if(is_writable($this->getPath()))
343 {
344 ilUtil::makeDir($this->getPath().'/'.COURSE_PATH);
345 $this->course_path = $this->getPath().'/'.COURSE_PATH;
346
347 return true;
348 }
349 return false;
350 }
getPath()
get Path @access public

References ilFileData\getPath(), and ilUtil\makeDir().

Referenced by ilFileDataCourse().

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

◆ addDirectory()

ilFileDataCourse::addDirectory (   $a_rel_name)

Definition at line 193 of file class.ilFileDataCourse.php.

194 {
195 ilUtil::makeDir($this->getCoursePath().'/'.$a_rel_name);
196
197 return true;
198 }

References getCoursePath(), and ilUtil\makeDir().

+ Here is the call graph for this function:

◆ copy()

ilFileDataCourse::copy (   $a_from,
  $a_to 
)

Definition at line 174 of file class.ilFileDataCourse.php.

175 {
176 if(@file_exists($a_from))
177 {
178 @copy($a_from,$this->getCoursePath().'/'.$a_to);
179
180 return true;
181 }
182 return false;
183 }

References copy(), and getCoursePath().

Referenced by copy().

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

◆ createImportFile()

ilFileDataCourse::createImportFile (   $a_tmp_name,
  $a_name 
)

Definition at line 245 of file class.ilFileDataCourse.php.

246 {
247 ilUtil::makeDir($this->getCoursePath().'/import/crs_'.$this->course_id);
248
249 ilUtil::moveUploadedFile($a_tmp_name,
250 $a_name,
251 $this->getCoursePath().'/import/crs_'.$this->course_id.'/'.$a_name);
252 $this->import_file_info = pathinfo($this->getCoursePath().'/import/crs_'.$this->course_id.'/'.$a_name);
253
254 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References getCoursePath(), ilUtil\makeDir(), and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

◆ createOnlineVersion()

ilFileDataCourse::createOnlineVersion (   $a_rel_name)

Definition at line 230 of file class.ilFileDataCourse.php.

231 {
232 ilUtil::makeDir(CLIENT_WEB_DIR.'/courses/'.$a_rel_name);
233 ilUtil::rCopy($this->getCoursePath().'/'.$a_rel_name,CLIENT_WEB_DIR.'/courses/'.$a_rel_name);
234
235 return true;
236 }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.

References getCoursePath(), ilUtil\makeDir(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ deleteArchive()

ilFileDataCourse::deleteArchive (   $a_rel_name)

Definition at line 134 of file class.ilFileDataCourse.php.

135 {
136 $this->deleteZipFile($this->course_path.'/'.$a_rel_name.'.zip');
137 $this->deleteDirectory($this->course_path.'/'.$a_rel_name);
138 $this->deleteDirectory(CLIENT_WEB_DIR.'/courses/'.$a_rel_name);
139 $this->deletePdf($this->course_path.'/'.$a_rel_name.'.pdf');
140
141 return true;
142 }

References deleteDirectory(), deletePdf(), and deleteZipFile().

+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileDataCourse::deleteDirectory (   $a_abs_name)

Definition at line 153 of file class.ilFileDataCourse.php.

154 {
155 if(file_exists($a_abs_name))
156 {
157 ilUtil::delDir($a_abs_name);
158
159 return true;
160 }
161 return false;
162 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir().

Referenced by deleteArchive().

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

◆ deleteMemberExportFile()

ilFileDataCourse::deleteMemberExportFile (   $a_name)

Definition at line 115 of file class.ilFileDataCourse.php.

116 {
117 $file_name = $this->course_path.'/'.$a_name;
118 if(@file_exists($file_name))
119 {
120 @unlink($file_name);
121 }
122 }

◆ deletePdf()

ilFileDataCourse::deletePdf (   $a_abs_name)

Definition at line 163 of file class.ilFileDataCourse.php.

164 {
165 if(@file_exists($a_abs_name))
166 {
167 @unlink($a_abs_name);
168
169 return true;
170 }
171 return false;
172 }

Referenced by deleteArchive().

+ Here is the caller graph for this function:

◆ deleteZipFile()

ilFileDataCourse::deleteZipFile (   $a_abs_name)

Definition at line 143 of file class.ilFileDataCourse.php.

144 {
145 if(@file_exists($a_abs_name))
146 {
147 @unlink($a_abs_name);
148
149 return true;
150 }
151 return false;
152 }

Referenced by deleteArchive().

+ Here is the caller graph for this function:

◆ getArchiveFile()

ilFileDataCourse::getArchiveFile (   $a_rel_name)

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

69 {
70 if(@file_exists($this->course_path.'/'.$a_rel_name.'.zip'))
71 {
72 return $this->course_path.'/'.$a_rel_name.'.zip';
73 }
74 if(@file_exists($this->course_path.'/'.$a_rel_name.'.pdf'))
75 {
76 return $this->course_path.'/'.$a_rel_name.'.pdf';
77 }
78 return false;
79 }

◆ getCoursePath()

ilFileDataCourse::getCoursePath ( )

get exercise path @access public

Returns
string path

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

226 {
227 return $this->course_path;
228 }

References $course_path.

Referenced by __checkImportPath(), __checkPath(), addDirectory(), copy(), createImportFile(), createOnlineVersion(), getImportFile(), rCopy(), unpackImportFile(), validateImportFile(), writeToFile(), and zipFile().

+ Here is the caller graph for this function:

◆ getImportFile()

ilFileDataCourse::getImportFile ( )

Definition at line 276 of file class.ilFileDataCourse.php.

277 {
278 return $this->getCoursePath().'/import/crs_'.$this->course_id
279 .'/'.basename($this->import_file_info['basename'],'.zip')
280 .'/'.basename($this->import_file_info['basename'],'.zip').'.xml';
281 }

References getCoursePath().

+ Here is the call graph for this function:

◆ getMemberExportFile()

ilFileDataCourse::getMemberExportFile (   $a_name)

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

125 {
126 $file_name = $this->course_path.'/'.$a_name;
127 if(@file_exists($file_name))
128 {
129 return file_get_contents($file_name);
130 }
131 }

◆ getMemberExportFiles()

ilFileDataCourse::getMemberExportFiles ( )

Get all member export files.

@access public

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

88 {
89 $files = array();
90 $dp = opendir($this->course_path);
91
92 while($file = readdir($dp))
93 {
94 if(is_dir($file))
95 {
96 continue;
97 }
98
99 if(preg_match("/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/",$file,$matches) and $matches[3] == $this->course_id)
100 {
101 $timest = $matches[1];
102 $file_info['name'] = $matches[0];
103 $file_info['timest'] = $matches[1];
104 $file_info['type'] = $matches[2];
105 $file_info['id'] = $matches[3];
106 $file_info['size'] = filesize($this->course_path.'/'.$file);
107
108 $files[$timest] = $file_info;
109 }
110 }
111 closedir($dp);
112 return $files ? $files : array();
113 }
print $file

References $file.

◆ getOnlineLink()

ilFileDataCourse::getOnlineLink (   $a_rel_name)

Definition at line 238 of file class.ilFileDataCourse.php.

239 {
240 return ilUtil::getWebspaceDir('filesystem').'/courses/'.$a_rel_name.'/index.html';
241 }
static getWebspaceDir($mode="filesystem")
get webspace directory

References ilUtil\getWebspaceDir().

+ Here is the call graph for this function:

◆ ilFileDataCourse()

ilFileDataCourse::ilFileDataCourse (   $a_course_id)

Constructor call base constructors checks if directory is writable and sets the optional obj_id.

Parameters
integeregerobj_id @access public

Definition at line 52 of file class.ilFileDataCourse.php.

53 {
54 define('COURSE_PATH','course');
55 parent::ilFileData();
56 $this->course_path = parent::getPath()."/".COURSE_PATH;
57 $this->course_id = $a_course_id;
58
59 // IF DIRECTORY ISN'T CREATED CREATE IT
60 if(!$this->__checkPath())
61 {
62 $this->__initDirectory();
63 }
64 // Check import dir
65 $this->__checkImportPath();
66 }
__initDirectory()
init directory overwritten method @access public

References __checkImportPath(), __checkPath(), and __initDirectory().

+ Here is the call graph for this function:

◆ rCopy()

ilFileDataCourse::rCopy (   $a_from,
  $a_to 
)

Definition at line 185 of file class.ilFileDataCourse.php.

186 {
187 ilUtil::rCopy($a_from,$this->getCoursePath().'/'.$a_to);
188
189 return true;
190 }

References getCoursePath(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ unpackImportFile()

ilFileDataCourse::unpackImportFile ( )

Definition at line 256 of file class.ilFileDataCourse.php.

257 {
258 return ilUtil::unzip($this->getCoursePath().'/import/crs_'.$this->course_id.'/'.$this->import_file_info['basename']);
259 }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file

References getCoursePath(), and ilUtil\unzip().

+ Here is the call graph for this function:

◆ validateImportFile()

ilFileDataCourse::validateImportFile ( )

Definition at line 261 of file class.ilFileDataCourse.php.

262 {
263 if(!is_dir($this->getCoursePath().'/import/crs_'.$this->course_id).'/'.
264 basename($this->import_file_info['basename'],'.zip'))
265 {
266 return false;
267 }
268 if(!file_exists($this->getCoursePath().'/import/crs_'.$this->course_id
269 .'/'.basename($this->import_file_info['basename'],'.zip')
270 .'/'.basename($this->import_file_info['basename'],'.zip').'.xml'))
271 {
272 return false;
273 }
274 }

References getCoursePath().

+ Here is the call graph for this function:

◆ writeToFile()

ilFileDataCourse::writeToFile (   $a_data,
  $a_rel_name 
)

Definition at line 200 of file class.ilFileDataCourse.php.

201 {
202 if(!$fp = @fopen($this->getCoursePath().'/'.$a_rel_name,'w+'))
203 {
204 die("Cannot open file: ".$this->getCoursePath().'/'.$a_rel_name);
205 }
206 @fwrite($fp,$a_data);
207
208 return true;
209 }

References getCoursePath().

+ Here is the call graph for this function:

◆ zipFile()

ilFileDataCourse::zipFile (   $a_rel_name,
  $a_zip_name 
)

Definition at line 211 of file class.ilFileDataCourse.php.

212 {
213 ilUtil::zip($this->getCoursePath().'/'.$a_rel_name,$this->getCoursePath().'/'.$a_zip_name);
214
215 // RETURN filesize
216 return filesize($this->getCoursePath().'/'.$a_zip_name);
217 }
static zip($a_dir, $a_file, $compress_content=false)

References getCoursePath(), and ilUtil\zip().

+ Here is the call graph for this function:

Field Documentation

◆ $course_id

ilFileDataCourse::$course_id
private

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

◆ $course_path

ilFileDataCourse::$course_path

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

Referenced by getCoursePath().


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