41 $this->error = $DIC[
'ilErr'];
43 define(
'FORUM_PATH',
'forum');
45 $this->forum_path = parent::getPath() .
"/" . FORUM_PATH;
51 $this->obj_id = $a_obj_id;
52 $this->pos_id = $a_pos_id;
65 $this->pos_id = $a_id;
80 public function getFiles()
83 $filter_iterator =
new RegexIterator($directory_iterator,
"/^{$this->obj_id}_(.+)$/");
86 foreach ($filter_iterator as $file) {
88 if (!$file->isFile()) {
92 list(
$obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
95 'path' => $file->getPathname(),
96 'md5' => md5($this->obj_id .
'_' .
$rest),
98 'size' => $file->getSize(),
99 'ctime' => date(
'Y-m-d H:i:s', $file->getCTime())
113 $filterIterator =
new RegexIterator($directoryIterator,
"/^{$this->obj_id}_{$this->getPosId()}_(.+)$/");
116 foreach ($filterIterator as $file) {
117 if ($file->isFile()) {
119 $files[
$rest] = array(
120 'path' => $file->getPathname(),
121 'md5' => md5($this->obj_id .
'_' . $this->pos_id .
'_' .
$rest),
123 'size' => $file->getSize(),
124 'ctime' => date(
'Y-m-d H:i:s', $file->getCTime())
136 public function moveFilesOfPost($a_new_frm_id = 0)
140 $filter_iterator =
new RegexIterator($directory_iterator,
"/^{$this->obj_id}_(\d+)_(.+)$/");
142 foreach ($filter_iterator as $file) {
144 if (!$file->isFile()) {
149 if ((
int)
$obj_id !== (int) $this->obj_id || (
int) $pos_id !== (int) $this->
getPosId()) {
154 $file->getPathname(),
155 $this->forum_path .
'/' . $a_new_frm_id .
'_' . $this->pos_id .
'_' .
$rest 165 public function ilClone($a_new_obj_id, $a_new_pos_id)
169 $this->
getForumPath() .
"/" . $this->obj_id .
"_" . $this->pos_id .
"_" . $file[
"name"],
170 $this->
getForumPath() .
"/" . $a_new_obj_id .
"_" . $a_new_pos_id .
"_" . $file[
"name"]
175 public function delete()
177 foreach ($this->getFiles() as $file) {
196 if (isset($files[
'name']) && is_array($files[
'name'])) {
202 $temp_name = $files[
'tmp_name'][
$index];
214 } elseif (isset($files[
'name']) && is_string($files[
'name'])) {
216 $files[
'name'] = rtrim($files[
'name'],
'/');
219 $temp_name = $files[
'tmp_name'];
239 if (is_array($a_filenames)) {
240 foreach ($a_filenames as $file) {
256 if (file_exists($this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
'_' . $a_filename)) {
257 return unlink($this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
"_" . $a_filename);
268 return $this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
"_" . $a_path;
280 foreach ((array) $files as $file) {
281 if ($file[
'type'] ==
'file' && md5($file[
'entry']) == $a_md5_filename) {
283 'path' => $this->forum_path .
'/' . $file[
'entry'],
284 'filename' => $file[
'entry'],
285 'clean_filename' => str_replace($this->obj_id .
'_' . $this->pos_id .
'_',
'', $file[
'entry'])
302 if (is_array($a_md5_filename)) {
303 foreach ((array) $files as $file) {
304 if ($file[
'type'] ==
'file' && in_array(md5($file[
'entry']), $a_md5_filename)) {
305 unlink($this->forum_path .
'/' . $file[
'entry']);
311 foreach ((array) $files as $file) {
312 if ($file[
'type'] ==
'file' && md5($file[
'entry']) == $a_md5_filename) {
313 return unlink($this->forum_path .
'/' . $file[
'entry']);
330 foreach ($a_files as $file) {
331 if (!file_exists($this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
'_' . $file)) {
358 if (is_writable($this->forum_path) && is_readable($this->forum_path)) {
361 $this->error->raiseError(
"Forum directory is not readable/writable by webserver", $this->error->FATAL);
372 if (is_writable($this->
getPath())) {
373 if (mkdir($this->
getPath() .
'/' . FORUM_PATH)) {
374 if (chmod($this->
getPath() .
'/' . FORUM_PATH, 0755)) {
375 $this->forum_path = $this->
getPath() .
'/' . FORUM_PATH;
391 if (file_exists($a_path)) {
393 return \ilFileUtils::rename($a_path, $a_path .
'.old');
426 $DIC->http()->close();
440 foreach ($filesOfPost as $file) {
441 @copy($file[
'path'], $tmp_dir .
'/' . $file[
'name']);
checkFilesExist($a_files)
check if files exist
unlinkFiles($a_filenames)
unlink files: expects an array of filenames e.g.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
__checkReadWrite()
check if directory is writable overwritten method from base class private
getAbsolutePath($a_path)
get absolute path of filename
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
__construct($a_obj_id=0, $a_pos_id=0)
Constructor call base constructors checks if directory is writable and sets the optional obj_id...
static rename($a_source, $a_target)
Rename a file.
static _sanitizeFilemame($a_filename)
This class handles all operations on files in directory /ilias_data/.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
unlinkFilesByMD5Filenames($a_md5_filename)
get file data of a specific attachment
__rotateFiles($a_path)
rotate files with same name recursive method
unlinkFile($a_filename)
unlink one uploaded file expects a filename e.g 'foo'
__construct(Container $dic, ilPlugin $plugin)
This class handles all operations on files for the forum object.
getFileDataByMD5Filename($a_md5_filename)
get file data of a specific attachment
ilClone($a_new_obj_id, $a_new_pos_id)
__initDirectory()
init directory overwritten method public
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getForumPath()
get forum path public
storeUploadedFile($files)
Store uploaded files in filesystem.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.