4require_once 
"Services/Mail/classes/class.ilFormatMail.php";
 
    5require_once 
"Services/Mail/classes/class.ilFileDataMail.php";
 
   39        public function __construct()
 
   53                $this->ctrl->saveParameter($this, 
'mobj_id');
 
   61                $forward_class = $this->ctrl->getNextClass($this);
 
   62                switch($forward_class)
 
   65                                if(!(
$cmd = $this->ctrl->getCmd()))
 
   67                                        $cmd = 
'showAttachments';
 
   76        public function saveAttachments()
 
   87                $size_of_selected_files = 0;
 
   88                if(is_array(
$_POST[
'filename']) && count(
$_POST[
'filename']) > 0)
 
   92                                if(file_exists($this->mfile->getMailPath() . 
'/' . basename(
$ilUser->getId() . 
'_' . urldecode(
$file))))
 
   95                                        $size_of_selected_files += filesize($this->mfile->getMailPath() . 
'/' . basename(
$ilUser->getId() . 
'_' . urldecode(
$file)));
 
  101                        null !== $this->mfile->getAttachmentsTotalSizeLimit() && 
 
  102                        $files && $size_of_selected_files > $this->mfile->getAttachmentsTotalSizeLimit()
 
  106                        return $this->showAttachments();
 
  109                $this->umail->saveAttachments(
$files);
 
  111                $this->ctrl->returnToParent($this);
 
  116                $this->ctrl->setParameter($this, 
'type', 
'attach');
 
  117                $this->ctrl->returnToParent($this);
 
  122                if(!isset(
$_POST[
'filename']) || !is_array(
$_POST[
'filename']) || !
$_POST[
'filename'])
 
  125                        $this->showAttachments();
 
  129                $this->tpl->setTitle($this->lng->txt(
'mail'));
 
  131                require_once 
'Services/Utilities/classes/class.ilConfirmationGUI.php';
 
  133                $confirmation->setFormAction($this->ctrl->getFormAction($this, 
'confirmDeleteAttachments'));
 
  134                $confirmation->setConfirm($this->lng->txt(
'confirm'), 
'confirmDeleteAttachments');
 
  135                $confirmation->setCancel($this->lng->txt(
'cancel'), 
'showAttachments');
 
  136                $confirmation->setHeaderText($this->lng->txt(
'mail_sure_delete_file'));
 
  143                $this->tpl->setContent($confirmation->getHtml());
 
  149                if(!isset(
$_POST[
'filename']) || !is_array(
$_POST[
'filename']) || !
$_POST[
'filename'])
 
  152                        $this->showAttachments();
 
  157                foreach(
$_POST[
'filename'] as $value)
 
  159                        $files[] = urldecode($value);
 
  162                if(strlen((
$error = $this->mfile->unlinkFiles(
$files))))
 
  168                        $mailData = $this->umail->getSavedData();
 
  169                        if(is_array($mailData[
'attachments']))
 
  172                                for($i = 0; $i < count($mailData[
'attachments']); $i++)
 
  174                                        if(!in_array($mailData[
'attachments'][$i], 
$files))
 
  176                                                $tmp[] = $mailData[
'attachments'][$i];
 
  179                                $this->umail->saveAttachments($tmp);
 
  185                $this->showAttachments();
 
  193                require_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  195                $attachment = 
new ilFileInputGUI($this->lng->txt(
'upload'), 
'userfile');
 
  196                $attachment->setRequired(
true);
 
  197                $attachment->setSize(20);
 
  198                $form->addItem($attachment);
 
  202        public function uploadFile()
 
  209                if(strlen(trim($_FILES[
'userfile'][
'name'])))
 
  212                        if($form->checkInput())
 
  214                                $this->mfile->storeUploadedFile($_FILES[
'userfile']);
 
  219                                if($form->getItemByPostVar(
'userfile')->getAlert() != 
$lng->txt(
"form_msg_file_size_exceeds"))
 
  234                $this->showAttachments();
 
  237        public function showAttachments()
 
  244                $this->tpl->setTitle($this->lng->txt(
'mail'));
 
  246                require_once 
'Services/Form/classes/class.ilFileInputGUI.php';
 
  247                $attachment = 
new ilFileInputGUI($this->lng->txt(
'upload'), 
'userfile');
 
  248                $attachment->setRequired(
true);
 
  249                $attachment->setSize(20);
 
  250                $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 
'uploadFile'), 
true);
 
  251                $ilToolbar->addInputItem($attachment);
 
  252                $ilToolbar->addFormButton($this->lng->txt(
'upload'), 
'uploadFile');
 
  254                require_once 
'Services/Mail/classes/class.ilMailAttachmentTableGUI.php';
 
  257                $mailData = $this->umail->getSavedData();
 
  258                $files    = $this->mfile->getUserFilesData();
 
  264                        if(is_array($mailData[
'attachments']) && in_array(
$file[
'name'], $mailData[
'attachments']))
 
  270                                'checked'       => $checked,
 
  271                                'filename'      => 
$file[
'name'],
 
  272                                'filesize'      => (
int)
$file[
'size'],
 
  273                                'filecreatedate'=> (
int)
$file[
'ctime']
 
  278                $table->setData(
$data);
 
  280                $this->tpl->setContent($table->getHtml());
 
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
This class handles all operations on files (attachments) in directory ilias_data/mail.
confirmDeleteAttachments()
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file