Public Member Functions | |
ilFileDataForum ($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 | |
getFiles () | |
getFilesOfPost () | |
ilClone ($a_new_obj_id, $a_new_pos_id) | |
delete () | |
storeUploadedFile ($a_http_post_file) | |
store uploaded file 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 | |
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 | |
Data Fields | |
$obj_id | |
$pos_id | |
$forum_path |
Definition at line 35 of file class.ilFileDataForum.php.
ilFileDataForum::__checkPath | ( | ) |
Definition at line 265 of file class.ilFileDataForum.php.
References __checkReadWrite(), and getForumPath().
Referenced by ilFileDataForum().
{ if(!@file_exists($this->getForumPath())) { return false; } $this->__checkReadWrite(); return true; }
ilFileDataForum::__checkReadWrite | ( | ) |
check if directory is writable overwritten method from base class private
Definition at line 281 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); } }
ilFileDataForum::__initDirectory | ( | ) |
init directory overwritten method public
Definition at line 298 of file class.ilFileDataForum.php.
References ilFileData::getPath().
Referenced by ilFileDataForum().
{ 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; }
ilFileDataForum::__rotateFiles | ( | $ | a_path | ) |
rotate files with same name recursive method
string | filename private |
Definition at line 320 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; }
ilFileDataForum::checkFilesExist | ( | $ | a_files | ) |
check if files exist
array | filenames to check public |
Definition at line 248 of file class.ilFileDataForum.php.
References $file.
{ 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 162 of file class.ilFileDataForum.php.
References $file, getFiles(), 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; }
ilFileDataForum::getAbsolutePath | ( | $ | a_path | ) |
get absolute path of filename
string | relative path public |
Definition at line 237 of file class.ilFileDataForum.php.
{ return $this->forum_path.'/'.$this->obj_id.'_'.$this->pos_id."_".$a_path; }
ilFileDataForum::getFiles | ( | ) |
Definition at line 96 of file class.ilFileDataForum.php.
References $file, $files, $obj_id, and ilFormat::formatDate().
Referenced by delete().
{ $files = array(); $dp = opendir($this->forum_path); while($file = readdir($dp)) { if(is_dir($file)) { continue; } list($obj_id,$rest) = split('_',$file,2); if($obj_id == $this->obj_id) { if(!is_dir($this->forum_path.'/'.$file)) { $files[] = array( 'name' => $rest, 'size' => filesize($this->forum_path.'/'.$file), 'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($this->forum_path.'/'.$file)))); } } } closedir($dp); return $files; }
ilFileDataForum::getFilesOfPost | ( | ) |
Definition at line 122 of file class.ilFileDataForum.php.
References $file, $files, $obj_id, $pos_id, ilFormat::formatDate(), and getPosId().
Referenced by ilClone().
{ $files = array(); $dp = opendir($this->forum_path); while($file = readdir($dp)) { if(is_dir($file)) { continue; } list($obj_id,$rest) = split('_',$file,2); if($obj_id == $this->obj_id) { list($pos_id,$rest) = split('_',$rest,2); if($pos_id == $this->getPosId()) { if(!is_dir($this->forum_path.'/'.$file)) { $files[] = array( 'name' => $rest, 'size' => filesize($this->forum_path.'/'.$file), 'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($this->forum_path.'/'.$file)))); } } } } closedir($dp); return $files; }
ilFileDataForum::getForumPath | ( | ) |
get forum path public
Definition at line 91 of file class.ilFileDataForum.php.
Referenced by __checkPath(), delete(), ilClone(), and storeUploadedFile().
{
return $this->forum_path;
}
ilFileDataForum::getObjId | ( | ) |
Definition at line 74 of file class.ilFileDataForum.php.
Referenced by delete().
{
return $this->obj_id;
}
ilFileDataForum::getPosId | ( | ) |
Definition at line 78 of file class.ilFileDataForum.php.
Referenced by getFilesOfPost().
{
return $this->pos_id;
}
ilFileDataForum::ilClone | ( | $ | a_new_obj_id, | |
$ | a_new_pos_id | |||
) |
Definition at line 153 of file class.ilFileDataForum.php.
References $file, getFilesOfPost(), and 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; }
ilFileDataForum::ilFileDataForum | ( | $ | a_obj_id = 0 , |
|
$ | a_pos_id = 0 | |||
) |
Constructor call base constructors checks if directory is writable and sets the optional obj_id.
integereger | obj_id public |
Definition at line 59 of file class.ilFileDataForum.php.
References __checkPath(), __initDirectory(), ilFileData::getPath(), and ilFileData::ilFileData().
{ define('FORUM_PATH','forum'); parent::ilFileData(); $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; }
ilFileDataForum::setPosId | ( | $ | a_id | ) |
Definition at line 82 of file class.ilFileDataForum.php.
{ $this->pos_id = $a_id; }
ilFileDataForum::storeUploadedFile | ( | $ | a_http_post_file | ) |
store uploaded file in filesystem
array | HTTP_POST_FILES public |
Definition at line 180 of file class.ilFileDataForum.php.
References __rotateFiles(), getForumPath(), and ilUtil::moveUploadedFile().
{ // TODO: // CHECK UPLOAD LIMIT // if(isset($a_http_post_file) && $a_http_post_file['size']) { // CHECK IF FILE WITH SAME NAME EXISTS $this->__rotateFiles($this->getForumPath().'/'.$this->obj_id.'_'.$this->pos_id."_".$a_http_post_file['name']); ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'], $this->getForumPath().'/'.$this->obj_id.'_'.$this->pos_id."_". $a_http_post_file['name']); //move_uploaded_file($a_http_post_file['tmp_name'],$this->getForumPath().'/'.$this->obj_id.'_'.$this->pos_id."_". // $a_http_post_file['name']); } return true; }
ilFileDataForum::unlinkFile | ( | $ | a_filename | ) |
unlink one uploaded file expects a filename e.g 'foo'
string | filename to delete public |
Definition at line 224 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); } }
ilFileDataForum::unlinkFiles | ( | $ | a_filenames | ) |
unlink files: expects an array of filenames e.g.
array('foo','bar')
array | filenames to delete public |
Definition at line 204 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 ''; }
ilFileDataForum::$forum_path |
Definition at line 50 of file class.ilFileDataForum.php.
ilFileDataForum::$obj_id |
Definition at line 42 of file class.ilFileDataForum.php.
Referenced by getFiles(), and getFilesOfPost().
ilFileDataForum::$pos_id |
Definition at line 43 of file class.ilFileDataForum.php.
Referenced by getFilesOfPost().