ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilFileDataForum Class Reference

This class handles all operations on files for the forum object. More...

+ Inheritance diagram for ilFileDataForum:
+ Collaboration diagram for ilFileDataForum:

Public Member Functions

 __construct ($a_obj_id=0, $a_pos_id=0)
 Constructor call base constructors checks if directory is writable and sets the optional obj_id.
 getObjId ()
 getPosId ()
 setPosId ($a_id)
 getForumPath ()
 get forum path public
 ilClone ($a_new_obj_id, $a_new_pos_id)
 delete ()
 storeUploadedFile ($files)
 Store uploaded files in filesystem.
 unlinkFiles ($a_filenames)
 unlink files: expects an array of filenames e.g.
 unlinkFile ($a_filename)
 unlink one uploaded file expects a filename e.g 'foo'
 getAbsolutePath ($a_path)
 get absolute path of filename
 getFileDataByMD5Filename ($a_md5_filename)
 get file data of a specific attachment
 unlinkFilesByMD5Filenames ($a_md5_filename)
 get file data of a specific attachment
 checkFilesExist ($a_files)
 check if files exist
 __checkPath ()
 __checkReadWrite ()
 check if directory is writable overwritten method from base class private
 __initDirectory ()
 init directory overwritten method public
 __rotateFiles ($a_path)
 rotate files with same name recursive method
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object public.
 checkPath ($a_path)
 check if path exists and is writable
 getPath ()
 get Path public
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object public.
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables

Data Fields

 $obj_id
 $pos_id
 $forum_path

Detailed Description

This class handles all operations on files for the forum object.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilFileDataForum.php 61402 2015-12-02 16:10:13Z gitmgr

Definition at line 14 of file class.ilFileDataForum.php.

Constructor & Destructor Documentation

ilFileDataForum::__construct (   $a_obj_id = 0,
  $a_pos_id = 0 
)

Constructor call base constructors checks if directory is writable and sets the optional obj_id.

Parameters
integeregerobj_id public

Definition at line 38 of file class.ilFileDataForum.php.

References __checkPath(), __initDirectory(), and ilFileData\getPath().

{
define('FORUM_PATH', 'forum');
$this->forum_path = parent::getPath()."/".FORUM_PATH;
// IF DIRECTORY ISN'T CREATED CREATE IT
if(!$this->__checkPath())
{
$this->__initDirectory();
}
$this->obj_id = $a_obj_id;
$this->pos_id = $a_pos_id;
}

+ Here is the call graph for this function:

Member Function Documentation

ilFileDataForum::__checkPath ( )

Definition at line 385 of file class.ilFileDataForum.php.

References __checkReadWrite(), and getForumPath().

Referenced by __construct().

