ILIAS  release_7 Revision v7.30-3-g800a261c036
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 @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
 __construct ()
 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
 __construct ()
 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.

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 @access public

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

53 {
54 define('COURSE_PATH', 'course');
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 @access public
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References __checkImportPath(), __checkPath(), ILIAS\GlobalScreen\Provider\__construct(), and __initDirectory().

+ Here is the call graph for this function:

Member Function Documentation

◆ __checkImportPath()

ilFileDataCourse::__checkImportPath ( )

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

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 }
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 __construct().

+ 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.

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 }
__checkReadWrite()
check if directory is writable overwritten method from base class @access private
const CLIENT_WEB_DIR
Definition: constants.php:45

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

Referenced by __construct().

+ 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 305 of file class.ilFileDataCourse.php.

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 }

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 319 of file class.ilFileDataCourse.php.

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 @access public

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

Referenced by __construct().

+ 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.

182 {
183 ilUtil::makeDir($this->getCoursePath() . '/' . $a_rel_name);
184
185 return true;
186 }

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

+ Here is the call graph for this function:

◆ copy()

ilFileDataCourse::copy (   $a_from,
  $a_to 
)

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

164 {
165 if (@file_exists($a_from)) {
166 @copy($a_from, $this->getCoursePath() . '/' . $a_to);
167
168 return true;
169 }
170 return false;
171 }

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 232 of file class.ilFileDataCourse.php.

233 {
234 ilUtil::makeDir($this->getCoursePath() . '/import/crs_' . $this->course_id);
235
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 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 217 of file class.ilFileDataCourse.php.

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.

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

+ Here is the call graph for this function:

◆ deleteArchive()

ilFileDataCourse::deleteArchive (   $a_rel_name)

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

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 }

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

+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileDataCourse::deleteDirectory (   $a_abs_name)

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

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

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 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.

154 {
155 if (@file_exists($a_abs_name)) {
156 @unlink($a_abs_name);
157
158 return true;
159 }
160 return false;
161 }

Referenced by deleteArchive().

+ Here is the caller graph for this function:

◆ deleteZipFile()

ilFileDataCourse::deleteZipFile (   $a_abs_name)

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

136 {
137 if (@file_exists($a_abs_name)) {
138 @unlink($a_abs_name);
139
140 return true;
141 }
142 return false;
143 }

Referenced by deleteArchive().

+ 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 @access public

Returns
string path

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

213 {
214 return $this->course_path;
215 }

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 262 of file class.ilFileDataCourse.php.

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 }

References getCoursePath().

+ 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.

@access public

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

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 }

◆ getOnlineLink()

ilFileDataCourse::getOnlineLink (   $a_rel_name)

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

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

References ilUtil\getWebspaceDir().

+ Here is the call graph for this function:

◆ rCopy()

ilFileDataCourse::rCopy (   $a_from,
  $a_to 
)

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

174 {
175 ilUtil::rCopy($a_from, $this->getCoursePath() . '/' . $a_to);
176
177 return true;
178 }

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

+ Here is the call graph for this function:

◆ unpackImportFile()

ilFileDataCourse::unpackImportFile ( )

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

245 {
246 return ilUtil::unzip($this->getCoursePath() . '/import/crs_' . $this->course_id . '/' . $this->import_file_info['basename']);
247 }
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)

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

+ Here is the call graph for this function:

◆ validateImportFile()

ilFileDataCourse::validateImportFile ( )

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

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 }

References getCoursePath().

+ 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.

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 }

References getCoursePath().

+ 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.

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

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: