24 require_once
"Services/Mail/classes/class.ilFormatMail.php";
25 require_once
"classes/class.ilFileDataMail.php";
52 $this->ctrl->saveParameter($this,
"mobj_id");
60 $forward_class = $this->ctrl->getNextClass($this);
61 switch($forward_class)
64 if (!(
$cmd = $this->ctrl->getCmd()))
66 $cmd =
"showAttachments";
81 if(is_array($_POST[
'filename']) && count($_POST[
'filename']))
83 foreach($_POST[
'filename'] as
$file)
85 if(file_exists($this->mfile->getMailPath().
'/'.basename($ilUser->getId().
'_'.
$file)))
92 $this->umail->saveAttachments(
$files);
94 $this->ctrl->returnToParent($this);
99 $this->ctrl->setParameter($this,
"type",
"attach");
100 $this->ctrl->returnToParent($this);
105 if(!$_POST[
"filename"])
108 $this->errorDelete =
true;
120 if(!$_POST[
"filename"])
124 else if($error = $this->mfile->unlinkFiles($_POST[
"filename"]))
130 $mailData = $this->umail->getSavedData();
131 if (is_array($mailData[
"attachments"]))
134 for ($i = 0; $i < count($mailData[
"attachments"]); $i++)
136 if (!in_array($mailData[
"attachments"][$i], $_POST[
"filename"]))
138 $tmp[] = $mailData[
"attachments"][$i];
141 $mailData[
"attachments"] = $tmp;
142 $this->umail->saveAttachments($tmp);
158 if (trim($_FILES[
"userfile"][
"name"]) !=
"")
160 if($this->mfile->storeUploadedFile($_FILES[
"userfile"]) == 1)
162 ilUtil::sendInfo($this->lng->txt(
"mail_maxsize_attachment_error").
" ".$this->mfile->getUploadLimit().
" K".$this->lng->txt(
"mail_byte"));
173 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_attachment.html",
"Services/Mail");
174 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
175 $this->tpl->setVariable(
"TXT_ATTACHMENT",$this->lng->txt(
"attachment"));
177 $mailData = $this->umail->getSavedData();
179 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this,
'saveAttachments'));
180 $this->tpl->setVariable(
"UPLOAD", $this->ctrl->getFormAction($this,
'uploadFile'));
181 $this->ctrl->clearParameters($this);
184 if (isset($_POST[
"cmd"][
"deleteAttachments"]) &&
185 !$this->errorDelete &&
186 !isset($_POST[
"cmd"][
"confirm"]))
188 $this->tpl->setCurrentBlock(
"confirm_delete");
189 $this->tpl->setVariable(
"BUTTON_CONFIRM",$this->lng->txt(
"confirm"));
190 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
191 $this->tpl->parseCurrentBlock();
195 $this->tpl->setVariable(
"TXT_ATTACHMENT",$this->lng->txt(
"attachment"));
196 $this->tpl->setVariable(
"TXT_FILENAME",$this->lng->txt(
"mail_file_name"));
197 $this->tpl->setVariable(
"TXT_FILESIZE",$this->lng->txt(
"mail_file_size"));
198 $this->tpl->setVariable(
"TXT_CREATE_TIME",$this->lng->txt(
"create_date"));
199 $this->tpl->setVariable(
"TXT_NEW_FILE",$this->lng->txt(
"mail_new_file"));
202 $this->tpl->setVariable(
"BUTTON_ATTACHMENT_ADOPT",$this->lng->txt(
"adopt"));
203 $this->tpl->setVariable(
"BUTTON_ATTACHMENT_CANCEL",$this->lng->txt(
"cancel"));
204 $this->tpl->setVariable(
"BUTTON_ATTACHMENT_DELETE",$this->lng->txt(
"delete"));
207 $this->tpl->setVariable(
"BUTTON_SUBMIT",$this->lng->txt(
"submit"));
208 $this->tpl->setVariable(
"BUTTON_UPLOAD",$this->lng->txt(
"upload"));
211 if(
$files = $this->mfile->getUserFilesData())
216 $this->tpl->setCurrentBlock(
'files');
217 if((!isset($_POST[
"cmd"][
"deleteAttachments"]) && is_array($mailData[
"attachments"]) && in_array($file[
"name"],$mailData[
"attachments"])) ||
218 (isset($_POST[
"cmd"][
"deleteAttachments"]) && is_array($_POST[
"filename"]) && in_array($file[
"name"],$_POST[
"filename"])))
220 $this->tpl->setVariable(
"CHECKED",
'checked');
222 $this->tpl->setVariable(
'CSSROW',++$counter%2 ?
'tblrow1' :
'tblrow2');
223 $this->tpl->setVariable(
'FILE_NAME',$file[
"name"]);
224 $this->tpl->setVariable(
"NAME",$file[
"name"]);
225 $this->tpl->setVariable(
"SIZE",$file[
"size"]);
226 $this->tpl->setVariable(
"CTIME",$file[
"ctime"]);
227 $this->tpl->parseCurrentBlock();
232 $this->tpl->setCurrentBlock(
"no_content");
233 $this->tpl->setVariable(
"TXT_ATTACHMENT_NO",$this->lng->txt(
"mail_no_attachments_found"));
234 $this->tpl->parseCurrentBlock();
237 $this->tpl->setVariable(
"TXT_MARKED_ENTRIES",$this->lng->txt(
"marked_entries"));