ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 __construct ($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 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 private More...
 
 __initDirectory ()
 init directory overwritten method public More...
 
- Public Member Functions inherited from ilFileData
 __construct ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path public More...
 
- Public Member Functions inherited from ilFile
 __construct ()
 Constructor get ilias object 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.

Constructor & Destructor Documentation

◆ __construct()

ilFileDataCourse::__construct (   $a_course_id)

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

Parameters
intobj_id public

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

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

53  {
54  define('COURSE_PATH', 'course');
55  parent::__construct();
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  $this->__initDirectory();
62  }
63  // Check import dir
64  $this->__checkImportPath();
65  }
__initDirectory()
init directory overwritten method public
+ Here is the call graph for this function:

Member Function Documentation

◆ __checkImportPath()

ilFileDataCourse::__checkImportPath ( )

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

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

Referenced by __construct().

289  {
290  if (!@file_exists($this->getCoursePath() . '/import')) {
291  ilUtil::makeDir($this->getCoursePath() . '/import');
292  }
293 
294  if (!is_writable($this->getCoursePath() . '/import') or !is_readable($this->getCoursePath() . '/import')) {
295  $this->ilias->raiseError("Course import path is not readable/writable by webserver", $this->ilias->error_obj->FATAL);
296  }
297  }
redirection script todo: (a better solution should control the processing via a xml file) ...
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
getCoursePath()
get exercise path public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __checkPath()

ilFileDataCourse::__checkPath ( )

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

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

Referenced by __construct().

274  {
275  if (!@file_exists($this->getCoursePath())) {
276  return false;
277  }
278  if (!@file_exists(CLIENT_WEB_DIR . '/courses')) {
279  ilUtil::makeDir(CLIENT_WEB_DIR . '/courses');
280  }
281 
282 
283  $this->__checkReadWrite();
284 
285  return true;
286  }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
__checkReadWrite()
check if directory is writable overwritten method from base class private
getCoursePath()
get exercise path public
+ 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 private

Returns
bool

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

Referenced by __checkPath().

306  {
307  if (is_writable($this->course_path) && is_readable($this->course_path)) {
308  return true;
309  } else {
310  $this->ilias->raiseError("Course directory is not readable/writable by webserver", $this->ilias->error_obj->FATAL);
311  }
312  }
redirection script todo: (a better solution should control the processing via a xml file) ...
+ Here is the caller graph for this function:

◆ __initDirectory()

ilFileDataCourse::__initDirectory ( )

init directory overwritten method public

Returns
string path

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

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

Referenced by __construct().

320  {
321  if (is_writable($this->getPath())) {
322  ilUtil::makeDir($this->getPath() . '/' . COURSE_PATH);
323  $this->course_path = $this->getPath() . '/' . COURSE_PATH;
324 
325  return true;
326  }
327  return false;
328  }
getPath()
get Path public
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ 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 181 of file class.ilFileDataCourse.php.

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

182  {
183  ilUtil::makeDir($this->getCoursePath() . '/' . $a_rel_name);
184 
185  return true;
186  }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ copy()

ilFileDataCourse::copy (   $a_from,
  $a_to 
)

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

References getCoursePath().

164  {
165  if (@file_exists($a_from)) {
166  @copy($a_from, $this->getCoursePath() . '/' . $a_to);
167 
168  return true;
169  }
170  return false;
171  }
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ createImportFile()

ilFileDataCourse::createImportFile (   $a_tmp_name,
  $a_name 
)

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

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

233  {
234  ilUtil::makeDir($this->getCoursePath() . '/import/crs_' . $this->course_id);
235 
236  ilUtil::moveUploadedFile(
237  $a_tmp_name,
238  $a_name,
239  $this->getCoursePath() . '/import/crs_' . $this->course_id . '/' . $a_name
240  );
241  $this->import_file_info = pathinfo($this->getCoursePath() . '/import/crs_' . $this->course_id . '/' . $a_name);
242  }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ createOnlineVersion()

ilFileDataCourse::createOnlineVersion (   $a_rel_name)

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

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

218  {
219  ilUtil::makeDir(CLIENT_WEB_DIR . '/courses/' . $a_rel_name);
220  ilUtil::rCopy($this->getCoursePath() . '/' . $a_rel_name, CLIENT_WEB_DIR . '/courses/' . $a_rel_name);
221 
222  return true;
223  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ deleteArchive()

ilFileDataCourse::deleteArchive (   $a_rel_name)

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

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

127  {
128  $this->deleteZipFile($this->course_path . '/' . $a_rel_name . '.zip');
129  $this->deleteDirectory($this->course_path . '/' . $a_rel_name);
130  $this->deleteDirectory(CLIENT_WEB_DIR . '/courses/' . $a_rel_name);
131  $this->deletePdf($this->course_path . '/' . $a_rel_name . '.pdf');
132 
133  return true;
134  }
+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileDataCourse::deleteDirectory (   $a_abs_name)

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

References ilUtil\delDir().

Referenced by deleteArchive().

145  {
146  if (file_exists($a_abs_name)) {
147  ilUtil::delDir($a_abs_name);
148 
149  return true;
150  }
151  return false;
152  }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteMemberExportFile()

ilFileDataCourse::deleteMemberExportFile (   $a_name)

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

110  {
111  $file_name = $this->course_path . '/' . $a_name;
112  if (@file_exists($file_name)) {
113  @unlink($file_name);
114  }
115  }

◆ deletePdf()

ilFileDataCourse::deletePdf (   $a_abs_name)

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

Referenced by deleteArchive().

154  {
155  if (@file_exists($a_abs_name)) {
156  @unlink($a_abs_name);
157 
158  return true;
159  }
160  return false;
161  }
+ Here is the caller graph for this function:

◆ deleteZipFile()

ilFileDataCourse::deleteZipFile (   $a_abs_name)

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

Referenced by deleteArchive().

136  {
137  if (@file_exists($a_abs_name)) {
138  @unlink($a_abs_name);
139 
140  return true;
141  }
142  return false;
143  }
+ Here is the caller graph for this function:

◆ getArchiveFile()

ilFileDataCourse::getArchiveFile (   $a_rel_name)

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

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

◆ getCoursePath()

ilFileDataCourse::getCoursePath ( )

get exercise path public

Returns
string path

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

References $course_path.

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

213  {
214  return $this->course_path;
215  }
+ Here is the caller graph for this function:

◆ getImportFile()

ilFileDataCourse::getImportFile ( )

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

References getCoursePath().

263  {
264  return $this->getCoursePath() . '/import/crs_' . $this->course_id
265  . '/' . basename($this->import_file_info['basename'], '.zip')
266  . '/' . basename($this->import_file_info['basename'], '.zip') . '.xml';
267  }
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ getMemberExportFile()

ilFileDataCourse::getMemberExportFile (   $a_name)

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

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

◆ getMemberExportFiles()

ilFileDataCourse::getMemberExportFiles ( )

Get all member export files.

public

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

References $file, $files, and array.

85  {
86  $files = array();
87  $dp = opendir($this->course_path);
88 
89  while ($file = readdir($dp)) {
90  if (is_dir($file)) {
91  continue;
92  }
93 
94  if (preg_match("/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/", $file, $matches) and $matches[3] == $this->course_id) {
95  $timest = $matches[1];
96  $file_info['name'] = $matches[0];
97  $file_info['timest'] = $matches[1];
98  $file_info['type'] = $matches[2];
99  $file_info['id'] = $matches[3];
100  $file_info['size'] = filesize($this->course_path . '/' . $file);
101 
102  $files[$timest] = $file_info;
103  }
104  }
105  closedir($dp);
106  return $files ? $files : array();
107  }
$files
Definition: add-vimline.php:18
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ getOnlineLink()

ilFileDataCourse::getOnlineLink (   $a_rel_name)

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

References ilUtil\getWebspaceDir().

226  {
227  return ilUtil::getWebspaceDir('filesystem') . '/courses/' . $a_rel_name . '/index.html';
228  }
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ rCopy()

ilFileDataCourse::rCopy (   $a_from,
  $a_to 
)

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

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

174  {
175  ilUtil::rCopy($a_from, $this->getCoursePath() . '/' . $a_to);
176 
177  return true;
178  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ unpackImportFile()

ilFileDataCourse::unpackImportFile ( )

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

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

245  {
246  return ilUtil::unzip($this->getCoursePath() . '/import/crs_' . $this->course_id . '/' . $this->import_file_info['basename']);
247  }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ validateImportFile()

ilFileDataCourse::validateImportFile ( )

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

References getCoursePath().

250  {
251  if (!is_dir($this->getCoursePath() . '/import/crs_' . $this->course_id) . '/' .
252  basename($this->import_file_info['basename'], '.zip')) {
253  return false;
254  }
255  if (!file_exists($this->getCoursePath() . '/import/crs_' . $this->course_id
256  . '/' . basename($this->import_file_info['basename'], '.zip')
257  . '/' . basename($this->import_file_info['basename'], '.zip') . '.xml')) {
258  return false;
259  }
260  }
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ writeToFile()

ilFileDataCourse::writeToFile (   $a_data,
  $a_rel_name 
)

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

References getCoursePath().

189  {
190  if (!$fp = @fopen($this->getCoursePath() . '/' . $a_rel_name, 'w+')) {
191  die("Cannot open file: " . $this->getCoursePath() . '/' . $a_rel_name);
192  }
193  @fwrite($fp, $a_data);
194 
195  return true;
196  }
getCoursePath()
get exercise path public
+ Here is the call graph for this function:

◆ zipFile()

ilFileDataCourse::zipFile (   $a_rel_name,
  $a_zip_name 
)

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

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

199  {
200  ilUtil::zip($this->getCoursePath() . '/' . $a_rel_name, $this->getCoursePath() . '/' . $a_zip_name);
201 
202  // RETURN filesize
203  return filesize($this->getCoursePath() . '/' . $a_zip_name);
204  }
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
getCoursePath()
get exercise path public
+ 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: