ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFileDataCourse Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $a_course_id)
 
 getArchiveFile ($a_rel_name)
 
 getMemberExportFiles ()
 
 deleteMemberExportFile (string $a_name)
 
 getMemberExportFile (string $a_name)
 
 deleteArchive (string $a_rel_name)
 
 deleteZipFile (string $a_abs_name)
 
 deleteDirectory (string $a_abs_name)
 
 deletePdf (string $a_abs_name)
 
 copy (string $a_from, string $a_to)
 
 rCopy (string $a_from, string $a_to)
 
 addDirectory (string $a_rel_name)
 
 writeToFile (string $a_data, string $a_rel_name)
 
 zipFile (string $a_rel_name, string $a_zip_name)
 
 getCoursePath ()
 
 createOnlineVersion (string $a_rel_name)
 
 getOnlineLink (string $a_rel_name)
 
 __checkPath ()
 
 __checkImportPath ()
 
 __checkReadWrite ()
 
 __initDirectory ()
 
- Public Member Functions inherited from ilFileData
 __construct ()
 
 checkPath (string $a_path)
 
 getPath ()
 
- Public Member Functions inherited from ilFile
 deleteTrailingSlash (string $a_path)
 delete trailing slash of path variables More...
 

Protected Attributes

ilErrorHandling $error
 
- Protected Attributes inherited from ilFile
string $path
 

Private Attributes

string $course_path
 
int $course_id
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

ilFileDataCourse::__construct ( int  $a_course_id)

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

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

