4 require_once
'Services/Mail/classes/class.ilFormatMail.php';
5 require_once
'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()
86 $this->showAttachments();
93 if(file_exists($this->mfile->getMailPath() .
'/' . basename($ilUser->getId() .
'_' . urldecode($file))))
95 $files[] = urldecode($file);
99 $this->umail->saveAttachments(
$files);
101 $this->ctrl->returnToParent($this);
106 $this->ctrl->setParameter($this,
'type',
'attach');
107 $this->ctrl->returnToParent($this);
112 if(!isset(
$_POST[
'filename']) || !is_array(
$_POST[
'filename']) || !
$_POST[
'filename'])
115 $this->showAttachments();
119 $this->tpl->setTitle($this->lng->txt(
'mail'));
121 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
123 $confirmation->setFormAction($this->ctrl->getFormAction($this,
'confirmDeleteAttachments'));
124 $confirmation->setConfirm($this->lng->txt(
'confirm'),
'confirmDeleteAttachments');
125 $confirmation->setCancel($this->lng->txt(
'cancel'),
'showAttachments');
126 $confirmation->setHeaderText($this->lng->txt(
'mail_sure_delete_file'));
133 $this->tpl->setContent($confirmation->getHtml());
139 if(!isset(
$_POST[
'filename']) || !is_array(
$_POST[
'filename']) || !
$_POST[
'filename'])
142 $this->showAttachments();
147 foreach(
$_POST[
'filename'] as $value)
149 $files[] = urldecode($value);
152 if(strlen(($error = $this->mfile->unlinkFiles(
$files))))
158 $mailData = $this->umail->getSavedData();
159 if(is_array($mailData[
'attachments']))
162 for($i = 0; $i < count($mailData[
'attachments']); $i++)
164 if(!in_array($mailData[
'attachments'][$i],
$files))
166 $tmp[] = $mailData[
'attachments'][$i];
169 $this->umail->saveAttachments($tmp);
175 $this->showAttachments();
180 if(strlen(trim($_FILES[
'userfile'][
'name'])))
182 if($this->mfile->storeUploadedFile($_FILES[
'userfile']) == 1)
188 $this->showAttachments();
191 public function showAttachments()
198 $this->tpl->setTitle($this->lng->txt(
'mail'));
200 require_once
'Services/Form/classes/class.ilFileInputGUI.php';
201 $attachment =
new ilFileInputGUI($this->lng->txt(
'upload'),
'userfile');
203 $attachment->setSize(20);
204 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
'uploadFile'),
true);
205 $ilToolbar->addInputItem($attachment);
206 $ilToolbar->addFormButton($this->lng->txt(
'upload'),
'uploadFile');
208 require_once
'Services/Mail/classes/class.ilMailAttachmentTableGUI.php';
211 $mailData = $this->umail->getSavedData();
212 $files = $this->mfile->getUserFilesData();
218 if(is_array($mailData[
'attachments']) && in_array($file[
'name'], $mailData[
'attachments']))
223 $data[$counter] = array(
224 'checked' => $checked,
225 'filename' => $file[
'name'],
226 'filesize' => (
int)$file[
'size'],
227 'filecreatedate'=> (
int)$file[
'ctime']
232 $table->setData(
$data);
234 $this->tpl->setContent($table->getHtml());