Public Member Functions | |
ilFileDataMail ($a_user_id=0) | |
Constructor call base constructors checks if directory is writable and sets the optional user_id. | |
initDirectory () | |
init directory overwritten method public | |
getUploadLimit () | |
getMailPath () | |
get mail path public | |
getAttachmentPath ($a_filename, $a_mail_id) | |
get the path of a specific attachment | |
adoptAttachments ($a_attachments, $a_mail_id) | |
adopt attachments (in case of forwarding a mail) | |
checkReadWrite () | |
check if directory is writable overwritten method from base class private | |
getUserFilesData () | |
get all attachments of a specific user public | |
getUnsentFiles () | |
get all files which are not sent find them in directory data/mail/ private | |
storeUploadedFile ($a_http_post_file) | |
store uploaded file in filesystem | |
copyAttachmentFile ($a_abs_path, $a_new_name) | |
Copy files in mail directory. | |
rotateFiles ($a_path) | |
rotate files with same name recursive method | |
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 | |
saveFiles ($a_mail_id, $a_attachments) | |
save all attachment files in a specific mail directory .../mail/<user_id>_<mail_id>/... | |
saveFile ($a_mail_id, $a_attachment) | |
save attachment file in a specific mail directory .../mail/<user_id>_<mail_id>/... | |
checkFilesExist ($a_files) | |
check if files exist | |
assignAttachmentsToDirectory ($a_mail_id, $a_sent_mail_id) | |
assign attachments to mail directory | |
deassignAttachmentFromDirectory ($a_mail_id) | |
dassign attachments from mail directory | |
__deleteAttachmentDirectory ($a_rel_path) | |
__initAttachmentMaxSize () | |
Data Fields | |
$user_id | |
$mail_path | |
$mail_maxsize_attach |
Definition at line 35 of file class.ilFileDataMail.php.
ilFileDataMail::__deleteAttachmentDirectory | ( | $ | a_rel_path | ) |
Definition at line 450 of file class.ilFileDataMail.php.
References $file.
Referenced by deassignAttachmentFromDirectory().
{ if(!@$dp = opendir($this->mail_path."/".$a_rel_path)) { return false; } while($file = @readdir($dp)) { if($file == '.' or $file == '..') { continue; } if(is_dir($file)) { $this->__deleteAttachmentDirectory($file); } unlink($this->mail_path."/".$a_rel_path."/".$file); } @rmdir($this->mail_path."/".$a_rel_path); closedir($dp); return true; }
ilFileDataMail::__initAttachmentMaxSize | ( | ) |
Definition at line 474 of file class.ilFileDataMail.php.
Referenced by ilFileDataMail().
{ $this->mail_maxsize_attach = $this->ilias->getSetting("mail_maxsize_attach") ? $this->ilias->getSetting("mail_maxsize_attach") * 1024 : 1024 * 1024 * 64; $this->mail_maxsize_attach_message = $this->ilias->getSetting("mail_maxsize_attach") ? $this->ilias->getSetting("mail_maxsize_attach") : ini_get("upload_max_filesize"); }
ilFileDataMail::adoptAttachments | ( | $ | a_attachments, | |
$ | a_mail_id | |||
) |
adopt attachments (in case of forwarding a mail)
array | attachments | |
integer | mail_id public |
Definition at line 140 of file class.ilFileDataMail.php.
References $file, ilFile::$path, getAttachmentPath(), and getMailPath().
{ if(is_array($a_attachments)) { foreach($a_attachments as $file) { $path = $this->getAttachmentPath($file,$a_mail_id); if(!copy($path,$this->getMailPath().'/'.$this->user_id.'_'.$file)) { return "ERROR: $this->getMailPath().'/'.$this->user_id.'_'.$file cannot be created"; } } } else { return "ARRAY REQUIRED"; } return ''; }
ilFileDataMail::assignAttachmentsToDirectory | ( | $ | a_mail_id, | |
$ | a_sent_mail_id | |||
) |
assign attachments to mail directory
integer | mail_id | |
integer | key for directory assignment public |
Definition at line 404 of file class.ilFileDataMail.php.
ilFileDataMail::checkFilesExist | ( | $ | a_files | ) |
check if files exist
array | filenames to check public |
Definition at line 382 of file class.ilFileDataMail.php.
References $file.
{ if($a_files) { foreach($a_files as $file) { if(!file_exists($this->mail_path.'/'.$this->user_id.'_'.$file)) { return false; } } return true; } return true; }
ilFileDataMail::checkReadWrite | ( | ) |
check if directory is writable overwritten method from base class private
Definition at line 166 of file class.ilFileDataMail.php.
Referenced by ilFileDataMail().
{ if(is_writable($this->mail_path) && is_readable($this->mail_path)) { return true; } else { $this->ilias->raiseError("Mail directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL); } }
ilFileDataMail::copyAttachmentFile | ( | $ | a_abs_path, | |
$ | a_new_name | |||
) |
Copy files in mail directory.
This is used for sending ILIAS generated mails with attachments
array | Array with files. Absolute path required public |
Definition at line 255 of file class.ilFileDataMail.php.
References getMailPath().
{ @copy($a_abs_path,$this->getMailPath()."/".$this->user_id."_".$a_new_name); return true; }
ilFileDataMail::deassignAttachmentFromDirectory | ( | $ | a_mail_id | ) |
dassign attachments from mail directory
integer | mail_id public |
Definition at line 417 of file class.ilFileDataMail.php.
References ilFile::$path, $query, $res, $row, and __deleteAttachmentDirectory().
{ // IF IT'S THE LAST MAIL CONTAINING THESE ATTACHMENTS => DELETE ATTACHMENTS $query = "SELECT path FROM mail_attachment ". "WHERE mail_id = '".$a_mail_id."'"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $path = $row->path; } if($path) { $query = "SELECT COUNT(mail_id) AS count_mail_id FROM mail_attachment ". "WHERE path = '".$path."'"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $cnt_mail_id = $row->count_mail_id; } if($cnt_mail_id == 1) { $this->__deleteAttachmentDirectory($path); } } $query = "DELETE FROM mail_attachment ". "WHERE mail_id = '".$a_mail_id."'"; $res = $this->ilias->db->query($query); return true; }
ilFileDataMail::getAbsolutePath | ( | $ | a_path | ) |
get absolute path of filename
string | relative path public |
Definition at line 319 of file class.ilFileDataMail.php.
{ return $this->mail_path.'/'.$this->user_id.'_'.$a_path; }
ilFileDataMail::getAttachmentPath | ( | $ | a_filename, | |
$ | a_mail_id | |||
) |
get the path of a specific attachment
string | filename | |
integer | mail_id public |
Definition at line 115 of file class.ilFileDataMail.php.
References ilFile::$path, $query, $row, and getMailPath().
Referenced by adoptAttachments().
{ $query = "SELECT path FROM mail_attachment ". "WHERE mail_id = '".$a_mail_id."'"; $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT); $path = $this->getMailPath().'/'.$row->path.'/'.$a_filename; if(file_exists($path)) { if(is_readable($path)) { return $path; } return ''; } return ''; }
ilFileDataMail::getMailPath | ( | ) |
get mail path public
Definition at line 103 of file class.ilFileDataMail.php.
Referenced by adoptAttachments(), copyAttachmentFile(), getAttachmentPath(), and storeUploadedFile().
{
return $this->mail_path;
}
ilFileDataMail::getUnsentFiles | ( | ) |
get all files which are not sent find them in directory data/mail/ private
Definition at line 194 of file class.ilFileDataMail.php.
References $file, $files, and ilFormat::formatDate().
Referenced by getUserFilesData().
{ $files = array(); $dp = opendir($this->mail_path); while($file = readdir($dp)) { if(is_dir($file)) { continue; } list($uid,$rest) = split('_',$file,2); if($uid == $this->user_id) { if(!is_dir($this->mail_path.'/'.$file)) { $files[] = array( 'name' => $rest, 'size' => filesize($this->mail_path.'/'.$file), 'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($this->mail_path.'/'.$file)))); } } } closedir($dp); return $files; }
ilFileDataMail::getUploadLimit | ( | ) |
Definition at line 93 of file class.ilFileDataMail.php.
{
return $this->mail_maxsize_attach_message;
}
ilFileDataMail::getUserFilesData | ( | ) |
get all attachments of a specific user public
Definition at line 182 of file class.ilFileDataMail.php.
References $files, and getUnsentFiles().
{ // FIRST GET FILES OF USER IN BASE DIRECTORY return $files = $this->getUnsentFiles(); }
ilFileDataMail::ilFileDataMail | ( | $ | a_user_id = 0 |
) |
Constructor call base constructors checks if directory is writable and sets the optional user_id.
integereger | user_id public |
Definition at line 60 of file class.ilFileDataMail.php.
References __initAttachmentMaxSize(), checkReadWrite(), ilFileData::getPath(), and ilFileData::ilFileData().
{ define('MAILPATH','mail'); parent::ilFileData(); $this->mail_path = parent::getPath()."/".MAILPATH; $this->checkReadWrite(); $this->user_id = $a_user_id; $this->__initAttachmentMaxSize(); }
ilFileDataMail::initDirectory | ( | ) |
init directory overwritten method public
Definition at line 78 of file class.ilFileDataMail.php.
References ilFileData::getPath().
{ if(is_writable($this->getPath())) { if(mkdir($this->getPath().'/'.MAILPATH)) { if(chmod($this->getPath().'/'.MAILPATH,0755)) { $this->mail_path = $this->getPath().'/'.MAILPATH; return true; } } } return false; }
ilFileDataMail::rotateFiles | ( | $ | a_path | ) |
rotate files with same name recursive method
string | filename private |
Definition at line 271 of file class.ilFileDataMail.php.
Referenced by storeUploadedFile().
{ if(file_exists($a_path)) { $this->rotateFiles($a_path.".old"); return rename($a_path,$a_path.'.old'); } return true; }
ilFileDataMail::saveFile | ( | $ | a_mail_id, | |
$ | a_attachment | |||
) |
save attachment file in a specific mail directory .../mail/<user_id>_<mail_id>/...
integer | mail id of mail in sent box | |
array | filenames to save public |
Definition at line 360 of file class.ilFileDataMail.php.
Referenced by saveFiles().
{ if(!is_dir($this->mail_path.'/'.$this->user_id.'_'.$a_mail_id)) { if(mkdir($this->mail_path.'/'.$this->user_id.'_'.$a_mail_id)) { chmod($this->mail_path.'/'.$this->user_id.'_'.$a_mail_id,0755); } else { return false; } } return copy($this->mail_path.'/'.$this->user_id.'_'.$a_attachment, $this->mail_path.'/'.$this->user_id.'_'.$a_mail_id.'/'.$a_attachment); }
ilFileDataMail::saveFiles | ( | $ | a_mail_id, | |
$ | a_attachments | |||
) |
save all attachment files in a specific mail directory .../mail/<user_id>_<mail_id>/...
integer | mail id of mail in sent box | |
array | filenames to save public |
Definition at line 331 of file class.ilFileDataMail.php.
References saveFile().
{ if(!$a_mail_id) { return "INTERNAL HERE ERROR: No valid mail_id given"; } if(is_array($a_attachments)) { foreach($a_attachments as $attachment) { if(!$this->saveFile($a_mail_id,$attachment)) { return $attachment; } } } else { return "ARRAY REQUIRED"; } return ''; }
ilFileDataMail::storeUploadedFile | ( | $ | a_http_post_file | ) |
store uploaded file in filesystem
array | HTTP_POST_FILES public |
Definition at line 226 of file class.ilFileDataMail.php.
References getMailPath(), ilUtil::moveUploadedFile(), and rotateFiles().
{ if($a_http_post_file["size"] >= $this->mail_maxsize_attach) { return 1; } if(isset($a_http_post_file) && $a_http_post_file['size']) { // CHECK IF FILE WITH SAME NAME EXISTS $this->rotateFiles($this->getMailPath().'/'.$this->user_id.'_'.$a_http_post_file['name']); ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'], $this->getMailPath().'/'.$this->user_id.'_'. $a_http_post_file['name']); //move_uploaded_file($a_http_post_file['tmp_name'],$this->getMailPath().'/'.$this->user_id.'_'. // $a_http_post_file['name']); return 0; } return 1; }
ilFileDataMail::unlinkFile | ( | $ | a_filename | ) |
unlink one uploaded file expects a filename e.g 'foo'
string | filename to delete public |
Definition at line 306 of file class.ilFileDataMail.php.
Referenced by unlinkFiles().
{ if(file_exists($this->mail_path.'/'.$this->user_id.'_'.$a_filename)) { return unlink($this->mail_path.'/'.$this->user_id.'_'.$a_filename); } }
ilFileDataMail::unlinkFiles | ( | $ | a_filenames | ) |
unlink files: expects an array of filenames e.g.
array('foo','bar')
array | filenames to delete public |
Definition at line 286 of file class.ilFileDataMail.php.
References $file, and unlinkFile().
{ if(is_array($a_filenames)) { foreach($a_filenames as $file) { if(!$this->unlinkFile($file)) { return $file; } } } return ''; }
ilFileDataMail::$mail_maxsize_attach |
Definition at line 51 of file class.ilFileDataMail.php.
ilFileDataMail::$mail_path |
Definition at line 49 of file class.ilFileDataMail.php.
ilFileDataMail::$user_id |
Definition at line 42 of file class.ilFileDataMail.php.