35  {
36  global $DIC;
37 
38  $this->error = $DIC['ilErr'];
39 
40  define('COURSE_PATH', 'course');
41 
43  $this->course_path = parent::getPath() . "/" . COURSE_PATH;
44  $this->course_id = $a_course_id;
45 
46  if (!$this->__checkPath()) {
47  $this->__initDirectory();
48  }
49  $this->__checkImportPath();
50  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ __checkImportPath()

ilFileDataCourse::__checkImportPath ( )

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

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

Referenced by __construct().

216  : void
217  {
218  if (!file_exists($this->getCoursePath() . '/import')) {
219  ilFileUtils::makeDir($this->getCoursePath() . '/import');
220  }
221 
222  if (!is_writable($this->getCoursePath() . '/import') || !is_readable($this->getCoursePath() . '/import')) {
223  $this->error->raiseError("Course import path is not readable/writable by webserver", $this->error->FATAL);
224  }
225  }
static makeDir(string $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:

◆ __checkPath()

ilFileDataCourse::__checkPath ( )

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

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

Referenced by __construct().

202  : bool
203  {
204  if (!file_exists($this->getCoursePath())) {
205  return false;
206  }
207  if (!file_exists(CLIENT_WEB_DIR . '/courses')) {
208  ilFileUtils::makeDir(CLIENT_WEB_DIR . '/courses');
209  }
210 
211  $this->__checkReadWrite();
212 
213  return true;
214  }
const CLIENT_WEB_DIR
Definition: constants.php:47
static makeDir(string $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:

◆ __checkReadWrite()

ilFileDataCourse::__checkReadWrite ( )

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

Referenced by __checkPath().

227  : bool
228  {
229  if (is_writable($this->course_path) && is_readable($this->course_path)) {
230  return true;
231  } else {
232  $this->error->raiseError("Course directory is not readable/writable by webserver", $this->error->FATAL);
233  }
234  return false;
235  }
+ Here is the caller graph for this function:

◆ __initDirectory()

ilFileDataCourse::__initDirectory ( )

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

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

Referenced by __construct().

237  : bool
238  {
239  if (is_writable($this->getPath())) {
240  ilFileUtils::makeDir($this->getPath() . '/' . COURSE_PATH);
241  $this->course_path = $this->getPath() . '/' . COURSE_PATH;
242  return true;
243  }
244  return false;
245  }
static makeDir(string $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 ( string  $a_rel_name)

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

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

162  : bool
163  {
164  ilFileUtils::makeDir($this->getCoursePath() . '/' . $a_rel_name);
165  return true;
166  }
static makeDir(string $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:

◆ copy()

ilFileDataCourse::copy ( string  $a_from,
string  $a_to 
)

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

References getCoursePath().

146  : bool
147  {
148  if (file_exists($a_from)) {
149  copy($a_from, $this->getCoursePath() . '/' . $a_to);
150 
151  return true;
152  }
153  return false;
154  }
copy(string $a_from, string $a_to)
+ Here is the call graph for this function:

◆ createOnlineVersion()

ilFileDataCourse::createOnlineVersion ( string  $a_rel_name)

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

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

190  : bool
191  {
192  ilFileUtils::makeDir(CLIENT_WEB_DIR . '/courses/' . $a_rel_name);
193  ilFileUtils::rCopy($this->getCoursePath() . '/' . $a_rel_name, CLIENT_WEB_DIR . '/courses/' . $a_rel_name);
194  return true;
195  }
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
const CLIENT_WEB_DIR
Definition: constants.php:47
static makeDir(string $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:

◆ deleteArchive()

ilFileDataCourse::deleteArchive ( string  $a_rel_name)

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

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

109  : void
110  {
111  $this->deleteZipFile($this->course_path . '/' . $a_rel_name . '.zip');
112  $this->deleteDirectory($this->course_path . '/' . $a_rel_name);
113  $this->deleteDirectory(CLIENT_WEB_DIR . '/courses/' . $a_rel_name);
114  $this->deletePdf($this->course_path . '/' . $a_rel_name . '.pdf');
115  }
deletePdf(string $a_abs_name)
deleteDirectory(string $a_abs_name)
const CLIENT_WEB_DIR
Definition: constants.php:47
deleteZipFile(string $a_abs_name)
+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileDataCourse::deleteDirectory ( string  $a_abs_name)

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

References ilFileUtils\delDir().

Referenced by deleteArchive().

126  : bool
127  {
128  if (file_exists($a_abs_name)) {
129  ilFileUtils::delDir($a_abs_name);
130 
131  return true;
132  }
133  return false;
134  }
static delDir(string $a_dir, bool $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 ( string  $a_name)

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

92  : void
93  {
94  $file_name = $this->course_path . '/' . $a_name;
95  if (file_exists($file_name)) {
96  unlink($file_name);
97  }
98  }

◆ deletePdf()

ilFileDataCourse::deletePdf ( string  $a_abs_name)

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

Referenced by deleteArchive().

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

◆ deleteZipFile()

ilFileDataCourse::deleteZipFile ( string  $a_abs_name)

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

Referenced by deleteArchive().

117  : bool
118  {
119  if (file_exists($a_abs_name)) {
120  unlink($a_abs_name);
121  return true;
122  }
123  return false;
124  }
+ Here is the caller graph for this function:

◆ getArchiveFile()

ilFileDataCourse::getArchiveFile (   $a_rel_name)

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

52  : string
53  {
54  if (file_exists($this->course_path . '/' . $a_rel_name . '.zip')) {
55  return $this->course_path . '/' . $a_rel_name . '.zip';
56  }
57  if (file_exists($this->course_path . '/' . $a_rel_name . '.pdf')) {
58  return $this->course_path . '/' . $a_rel_name . '.pdf';
59  }
60  return '';
61  }

◆ getCoursePath()

ilFileDataCourse::getCoursePath ( )

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

References $course_path.

Referenced by __checkImportPath(), __checkPath(), addDirectory(), copy(), createOnlineVersion(), rCopy(), writeToFile(), and zipFile().

185  : string
186  {
187  return $this->course_path;
188  }
+ Here is the caller graph for this function:

◆ getMemberExportFile()

ilFileDataCourse::getMemberExportFile ( string  $a_name)

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

100  : string
101  {
102  $file_name = $this->course_path . '/' . $a_name;
103  if (file_exists($file_name)) {
104  return file_get_contents($file_name);
105  }
106  return '';
107  }

◆ getMemberExportFiles()

ilFileDataCourse::getMemberExportFiles ( )

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

63  : array
64  {
65  $files = array();
66  $dp = opendir($this->course_path);
67 
68  while ($file = readdir($dp)) {
69  if (is_dir($file)) {
70  continue;
71  }
72 
73  if (preg_match(
74  "/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/",
75  $file,
76  $matches
77  ) && $matches[3] == $this->course_id) {
78  $timest = $matches[1];
79  $file_info['name'] = $matches[0];
80  $file_info['timest'] = $matches[1];
81  $file_info['type'] = $matches[2];
82  $file_info['id'] = $matches[3];
83  $file_info['size'] = filesize($this->course_path . '/' . $file);
84 
85  $files[$timest] = $file_info;
86  }
87  }
88  closedir($dp);
89  return $files;
90  }

◆ getOnlineLink()

ilFileDataCourse::getOnlineLink ( string  $a_rel_name)

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

References ilFileUtils\getWebspaceDir().

197  : string
198  {
199  return ilFileUtils::getWebspaceDir('filesystem') . '/courses/' . $a_rel_name . '/index.html';
200  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ rCopy()

ilFileDataCourse::rCopy ( string  $a_from,
string  $a_to 
)

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

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

156  : bool
157  {
158  ilFileUtils::rCopy($a_from, $this->getCoursePath() . '/' . $a_to);
159  return true;
160  }
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
+ Here is the call graph for this function:

◆ writeToFile()

ilFileDataCourse::writeToFile ( string  $a_data,
string  $a_rel_name 
)

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

References getCoursePath().

168  : bool
169  {
170  if (!$fp = fopen($this->getCoursePath() . '/' . $a_rel_name, 'w+')) {
171  die("Cannot open file: " . $this->getCoursePath() . '/' . $a_rel_name);
172  }
173  fwrite($fp, $a_data);
174  return true;
175  }
+ Here is the call graph for this function:

◆ zipFile()

ilFileDataCourse::zipFile ( string  $a_rel_name,
string  $a_zip_name 
)

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

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

177  : int
178  {
179  ilFileUtils::zip($this->getCoursePath() . '/' . $a_rel_name, $this->getCoursePath() . '/' . $a_zip_name);
180 
181  // RETURN filesize
182  return (int) filesize($this->getCoursePath() . '/' . $a_zip_name);
183  }
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
+ Here is the call graph for this function:

Field Documentation

◆ $course_id

int ilFileDataCourse::$course_id
private

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

◆ $course_path

string ilFileDataCourse::$course_path
private

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

Referenced by getCoursePath().

◆ $error

ilErrorHandling ilFileDataCourse::$error
protected

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


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