public function saveAttachments() { /** * @var $ilUser ilObjUser */ global $ilUser; $files = array(); if (count($_POST['filename']) == 0) { ilUtil::sendFailure($this->lng->txt('mail_select_one_file')); return $this->showAttachments(); } if (is_array($_POST['filename']) && count($_POST['filename']) > 0) { foreach ($_POST['filename'] as $file) { if (file_exists($this->mfile->getMailPath() . '/' . basename($ilUser->getId() . '_' . urldecode($file)))) { $files[] = urldecode($file); } } } $this->umail->saveAttachments($files); $this->ctrl->returnToParent($this); }
public function saveAttachments() { /** * @var $ilUser ilObjUser */ global $ilUser; $files = array(); // Important: Do not check for uploaded files here, otherwise it is no more possible to remove files (please ignore bug reports like 10137) $size_of_selected_files = 0; if (is_array($_POST['filename']) && count($_POST['filename']) > 0) { foreach ($_POST['filename'] as $file) { if (file_exists($this->mfile->getMailPath() . '/' . basename($ilUser->getId() . '_' . urldecode($file)))) { $files[] = urldecode($file); $size_of_selected_files += filesize($this->mfile->getMailPath() . '/' . basename($ilUser->getId() . '_' . urldecode($file))); } } } if (null !== $this->mfile->getAttachmentsTotalSizeLimit() && $files && $size_of_selected_files > $this->mfile->getAttachmentsTotalSizeLimit()) { ilUtil::sendFailure($this->lng->txt('mail_max_size_attachments_total_error') . ' ' . ilFormat::formatSize($this->mfile->getAttachmentsTotalSizeLimit())); return $this->showAttachments(); } $this->umail->saveAttachments($files); $this->ctrl->returnToParent($this); }