{
if(!@file_exists($this->getForumPath()))
{
return false;
}
$this->__checkReadWrite();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileDataForum::__checkReadWrite ( )

check if directory is writable overwritten method from base class private

Returns
bool

Definition at line 401 of file class.ilFileDataForum.php.

Referenced by __checkPath().

{
if(is_writable($this->forum_path) && is_readable($this->forum_path))
{
return true;
}
else
{
$this->ilias->raiseError("Forum directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
}
}

+ Here is the caller graph for this function:

ilFileDataForum::__initDirectory ( )

init directory overwritten method public

Returns
string path

Definition at line 418 of file class.ilFileDataForum.php.

References ilFileData\getPath().

Referenced by __construct().

{
if(is_writable($this->getPath()))
{
if(mkdir($this->getPath().'/'.FORUM_PATH))
{
if(chmod($this->getPath().'/'.FORUM_PATH,0755))
{
$this->forum_path = $this->getPath().'/'.FORUM_PATH;
return true;
}
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileDataForum::__rotateFiles (   $a_path)

rotate files with same name recursive method

Parameters
stringfilename private
Returns
bool

Definition at line 440 of file class.ilFileDataForum.php.

Referenced by storeUploadedFile().

{
if(file_exists($a_path))
{
$this->__rotateFiles($a_path.".old");
return rename($a_path,$a_path.'.old');
}
return true;
}

+ Here is the caller graph for this function:

ilFileDataForum::checkFilesExist (   $a_files)

check if files exist

Parameters
arrayfilenames to check public
Returns
bool

Definition at line 368 of file class.ilFileDataForum.php.

{
if($a_files)
{
foreach($a_files as $file)
{
if(!file_exists($this->forum_path.'/'.$this->obj_id.'_'.$this->pos_id.'_'.$file))
{
return false;
}
}
return true;
}
return true;
}
ilFileDataForum::delete ( )

Definition at line 192 of file class.ilFileDataForum.php.

References $file, getForumPath(), and getObjId().

{
foreach($this->getFiles() as $file)
{
if(file_exists($this->getForumPath()."/".$this->getObjId()."_".$file["name"]))
{
unlink($this->getForumPath()."/".$this->getObjId()."_".$file["name"]);
}
}
return true;
}

+ Here is the call graph for this function:

ilFileDataForum::getAbsolutePath (   $a_path)

get absolute path of filename

Parameters
stringrelative path public
Returns
string absolute path

Definition at line 298 of file class.ilFileDataForum.php.

{
return $this->forum_path.'/'.$this->obj_id.'_'.$this->pos_id."_".$a_path;
}
ilFileDataForum::getFileDataByMD5Filename (   $a_md5_filename)

get file data of a specific attachment

Parameters
stringmd5 encrypted filename public
Returns
array filedata

Definition at line 309 of file class.ilFileDataForum.php.

References ilUtil\getDir().

{
$files = ilUtil::getDir( $this->forum_path );
foreach((array)$files as $file)
{
if($file['type'] == 'file' && md5($file['entry']) == $a_md5_filename)
{
return array(
'path' => $this->forum_path.'/'.$file['entry'],
'filename' => $file['entry'],
'clean_filename' => str_replace($this->obj_id.'_'.$this->pos_id.'_', '', $file['entry'])
);
}
}
return false;
}

+ Here is the call graph for this function:

ilFileDataForum::getForumPath ( )

get forum path public

Returns
string path

Definition at line 70 of file class.ilFileDataForum.php.

References $forum_path.

Referenced by __checkPath(), delete(), ilClone(), and storeUploadedFile().

{
}

+ Here is the caller graph for this function:

ilFileDataForum::getObjId ( )

Definition at line 53 of file class.ilFileDataForum.php.

References $obj_id.

Referenced by delete().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

ilFileDataForum::getPosId ( )

Definition at line 57 of file class.ilFileDataForum.php.

References $pos_id.

{
return $this->pos_id;
}
ilFileDataForum::ilClone (   $a_new_obj_id,
  $a_new_pos_id 
)

Definition at line 183 of file class.ilFileDataForum.php.

References getForumPath().

{
foreach($this->getFilesOfPost() as $file)
{
@copy($this->getForumPath()."/".$this->obj_id."_".$this->pos_id."_".$file["name"],
$this->getForumPath()."/".$a_new_obj_id."_".$a_new_pos_id."_".$file["name"]);
}
return true;
}

+ Here is the call graph for this function:

ilFileDataForum::setPosId (   $a_id)

Definition at line 61 of file class.ilFileDataForum.php.

{
$this->pos_id = $a_id;
}
ilFileDataForum::storeUploadedFile (   $files)

Store uploaded files in filesystem.

Parameters
array$filesCopy of $_FILES array, public
Returns
bool

Definition at line 213 of file class.ilFileDataForum.php.

References $filename, ilFile\$path, __rotateFiles(), ilUtil\_sanitizeFilemame(), getForumPath(), and ilUtil\moveUploadedFile().

{
if(isset($files['name']) && is_array($files['name']))
{
foreach($files['name'] as $index => $name)
{
// remove trailing '/'
while(substr($name, -1) == '/')
{
$name = substr($name, 0, -1);
}
$temp_name = $files['tmp_name'][$index];
$error = $files['error'][$index];
if(strlen($filename) && strlen($temp_name) && $error == 0)
{
$path = $this->getForumPath().'/'.$this->obj_id.'_'.$this->pos_id.'_'.$filename;
}
}
return true;
}
else if(isset($files['name']) && is_string($files['name']))
{
// remove trailing '/'
while(substr($files['name'], -1) == '/')
{
$files['name'] = substr($files['name'], 0, -1);
}
$temp_name = $files['tmp_name'];
$path = $this->getForumPath().'/'.$this->obj_id.'_'.$this->pos_id.'_'.$filename;
return true;
}
return false;
}

+ Here is the call graph for this function:

ilFileDataForum::unlinkFile (   $a_filename)

unlink one uploaded file expects a filename e.g 'foo'

Parameters
stringfilename to delete public
Returns
bool

Definition at line 285 of file class.ilFileDataForum.php.

Referenced by unlinkFiles().

{
if(file_exists($this->forum_path.'/'.$this->obj_id.'_'.$this->pos_id.'_'.$a_filename))
{
return unlink($this->forum_path.'/'.$this->obj_id.'_'.$this->pos_id."_".$a_filename);
}
}

+ Here is the caller graph for this function:

ilFileDataForum::unlinkFiles (   $a_filenames)

unlink files: expects an array of filenames e.g.

array('foo','bar')

Parameters
arrayfilenames to delete public
Returns
string error message with filename that couldn't be deleted

Definition at line 265 of file class.ilFileDataForum.php.

References $file, and unlinkFile().

{
if(is_array($a_filenames))
{
foreach($a_filenames as $file)
{
if(!$this->unlinkFile($file))
{
return $file;
}
}
}
return '';
}

+ Here is the call graph for this function:

ilFileDataForum::unlinkFilesByMD5Filenames (   $a_md5_filename)

get file data of a specific attachment

Parameters
string|arraymd5 encrypted filename or array of multiple md5 encrypted files public
Returns
boolean status

Definition at line 333 of file class.ilFileDataForum.php.

References ilUtil\getDir().

{
$files = ilUtil::getDir( $this->forum_path );
if(is_array($a_md5_filename))
{
foreach((array)$files as $file)
{
if($file['type'] == 'file' && in_array(md5($file['entry']), $a_md5_filename))
{
unlink( $this->forum_path.'/'.$file['entry'] );
}
}
return true;
}
else
{
foreach((array)$files as $file)
{
if($file['type'] == 'file' && md5($file['entry']) == $a_md5_filename)
{
return unlink( $this->forum_path.'/'.$file['entry'] );
}
}
}
return false;
}

+ Here is the call graph for this function:

Field Documentation

ilFileDataForum::$forum_path

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

Referenced by getForumPath().

ilFileDataForum::$obj_id

Definition at line 21 of file class.ilFileDataForum.php.

Referenced by getObjId().

ilFileDataForum::$pos_id

Definition at line 22 of file class.ilFileDataForum.php.

Referenced by getPosId().


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