4require_once(
"./Services/FileSystem/classes/class.ilFileData.php");
 
    5require_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
 
   44        $this->
error = $DIC[
'ilErr'];
 
   46        define(
'FORUM_PATH', 
'forum');
 
   47        parent::__construct();
 
   48        $this->forum_path = parent::getPath() . 
"/" . FORUM_PATH;
 
   54        $this->obj_id = $a_obj_id;
 
   55        $this->pos_id = $a_pos_id;
 
   68        $this->pos_id = $a_id;
 
   83    public function getFiles()
 
   87        foreach (
new DirectoryIterator($this->forum_path) as 
$file) {
 
   99                    'path'  => 
$file->getPathname(),
 
  100                    'md5'   => md5($this->obj_id . 
'_' . $this->pos_id . 
'_' . 
$rest),
 
  102                    'size'  => 
$file->getSize(),
 
  103                    'ctime' => 
date(
'Y-m-d H:i:s', 
$file->getCTime())
 
  114    public function getFilesOfPost()
 
  118        foreach (
new DirectoryIterator($this->forum_path) as 
$file) {
 
  123            if (
$file->isDir()) {
 
  128            if (
$obj_id == $this->obj_id) {
 
  132                        'path'  => 
$file->getPathname(),
 
  133                        'md5'   => md5($this->obj_id . 
'_' . $this->pos_id . 
'_' . 
$rest),
 
  135                        'size'  => 
$file->getSize(),
 
  136                        'ctime' => 
date(
'Y-m-d H:i:s', 
$file->getCTime())
 
  149    public function moveFilesOfPost($a_new_frm_id = 0)
 
  151        if ((
int) $a_new_frm_id) {
 
  152            foreach (
new DirectoryIterator($this->forum_path) as 
$file) {
 
  157                if (
$file->isDir()) {
 
  162                if (
$obj_id == $this->obj_id) {
 
  166                            $file->getPathname(),
 
  167                            $this->forum_path . 
'/' . $a_new_frm_id . 
'_' . $this->pos_id . 
'_' . 
$rest 
  179    public function ilClone($a_new_obj_id, $a_new_pos_id)
 
  181        foreach ($this->getFilesOfPost() as 
$file) {
 
  183                $this->
getForumPath() . 
"/" . $this->obj_id . 
"_" . $this->pos_id . 
"_" . 
$file[
"name"],
 
  184                $this->
getForumPath() . 
"/" . $a_new_obj_id . 
"_" . $a_new_pos_id . 
"_" . 
$file[
"name"]
 
  189    public function delete()
 
  191        foreach ($this->getFiles() as 
$file) {
 
  210        if (isset(
$files[
'name']) && is_array(
$files[
'name'])) {
 
  228        } elseif (isset(
$files[
'name']) && is_string(
$files[
'name'])) {
 
  233            $temp_name = 
$files[
'tmp_name'];
 
  253        if (is_array($a_filenames)) {
 
  254            foreach ($a_filenames as 
$file) {
 
  270        if (file_exists($this->forum_path . 
'/' . $this->obj_id . 
'_' . $this->pos_id . 
'_' . $a_filename)) {
 
  271            return unlink($this->forum_path . 
'/' . $this->obj_id . 
'_' . $this->pos_id . 
"_" . $a_filename);
 
  282        return $this->forum_path . 
'/' . $this->obj_id . 
'_' . $this->pos_id . 
"_" . $a_path;
 
  295            if (
$file[
'type'] == 
'file' && md5(
$file[
'entry']) == $a_md5_filename) {
 
  297                    'path' => $this->forum_path . 
'/' . 
$file[
'entry'],
 
  298                    'filename' => 
$file[
'entry'],
 
  299                    'clean_filename' => str_replace($this->obj_id . 
'_' . $this->pos_id . 
'_', 
'', 
$file[
'entry'])
 
  316        if (is_array($a_md5_filename)) {
 
  318                if (
$file[
'type'] == 
'file' && in_array(md5(
$file[
'entry']), $a_md5_filename)) {
 
  319                    unlink($this->forum_path . 
'/' . 
$file[
'entry']);
 
  326                if (
$file[
'type'] == 
'file' && md5(
$file[
'entry']) == $a_md5_filename) {
 
  327                    return unlink($this->forum_path . 
'/' . 
$file[
'entry']);
 
  344            foreach ($a_files as 
$file) {
 
  345                if (!file_exists($this->forum_path . 
'/' . $this->obj_id . 
'_' . $this->pos_id . 
'_' . 
$file)) {
 
  372        if (is_writable($this->forum_path) && is_readable($this->forum_path)) {
 
  375            $this->
error->raiseError(
"Forum directory is not readable/writable by webserver", $this->
error->FATAL);
 
  386        if (is_writable($this->
getPath())) {
 
  387            if (mkdir($this->
getPath() . 
'/' . FORUM_PATH)) {
 
  388                if (chmod($this->
getPath() . 
'/' . FORUM_PATH, 0755)) {
 
  389                    $this->forum_path = $this->
getPath() . 
'/' . FORUM_PATH;
 
  405        if (file_exists($a_path)) {
 
  407            return \ilFileUtils::rename($a_path, $a_path . 
'.old');
 
  449        $filesOfPost = $this->getFilesOfPost();
 
  454        foreach ($filesOfPost as 
$file) {
 
  455            @copy(
$file[
'path'], $tmp_dir . 
'/' . 
$file[
'name']);
 
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
This class handles all operations on files for the forum object.
__construct($a_obj_id=0, $a_pos_id=0)
Constructor call base constructors checks if directory is writable and sets the optional obj_id.
__rotateFiles($a_path)
rotate files with same name recursive method
getAbsolutePath($a_path)
get absolute path of filename
unlinkFilesByMD5Filenames($a_md5_filename)
get file data of a specific attachment
getFileDataByMD5Filename($a_md5_filename)
get file data of a specific attachment
__initDirectory()
init directory overwritten method @access public
getForumPath()
get forum path @access public
storeUploadedFile($files)
Store uploaded files in filesystem.
unlinkFile($a_filename)
unlink one uploaded file expects a filename e.g 'foo'
ilClone($a_new_obj_id, $a_new_pos_id)
__checkReadWrite()
check if directory is writable overwritten method from base class @access private
unlinkFiles($a_filenames)
unlink files: expects an array of filenames e.g.
checkFilesExist($a_files)
check if files exist
This class handles all operations on files in directory /ilias_data/.
getPath()
get Path @access public
static rename($a_source, $a_target)
Rename a file.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static _sanitizeFilemame($a_filename)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file