4 require_once(
"./Services/FileSystem/classes/class.ilFileData.php");
5 require_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
41 define(
'FORUM_PATH',
'forum');
42 parent::__construct();
43 $this->forum_path = parent::getPath().
"/".FORUM_PATH;
50 $this->obj_id = $a_obj_id;
51 $this->pos_id = $a_pos_id;
64 $this->pos_id = $a_id;
79 public function getFiles()
94 list($obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
95 if($obj_id == $this->obj_id)
98 'path' => $file->getPathname(),
99 'md5' => md5($this->obj_id .
'_' . $this->pos_id .
'_' .
$rest),
101 'size' => $file->getSize(),
113 public function getFilesOfPost()
128 list($obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
129 if($obj_id == $this->obj_id)
131 list($pos_id,
$rest) = explode(
'_',
$rest, 2);
135 'path' => $file->getPathname(),
136 'md5' => md5($this->obj_id .
'_' . $this->pos_id .
'_' .
$rest),
138 'size' => $file->getSize(),
152 public function moveFilesOfPost($a_new_frm_id = 0)
154 if((
int)$a_new_frm_id)
167 list($obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
168 if($obj_id == $this->obj_id)
170 list($pos_id,
$rest) = explode(
'_',
$rest, 2);
174 $file->getPathname(),
175 $this->forum_path .
'/' . $a_new_frm_id .
'_' . $this->pos_id .
'_' .
$rest 189 foreach($this->getFilesOfPost() as
$file)
191 @copy($this->
getForumPath().
"/".$this->obj_id.
"_".$this->pos_id.
"_".$file[
"name"],
192 $this->getForumPath().
"/".$a_new_obj_id.
"_".$a_new_pos_id.
"_".$file[
"name"]);
198 foreach($this->getFiles() as
$file)
219 if(isset($files[
'name']) && is_array($files[
'name']))
221 foreach($files[
'name'] as $index => $name)
224 while(substr($name, -1) ==
'/')
226 $name = substr($name, 0, -1);
229 $temp_name = $files[
'tmp_name'][$index];
230 $error = $files[
'error'][$index];
232 if(strlen(
$filename) && strlen($temp_name) && $error == 0)
243 else if(isset($files[
'name']) && is_string($files[
'name']))
246 while(substr($files[
'name'], -1) ==
'/')
248 $files[
'name'] = substr($files[
'name'], 0, -1);
251 $temp_name = $files[
'tmp_name'];
271 if(is_array($a_filenames))
273 foreach($a_filenames as
$file)
291 if(file_exists($this->forum_path.
'/'.$this->obj_id.
'_'.$this->pos_id.
'_'.$a_filename))
293 return unlink($this->forum_path.
'/'.$this->obj_id.
'_'.$this->pos_id.
"_".$a_filename);
304 return $this->forum_path.
'/'.$this->obj_id.
'_'.$this->pos_id.
"_".$a_path;
316 foreach((array)$files as
$file)
318 if($file[
'type'] ==
'file' && md5($file[
'entry']) == $a_md5_filename)
321 'path' => $this->forum_path.
'/'.$file[
'entry'],
322 'filename' => $file[
'entry'],
323 'clean_filename' => str_replace($this->obj_id.
'_'.$this->pos_id.
'_',
'', $file[
'entry'])
340 if(is_array($a_md5_filename))
342 foreach((array)$files as
$file)
344 if($file[
'type'] ==
'file' && in_array(md5($file[
'entry']), $a_md5_filename))
346 unlink( $this->forum_path.
'/'.$file[
'entry'] );
354 foreach((array)$files as
$file)
356 if($file[
'type'] ==
'file' && md5($file[
'entry']) == $a_md5_filename)
358 return unlink( $this->forum_path.
'/'.$file[
'entry'] );
376 foreach($a_files as
$file)
378 if(!file_exists($this->forum_path.
'/'.$this->obj_id.
'_'.$this->pos_id.
'_'.$file))
407 if(is_writable($this->forum_path) && is_readable($this->forum_path))
413 $this->
ilias->raiseError(
"Forum directory is not readable/writable by webserver",$this->
ilias->error_obj->FATAL);
424 if(is_writable($this->
getPath()))
426 if(mkdir($this->
getPath().
'/'.FORUM_PATH))
428 if(chmod($this->
getPath().
'/'.FORUM_PATH,0755))
430 $this->forum_path = $this->
getPath().
'/'.FORUM_PATH;
446 if(file_exists($a_path))
449 return \ilFileUtils::rename($a_path, $a_path .
'.old');
checkFilesExist($a_files)
check if files exist
unlinkFiles($a_filenames)
unlink files: expects an array of filenames e.g.
__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
redirection script todo: (a better solution should control the processing via a xml file) ...
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'
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
getForumPath()
get forum path public
storeUploadedFile($files)
Store uploaded files in filesystem.