public function showAttachments()
 {
     /**
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilToolbar;
     $this->tpl->setTitle($this->lng->txt('mail'));
     require_once 'Services/Form/classes/class.ilFileInputGUI.php';
     $attachment = new ilFileInputGUI($this->lng->txt('upload'), 'userfile');
     $attachment->setRequired(true);
     $attachment->setSize(20);
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'uploadFile'), true);
     $ilToolbar->addInputItem($attachment);
     $ilToolbar->addFormButton($this->lng->txt('upload'), 'uploadFile');
     require_once 'Services/Mail/classes/class.ilMailAttachmentTableGUI.php';
     $table = new ilMailAttachmentTableGUI($this, 'showAttachments');
     $mailData = $this->umail->getSavedData();
     $files = $this->mfile->getUserFilesData();
     $data = array();
     $counter = 0;
     foreach ($files as $file) {
         $checked = false;
         if (is_array($mailData['attachments']) && in_array($file['name'], $mailData['attachments'])) {
             $checked = true;
         }
         $data[$counter] = array('checked' => $checked, 'filename' => $file['name'], 'filesize' => (int) $file['size'], 'filecreatedate' => (int) $file['ctime']);
         ++$counter;
     }
     $table->setData($data);
     $this->tpl->setContent($table->getHtml());
     $this->tpl->show();
 }
Exemple #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;
 }
 function deliverFile()
 {
     if ($_SESSION["mail_id"]) {
         $_GET["mail_id"] = $_SESSION["mail_id"];
     }
     $_SESSION["mail_id"] = "";
     $filename = $_SESSION["filename"] ? $_SESSION["filename"] : ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
     $_SESSION["filename"] = "";
     if ($filename != "") {
         require_once "./Services/Mail/classes/class.ilFileDataMail.php";
         // secure filename
         $filename = str_replace("..", "", $filename);
         $mfile = new ilFileDataMail($_SESSION["AccountId"]);
         if (!is_array($file = $mfile->getAttachmentPathByMD5Filename($filename, $_GET['mail_id']))) {
             ilUtil::sendInfo($this->lng->txt('mail_error_reading_attachment'));
             $this->showMail();
         } else {
             ilUtil::deliverFile($file['path'], $file['filename']);
         }
     } else {
         ilUtil::sendInfo($this->lng->txt('mail_select_attachment'));
         $this->showMail();
     }
 }
 /**
  * Delete attachments
  */
 protected function deleteAttachments()
 {
     include_once './Services/Mail/classes/class.ilFileDataMail.php';
     $attachment = new ilFileDataMail($this->getSender());
     $attachment->unlinkFiles($this->getAttachments());
 }
    /**
     * deletes user's mailbox and all db entries related to mailbox
     * TODO: stefan, bitte nochmal kontrollieren, ob auch wirklich alles gel�scht wird.
     * Vielleicht hab ich was �bersehen. - shofmann, 15.7.03
     *
     * @access	public
     * @return	boolean	true on successful deletion
     */
    function delete()
    {
        /**
         * @var $ilDB ilDB
         */
        global $ilDB;
        $ilDB->manipulateF('
			DELETE FROM mail_obj_data WHERE user_id = %s', array('integer'), array($this->user_id));
        $ilDB->manipulateF('
			DELETE FROM mail_options WHERE user_id = %s', array('integer'), array($this->user_id));
        $ilDB->manipulateF('
			DELETE FROM mail_saved WHERE user_id = %s', array('integer'), array($this->user_id));
        $ilDB->manipulateF('
			DELETE FROM mail_tree WHERE tree = %s', array('integer'), array($this->user_id));
        // Delete the user's files from filesystem: This has to be done before deleting the database entries in table 'mail'
        require_once 'Services/Mail/classes/class.ilFileDataMail.php';
        $fdm = new ilFileDataMail($this->user_id);
        $fdm->onUserDelete();
        // Delete mails of deleted user
        $ilDB->manipulateF('DELETE FROM mail WHERE user_id = %s', array('integer'), array($this->user_id));
        return true;
    }
 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);
     }
 }
 /**
  * send  bookmarks as attachment
  */
 function sendmail()
 {
     global $ilUser;
     include_once './Services/Mail/classes/class.ilFileDataMail.php';
     require_once "Services/Mail/classes/class.ilFormatMail.php";
     $mfile = new ilFileDataMail($ilUser->getId());
     $umail = new ilFormatMail($ilUser->getId());
     $html_content = $this->export(false);
     $tempfile = ilUtil::ilTempnam();
     $fp = fopen($tempfile, 'w');
     fwrite($fp, $html_content);
     fclose($fp);
     $filename = 'bookmarks.html';
     $mfile->copyAttachmentFile($tempfile, $filename);
     $umail->savePostData($ilUser->getId(), array($filename), '', '', '', '', '', '', '', 0);
     require_once 'Services/Mail/classes/class.ilMailFormCall.php';
     ilUtil::redirect(ilMailFormCall::getRedirectTarget($this, '', array(), array('type' => 'attach')));
 }
 /**
  * Returns the number of attachments and the number of bytes used on the
  * harddisk for mail attachments, by the user with the specified user id.
  * @param int user id.
  * @return array('count'=>integer,'size'=>integer),...)
  *                            // an associative array with the disk
  *                            // usage in bytes for each object type
  */
 function _lookupDiskUsageOfUser($user_id)
 {
     require_once "./Services/Mail/classes/class.ilFileDataMail.php";
     return ilFileDataMail::_lookupDiskUsageOfUser($user_id);
 }
 /**
  * mail via soap
  * @param object $sid
  * @param object $a_mail_xml
  * @return 
  */
 public function distributeMails($sid, $a_mail_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     include_once 'Services/Mail/classes/class.ilMail.php';
     include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
     $parser = new ilSoapMailXmlParser($a_mail_xml);
     try {
         // Check if wellformed
         libxml_use_internal_errors(true);
         $ok = simplexml_load_string($a_mail_xml);
         if (!$ok) {
             foreach (libxml_get_errors() as $err) {
                 $error .= $err->message . ' ';
             }
             return $this->__raiseError($error, 'CLIENT');
         }
         $parser->start();
     } catch (InvalidArgumentException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
         return $this->__raiseError($e->getMessage(), 'CLIENT');
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
         return $this->__raiseError($e->getMessage(), 'CLIENT');
     }
     $mails = $parser->getMails();
     global $ilUser;
     foreach ($mails as $mail) {
         // Prepare attachments
         include_once './Services/Mail/classes/class.ilFileDataMail.php';
         $file = new ilFileDataMail($ilUser->getId());
         foreach ((array) $mail['attachments'] as $attachment) {
             // TODO: Error handling
             $file->storeAsAttachment($attachment['name'], $attachment['content']);
             $attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
         }
         $mail_obj = new ilMail($ilUser->getId());
         $mail_obj->setSaveInSentbox(true);
         $mail_obj->saveAttachments((array) $attachments);
         $mail_obj->sendMail(implode(',', (array) $mail['to']), implode(',', (array) $mail['cc']), implode(',', (array) $mail['bcc']), $mail['subject'], implode("\n", $mail['body']), (array) $attachments, array($mail['type']), (bool) $mail['usePlaceholders']);
         // Finally unlink attachments
         foreach ((array) $attachments as $att) {
             $file->unlinkFile($att);
         }
         $mail_obj->savePostData($ilUser->getId(), array(), '', '', '', '', '', '', '', '');
     }
     return true;
 }