public function confirmDeleteAttachments()
 {
     if (!isset($_POST['filename']) || !is_array($_POST['filename']) || !$_POST['filename']) {
         ilUtil::sendInfo($this->lng->txt('mail_select_one_mail'));
         $this->showAttachments();
         return true;
     }
     $files = array();
     foreach ($_POST['filename'] as $value) {
         $files[] = urldecode($value);
     }
     if (strlen($error = $this->mfile->unlinkFiles($files))) {
         ilUtil::sendFailure($this->lng->txt('mail_error_delete_file') . ' ' . $error);
     } else {
         $mailData = $this->umail->getSavedData();
         if (is_array($mailData['attachments'])) {
             $tmp = array();
             for ($i = 0; $i < count($mailData['attachments']); $i++) {
                 if (!in_array($mailData['attachments'][$i], $files)) {
                     $tmp[] = $mailData['attachments'][$i];
                 }
             }
             $this->umail->saveAttachments($tmp);
         }
         ilUtil::sendSuccess($this->lng->txt('mail_files_deleted'));
     }
     $this->showAttachments();
 }
Example #2
0
 public function sendAdvancedNotification($active_id)
 {
     include_once "./Modules/Test/classes/class.ilTestMailNotification.php";
     $mail = new ilTestMailNotification();
     $owner_id = $this->getOwner();
     $usr_data = $this->userLookupFullName(ilObjTest::_getUserIdFromActiveId($active_id));
     include_once "./Modules/Test/classes/class.ilTestExport.php";
     $exportObj = new ilTestExport($this, "results");
     $file = $exportObj->exportToExcel($deliver = FALSE, 'active_id', $active_id, $passedonly = FALSE);
     include_once "./Services/Mail/classes/class.ilFileDataMail.php";
     $fd = new ilFileDataMail(ANONYMOUS_USER_ID);
     $fd->copyAttachmentFile($file, "result_" . $active_id . ".xls");
     $file_names[] = "result_" . $active_id . ".xls";
     $mail->sendAdvancedNotification($owner_id, $this->getTitle(), $usr_data, $file_names);
     if (count($file_names)) {
         $fd->unlinkFiles($file_names);
         unset($fd);
         @unlink($file);
     }
 }
 /**
  * send exercise per mail to members
  */
 function sendAssignment($a_exc_id, $a_ass_id, $a_members)
 {
     include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
     $ass_title = ilExAssignment::lookupTitle($a_ass_id);
     include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
     $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id);
     $files = $storage->getFiles();
     if (count($files)) {
         include_once "./Services/Mail/classes/class.ilFileDataMail.php";
         $mfile_obj = new ilFileDataMail($_SESSION["AccountId"]);
         foreach ($files as $file) {
             $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
             $file_names[] = $file["name"];
         }
     }
     include_once "Services/Mail/classes/class.ilMail.php";
     $tmp_mail_obj = new ilMail($_SESSION["AccountId"]);
     $message = $tmp_mail_obj->sendMail($this->__formatRecipients($a_members), "", "", $this->__formatSubject($ass_title), $this->__formatBody($a_ass_id), count($file_names) ? $file_names : array(), array("normal"));
     unset($tmp_mail_obj);
     if (count($file_names)) {
         $mfile_obj->unlinkFiles($file_names);
         unset($mfile_obj);
     }
     // SET STATUS SENT FOR ALL RECIPIENTS
     foreach ($a_members as $member_id => $value) {
         ilExAssignment::updateStatusSentForUser($a_ass_id, $member_id, 1);
     }
     return true;
 }
 /**
  * Delete attachments
  */
 protected function deleteAttachments()
 {
     include_once './Services/Mail/classes/class.ilFileDataMail.php';
     $attachment = new ilFileDataMail($this->getSender());
     $attachment->unlinkFiles($this->getAttachments());
 }
 public function sendAdvancedNotification($active_id)
 {
     include_once "./Services/Mail/classes/class.ilMail.php";
     $mail = new ilMail(ANONYMOUS_USER_ID);
     $usr_data = $this->userLookupFullName(ilObjTest::_getUserIdFromActiveId($active_id));
     $message = new ilTemplate("tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE, "Modules/Test");
     $message->setVariable('TEXT_TEST_TITLE', $this->lng->txt('title'));
     $message->setVariable('VALUE_TEST_TITLE', $this->getTitle());
     $message->setVariable('TEXT_USER_NAME', $this->lng->txt('username'));
     $message->setVariable('VALUE_USER_NAME', $usr_data);
     $message->setVariable('TEXT_FINISH_TIME', $this->lng->txt('tst_finished'));
     ilDatePresentation::setUseRelativeDates(false);
     $message->setVariable('VALUE_FINISH_TIME', ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX)));
     include_once "./Modules/Test/classes/class.ilTestExport.php";
     $exportObj = new ilTestExport($this, "results");
     $file = $exportObj->exportToExcel($deliver = FALSE, 'active_id', $active_id, $passedonly = FALSE);
     include_once "./Services/Mail/classes/class.ilFileDataMail.php";
     $fd = new ilFileDataMail(ANONYMOUS_USER_ID);
     $fd->copyAttachmentFile($file, "result_" . $active_id . ".xls");
     $file_names[] = "result_" . $active_id . ".xls";
     $result = $mail->sendMail(ilObjUser::_lookupLogin($this->getOwner()), "", "", sprintf($this->lng->txt('tst_user_finished_test'), $this->getTitle()), $message->get(), count($file_names) ? $file_names : array(), array('normal'));
     if (count($file_names)) {
         $fd->unlinkFiles($file_names);
         unset($fd);
         @unlink($file);
     }
 }