4 require_once 
"Services/Mail/classes/class.ilFormatMail.php";
 
    5 require_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()
 
   85                 if(count(
$_POST[
'filename']) == 0)
 
   88                         return $this->showAttachments();
 
   91                 if(is_array(
$_POST[
'filename']) && count(
$_POST[
'filename']) > 0)
 
   95                                 if(file_exists($this->mfile->getMailPath() . 
'/' . basename($ilUser->getId() . 
'_' . urldecode($file))))
 
   97                                         $files[] = urldecode($file);
 
  102                 $this->umail->saveAttachments($files);
 
  104                 $this->ctrl->returnToParent($this);
 
  109                 $this->ctrl->setParameter($this, 
'type', 
'attach');
 
  110                 $this->ctrl->returnToParent($this);
 
  115                 if(!isset(
$_POST[
'filename']) || !is_array(
$_POST[
'filename']) || !
$_POST[
'filename'])
 
  118                         $this->showAttachments();
 
  122                 $this->tpl->setTitle($this->lng->txt(
'mail'));
 
  124                 require_once 
'Services/Utilities/classes/class.ilConfirmationGUI.php';
 
  126                 $confirmation->setFormAction($this->ctrl->getFormAction($this, 
'confirmDeleteAttachments'));
 
  127                 $confirmation->setConfirm($this->lng->txt(
'confirm'), 
'confirmDeleteAttachments');
 
  128                 $confirmation->setCancel($this->lng->txt(
'cancel'), 
'showAttachments');
 
  129                 $confirmation->setHeaderText($this->lng->txt(
'mail_sure_delete_file'));
 
  136                 $this->tpl->setContent($confirmation->getHtml());
 
  142                 if(!isset(
$_POST[
'filename']) || !is_array(
$_POST[
'filename']) || !
$_POST[
'filename'])
 
  145                         $this->showAttachments();
 
  150                 foreach(
$_POST[
'filename'] as $value)
 
  152                         $files[] = urldecode($value);
 
  155                 if(strlen(($error = $this->mfile->unlinkFiles($files))))
 
  161                         $mailData = $this->umail->getSavedData();
 
  162                         if(is_array($mailData[
'attachments']))
 
  165                                 for($i = 0; $i < count($mailData[
'attachments']); $i++)
 
  167                                         if(!in_array($mailData[
'attachments'][$i], $files))
 
  169                                                 $tmp[] = $mailData[
'attachments'][$i];
 
  172                                 $this->umail->saveAttachments($tmp);
 
  178                 $this->showAttachments();
 
  183                 if(strlen(trim($_FILES[
'userfile'][
'name'])))
 
  185                         if($this->mfile->storeUploadedFile($_FILES[
'userfile']) == 1)
 
  191                 $this->showAttachments();
 
  194         public function showAttachments()
 
  201                 $this->tpl->setTitle($this->lng->txt(
'mail'));
 
  203                 require_once 
'Services/Form/classes/class.ilFileInputGUI.php';
 
  204                 $attachment = 
new ilFileInputGUI($this->lng->txt(
'upload'), 
'userfile');
 
  206                 $attachment->setSize(20);
 
  207                 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 
'uploadFile'), 
true);
 
  208                 $ilToolbar->addInputItem($attachment);
 
  209                 $ilToolbar->addFormButton($this->lng->txt(
'upload'), 
'uploadFile');
 
  211                 require_once 
'Services/Mail/classes/class.ilMailAttachmentTableGUI.php';
 
  214                 $mailData = $this->umail->getSavedData();
 
  215                 $files    = $this->mfile->getUserFilesData();
 
  218                 foreach($files as $file)
 
  221                         if(is_array($mailData[
'attachments']) && in_array($file[
'name'], $mailData[
'attachments']))
 
  226                         $data[$counter] = array(
 
  227                                 'checked'       => $checked,
 
  228                                 'filename'      => $file[
'name'],
 
  229                                 'filesize'      => (
int)$file[
'size'],
 
  230                                 'filecreatedate'=> (
int)$file[
'ctime']
 
  235                 $table->setData(
$data);
 
  237                 $this->tpl->setContent($table->getHtml());