41 $this->error = $DIC[
'ilErr'];
43 define(
'FORUM_PATH',
'forum');
44 parent::__construct();
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()
93 list(
$obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
96 'path' => $file->getPathname(),
97 'md5' => md5($this->obj_id .
'_' . $this->pos_id .
'_' .
$rest),
99 'size' => $file->getSize(),
100 'ctime' => date(
'Y-m-d H:i:s', $file->getCTime())
111 public function getFilesOfPost()
120 if ($file->isDir()) {
124 list(
$obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
125 if (
$obj_id == $this->obj_id) {
129 'path' => $file->getPathname(),
130 'md5' => md5($this->obj_id .
'_' . $this->pos_id .
'_' .
$rest),
132 'size' => $file->getSize(),
133 'ctime' => date(
'Y-m-d H:i:s', $file->getCTime())
146 public function moveFilesOfPost($a_new_frm_id = 0)
148 if ((
int) $a_new_frm_id) {
154 if ($file->isDir()) {
158 list(
$obj_id,
$rest) = explode(
'_', $file->getFilename(), 2);
159 if (
$obj_id == $this->obj_id) {
163 $file->getPathname(),
164 $this->forum_path .
'/' . $a_new_frm_id .
'_' . $this->pos_id .
'_' .
$rest 176 public function ilClone($a_new_obj_id, $a_new_pos_id)
178 foreach ($this->getFilesOfPost() as $file) {
180 $this->
getForumPath() .
"/" . $this->obj_id .
"_" . $this->pos_id .
"_" . $file[
"name"],
181 $this->
getForumPath() .
"/" . $a_new_obj_id .
"_" . $a_new_pos_id .
"_" . $file[
"name"]
186 public function delete()
188 foreach ($this->getFiles() as $file) {
207 if (isset(
$files[
'name']) && is_array(
$files[
'name'])) {
225 } elseif (isset(
$files[
'name']) && is_string(
$files[
'name'])) {
230 $temp_name =
$files[
'tmp_name'];
250 if (is_array($a_filenames)) {
251 foreach ($a_filenames as $file) {
267 if (file_exists($this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
'_' . $a_filename)) {
268 return unlink($this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
"_" . $a_filename);
279 return $this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
"_" . $a_path;
291 foreach ((array)
$files as $file) {
292 if ($file[
'type'] ==
'file' && md5($file[
'entry']) == $a_md5_filename) {
294 'path' => $this->forum_path .
'/' . $file[
'entry'],
295 'filename' => $file[
'entry'],
296 'clean_filename' => str_replace($this->obj_id .
'_' . $this->pos_id .
'_',
'', $file[
'entry'])
313 if (is_array($a_md5_filename)) {
314 foreach ((array)
$files as $file) {
315 if ($file[
'type'] ==
'file' && in_array(md5($file[
'entry']), $a_md5_filename)) {
316 unlink($this->forum_path .
'/' . $file[
'entry']);
322 foreach ((array)
$files as $file) {
323 if ($file[
'type'] ==
'file' && md5($file[
'entry']) == $a_md5_filename) {
324 return unlink($this->forum_path .
'/' . $file[
'entry']);
341 foreach ($a_files as $file) {
342 if (!file_exists($this->forum_path .
'/' . $this->obj_id .
'_' . $this->pos_id .
'_' . $file)) {
369 if (is_writable($this->forum_path) && is_readable($this->forum_path)) {
372 $this->error->raiseError(
"Forum directory is not readable/writable by webserver", $this->error->FATAL);
383 if (is_writable($this->
getPath())) {
384 if (mkdir($this->
getPath() .
'/' . FORUM_PATH)) {
385 if (chmod($this->
getPath() .
'/' . FORUM_PATH, 0755)) {
386 $this->forum_path = $this->
getPath() .
'/' . FORUM_PATH;
402 if (file_exists($a_path)) {
404 return \ilFileUtils::rename($a_path, $a_path .
'.old');
446 $filesOfPost = $this->getFilesOfPost();
451 foreach ($filesOfPost as $file) {
452 @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 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'
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.