public function notify(ilNotificationObject $notification)
 {
     // use a specific sender or ANONYMOUS
     $sender_id = isset($notification->handlerParams['mail']['sender']) ? $notification->handlerParams['mail']['sender'] : ANONYMOUS_USER_ID;
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($sender_id);
     $mail->appendInstallationSignature(true);
     $mail->sendMail($notification->user->getLogin(), '', '', $notification->title, $notification->longDescription, false, array('normal'));
     //mail($notification->user->getEmail(), $notification->title, $notification->longDescription);
 }
 /**
  * check whether goto script will succeed
  */
 function _checkGoto($a_target)
 {
     global $rbacsystem;
     require_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($_SESSION["AccountId"]);
     if ($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
         return true;
     }
     return false;
 }
 /**
  * Get Mails
  */
 function getMails()
 {
     global $ilUser;
     // BEGIN MAILS
     $umail = new ilMail($_SESSION["AccountId"]);
     $mbox = new ilMailBox($_SESSION["AccountId"]);
     $inbox = $mbox->getInboxFolder();
     //SHOW MAILS FOR EVERY USER
     $this->mails = $umail->getMailsOfFolder($inbox, array('status' => 'unread', 'type' => 'system'));
 }
 /**
  * send an advanced notification to the owner of the test
  * @param int $owner_id
  * @param string $title
  * @param sting $usr_data
  * @param array $file_names
  */
 public function sendAdvancedNotification($owner_id, $title, $usr_data, $file_names)
 {
     $this->initLanguage($owner_id);
     $this->language->loadLanguageModule('assessment');
     $this->initMail();
     $this->setSubject(sprintf($this->language->txt('tst_user_finished_test'), $title));
     $this->setBody(ilMail::getSalutation($owner_id, $this->getLanguage()));
     $this->appendBody("\n\n");
     $this->appendBody($this->language->txt('user_has_finished_a_test'));
     $this->appendBody("\n\n");
     $this->appendBody($this->language->txt('title') . ': ' . $title);
     $this->appendBody("\n");
     $this->appendBody($this->language->txt('username') . ': ' . $usr_data);
     $this->appendBody("\n");
     ilDatePresentation::setUseRelativeDates(false);
     $this->appendBody($this->language->txt('tst_finished') . ': ' . ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX)));
     $this->appendBody("\n\n");
     $this->appendBody($this->language->txt('tst_attached_xls_file'));
     $this->appendBody("\n\n");
     $this->appendBody($this->language->txt('tst_notification_explanation_admin'));
     $this->appendBody("\n");
     $this->setAttachments($file_names);
     $this->getMail()->appendInstallationSignature(true);
     $this->sendMail(array($owner_id), array('system'));
 }
 /**
  * Send notifications
  * @return 
  */
 public function send()
 {
     global $ilUser;
     switch ($this->getType()) {
         case self::TYPE_USER_BLOCKED:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('cont_user_blocked'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('cont_user_blocked2'));
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('cont_user_blocked3') . " '" . $this->getLanguageText('objs_qst') . "' > '" . $this->getLanguageText('cont_blocked_users') . "'");
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('obj_lm') . ": " . $this->getObjectTitle(true));
                 $this->appendBody("\n");
                 include_once "./Services/User/classes/class.ilUserUtil.php";
                 $this->appendBody($this->getLanguageText('user') . ": " . ilUserUtil::getNamePresentation($ilUser->getId(), false, false, ""));
                 $this->appendBody("\n");
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $this->appendBody($this->getLanguageText('question') . ": " . assQuestion::_getTitle($this->getQuestionId()));
                 $this->appendBody("\n");
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('cont_lm_mail_permanent_link'));
                 $this->appendBody("\n");
                 $this->appendBody($this->createPermanentLink(array(), ""));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
     }
     return true;
 }
 private function buildBody()
 {
     //	Salutation
     $this->setBody(ilMail::getSalutation($this->getRecipient(), $this->getLanguage()));
     $this->appendBody("\n\n");
     //	Message (What has happened?)
     $this->appendBody($this->getLanguageText('tst_notify_manscoring_done_body_msg_topic'));
     $this->appendBody("\n\n");
     $info = $this->getAdditionalInformation();
     $this->appendBody($this->getLanguageText('obj_tst') . ': ' . $info['test_title']);
     $this->appendBody("\n");
     $this->appendBody($this->getLanguageText('pass') . ': ' . $info['test_pass']);
     $this->appendBody("\n\n");
     foreach ($info['questions_gui_list'] as $questionId => $questionGui) {
         $points = $info['questions_scoring_data'][$questionId]['points'];
         $feedback = $info['questions_scoring_data'][$questionId]['feedback'];
         $feedback = $this->convertFeedbackForMail($feedback);
         $this->appendBody($this->getLanguageText('tst_question') . ': ' . $questionGui->object->getTitle());
         $this->appendBody("\n");
         $this->appendBody($this->getLanguageText('tst_reached_points') . ': ' . $points);
         $this->appendBody("\n");
         $this->appendBody($this->getLanguageText('set_manual_feedback') . ":\n" . $feedback);
         $this->appendBody("\n\n");
     }
     //	Task (What do I have to do?
     /* NOTHING TODO FOR PARTICIPANT */
     //	Explanation (Why do I receive the following message?)
     $this->appendBody("\n");
     $this->appendBody($this->getLanguageText('tst_notify_manscoring_done_body_msg_reason'));
     //	Signature
     $this->getMail()->appendInstallationSignature(true);
 }
 public function send()
 {
     switch ($this->getType()) {
         case self::TYPE_NOTIFICATION_ACTIVATION:
             $additional_information = $this->getAdditionalInformation();
             /**
              * @var $user ilObjUser
              */
             $user = $additional_information['usr'];
             foreach ($this->getRecipients() as $rcp) {
                 try {
                     $this->handleCurrentRecipient($rcp);
                 } catch (ilMailException $e) {
                     continue;
                 }
                 $this->initMimeMail();
                 $this->setSubject($this->getLanguage()->txt('reg_mail_subject_confirmation'));
                 $this->setBody($this->getLanguage()->txt('reg_mail_body_salutation') . ' ' . $user->getFullname() . ',');
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguage()->txt('reg_mail_body_confirmation'));
                 $this->appendBody("\n");
                 $this->appendBody(ILIAS_HTTP_PATH . '/confirmReg.php?client_id=' . CLIENT_ID . '&rh=' . ilObjUser::_generateRegistrationHash($user->getId()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguage()->txt('reg_mail_body_2_confirmation'), ilFormat::_secondsToString($additional_information['hash_lifetime'])));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguage()->txt('reg_mail_body_3_confirmation'));
                 $this->appendBody(ilMail::_getInstallationSignature());
                 $this->sendMimeMail($this->getCurrentRecipient());
             }
             break;
     }
 }
 public function send()
 {
     global $lng;
     $additional_information = $this->getAdditionalInformation();
     $old_val = ilDatePresentation::useRelativeDates();
     ilDatePresentation::setUseRelativeDates(false);
     foreach ($this->getRecipients() as $rcp) {
         try {
             $this->handleCurrentRecipient($rcp);
         } catch (ilMailException $e) {
             continue;
         }
         $this->initMimeMail();
         $this->initLanguageByIso2Code();
         ilDatePresentation::setLanguage($this->getLanguage());
         $date_for_deletion = ilDatePresentation::formatDate(new ilDate($additional_information["date"], IL_CAL_UNIX));
         $this->setSubject($this->getLanguage()->txt('del_mail_subject'));
         $body = sprintf($this->getLanguage()->txt("del_mail_body"), $rcp->fullname, "\n\n", $additional_information["www"], $date_for_deletion);
         $this->appendBody($body);
         $this->appendBody(ilMail::_getInstallationSignature());
         $this->sendMimeMail($this->getCurrentRecipient());
     }
     ilDatePresentation::setUseRelativeDates($old_val);
     ilDatePresentation::setLanguage($lng);
 }
Esempio n. 9
0
 /**
  * Sends a notification message to all users responsible for vat assignment.
  * 
  * @access	public
  * @static
  * @param	ilPaymentObject $oPaymentObject
  */
 public static function _sendNotificationToVATAdministration($oPaymentObject)
 {
     global $ilSetting, $lng, $ilClientIniFile;
     $payment_vat_admins = $ilSetting->get('payment_vat_admins');
     $users = explode(',', $payment_vat_admins);
     $subject = $lng->txt('payment_vat_assignment_notification_subject');
     $tmp_obj = ilObjectFactory::getInstanceByRefId($oPaymentObject->getRefId());
     $message = sprintf($lng->txt('payment_vat_assignment_notification_body'), $tmp_obj->getTitle()) . "\n\n";
     $message .= "------------------------------------------------------------\n";
     $message .= sprintf($lng->txt('payment_vat_assignment_notification_intro'), $ilClientIniFile->readVariable('client', 'name'), ILIAS_HTTP_PATH . '/?client_id=' . CLIENT_ID);
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail_obj = new ilMail(ANONYMOUS_USER_ID);
     foreach ((array) $users as $login) {
         if (strlen(trim($login)) && (int) ilObjUser::_lookupId(trim($login))) {
             $success = $mail_obj->sendMail(trim($login), '', '', $subject, $message, array(), array("system"));
         }
     }
 }
 public function __construct($wsp_access_handler = null, $wsp_node_id = null)
 {
     global $tpl, $ilCtrl, $lng, $ilUser, $rbacsystem;
     $this->tpl = $tpl;
     $this->ctrl = $ilCtrl;
     $this->lng = $lng;
     // personal workspace
     $this->wsp_access_handler = $wsp_access_handler;
     $this->wsp_node_id = $wsp_node_id;
     $this->ctrl->saveParameter($this, "mobj_id");
     $this->ctrl->saveParameter($this, "ref");
     // check if current user may send mails
     include_once "Services/Mail/classes/class.ilMail.php";
     $mail = new ilMail($_SESSION["AccountId"]);
     $this->mailing_allowed = $rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
     $this->umail = new ilFormatMail($ilUser->getId());
     $this->abook = new ilAddressbook($ilUser->getId());
 }
    /**
     * 
     * Send notifications	 
     *  
     * @access	public
     *  
     */
    public function send()
    {
        global $ilDB;
        // parent::send();
        if (count($this->getRecipients())) {
            $res = $ilDB->queryf("SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," . "u.time_limit_unlimited, " . $ilDB->fromUnixtime("u.time_limit_from") . ", " . $ilDB->fromUnixtime("u.time_limit_until") . "," . "CASE WHEN u.active = 0 THEN '0001-01-01' ELSE CASE WHEN u.time_limit_unlimited=1 THEN '9999-12-31' ELSE " . $ilDB->fromUnixtime("u.time_limit_until") . " END END access_until," . " CASE WHEN " . $ilDB->unixTimestamp() . " BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," . "rq.role_disk_quota, system_role.rol_id role_id, " . "p1.value+0 user_disk_quota," . "p2.value+0 disk_usage, " . "p3.value last_update, " . "p5.value language, " . "CASE WHEN rq.role_disk_quota>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota ELSE p1.value+0 END disk_quota\t" . "FROM usr_data u  " . "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " . "FROM usr_data u " . "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " . "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s  " . "JOIN role_data rd ON rd.role_id=ua.rol_id WHERE u.usr_id=ua.usr_id GROUP BY u.usr_id) rq ON rq.usr_id=u.usr_id " . "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " . "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota'  " . "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage'  " . "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update'  " . "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language'  " . 'WHERE (((p1.value+0 > rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR 
					((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ' . 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR ' . $ilDB->unixTimestamp() . ' BETWEEN u.time_limit_from AND u.time_limit_until)) ', array('integer', 'integer'), array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID));
            $users = array();
            $counter = 0;
            while ($row = $ilDB->fetchAssoc($res)) {
                $details = ilDiskQuotaChecker::_lookupDiskUsage($row['usr_id']);
                $users[$counter]['disk_quota'] = $row['disk_quota'];
                $users[$counter]['disk_usage'] = $details['disk_usage'];
                $users[$counter]['email'] = $row['email'];
                $users[$counter]['firstname'] = $row['firstname'];
                $users[$counter]['lastname'] = $row['lastname'];
                ++$counter;
            }
            if (count($users)) {
                foreach ($this->getRecipients() as $rcp) {
                    $usrId = ilObjUser::_lookupId($rcp);
                    $this->initLanguage($usrId);
                    $this->initMail();
                    $this->setSubject($this->getLanguage()->txt('disk_quota_summary_subject'));
                    $this->setBody(ilMail::getSalutation($usrId, $this->getLanguage()));
                    $this->appendBody("\n\n");
                    $this->appendBody($this->getLanguage()->txt('disk_quota_exceeded_headline'));
                    $this->appendBody("\n\n");
                    $first = true;
                    $counter = 0;
                    $numUsers = count($users);
                    foreach ($users as $user) {
                        if (!$first) {
                            $this->appendBody("\n---------------------------------------------------\n\n");
                        }
                        $this->appendBody($this->getLanguage()->txt('fullname') . ': ' . $user['lastname'] . ', ' . $user['firstname'] . "\n");
                        $this->appendBody($this->getLanguage()->txt('email') . ': ' . $user['email'] . "\n");
                        $this->appendBody($this->getLanguage()->txt('disk_quota') . ': ' . ilFormat::formatSize($user['disk_quota'], 'short', $this->getLanguage()) . "\n");
                        $this->appendBody($this->getLanguage()->txt('currently_used_disk_space') . ': ' . ilFormat::formatSize($user['disk_usage'], 'short', $this->getLanguage()) . "\n");
                        $this->appendBody($this->getLanguage()->txt('usrf_profile_link') . ': ' . ilUtil::_getHttpPath() . '/goto.php?target=usrf&client_id=' . CLIENT_ID);
                        if ($counter < $numUsers - 1) {
                            $this->appendBody("\n");
                        }
                        ++$counter;
                        $first = false;
                    }
                    $this->getMail()->appendInstallationSignature(true);
                    $this->sendMail(array($rcp), array('system'), false);
                }
            }
        }
    }
 /**
  * Parse and send mail
  * @return 
  */
 public function send()
 {
     switch ($this->getType()) {
         case self::TYPE_NOTIFICATION_APPROVERS:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject($this->getLanguageText('reg_mail_new_user'));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_new_user_body'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_body_profile'));
                 $info = $this->getAdditionalInformation();
                 $this->appendBody("\n\n");
                 $this->appendBody($info['usr']->getProfileAsString($this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_body_reason'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->getMail()->enableSoap(false);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_NOTIFICATION_CONFIRMATION:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject($this->getLanguageText('reg_mail_new_user_confirmation'));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_new_user_body'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_body_profile'));
                 $info = $this->getAdditionalInformation();
                 $this->appendBody("\n\n");
                 $this->appendBody($info['usr']->getProfileAsString($this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_body_confirmation'));
                 $this->appendBody("\n");
                 // #4527
                 include_once "Services/Link/classes/class.ilLink.php";
                 $this->appendBody(ilLink::_getStaticLink($info['usr']->getId(), "usrf"));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('reg_mail_body_reason'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->getMail()->enableSoap(false);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
     }
 }
 /**
  * Send notifications
  * @return 
  */
 public function send()
 {
     global $ilUser;
     // parent::send();
     include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
     switch ($this->getType()) {
         case self::TYPE_FEEDBACK_FILE_ADDED:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('exc_msg_new_feedback_file_uploaded'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('exc_msg_new_feedback_file_uploaded2'));
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true));
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('exc_assignment') . ": " . ilExAssignment::lookupTitle($this->getAssignmentId()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
                 $this->appendBody("\n");
                 $this->appendBody($this->createPermanentLink(array(), '_' . $this->getAssignmentId()) . '#fb' . $this->getAssignmentId());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_SUBMISSION_UPLOAD:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('exc_submission_notification_subject'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('exc_submission_notification_body'), $this->getObjectTitle(true)));
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('exc_assignment') . ": " . ilExAssignment::lookupTitle($this->getAssignmentId()));
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('user') . ": " . $ilUser->getFullName());
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('exc_submission_notification_link'), $this->createPermanentLink()));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
     }
     return true;
 }
 public function send()
 {
     $additional_information = $this->getAdditionalInformation();
     foreach ($this->getRecipients() as $rcp) {
         try {
             $this->handleCurrentRecipient($rcp);
         } catch (ilMailException $e) {
             continue;
         }
         $this->initMimeMail();
         $this->initLanguageByIso2Code();
         $this->setSubject($this->getLanguage()->txt('del_mail_subject'));
         $body = sprintf($this->getLanguage()->txt("del_mail_body"), $rcp->fullname, "\n\n", $additional_information["www"], $additional_information["days"]);
         $this->appendBody($body);
         $this->appendBody(ilMail::_getInstallationSignature());
         $this->sendMimeMail($this->getCurrentRecipient());
     }
 }
 public function send()
 {
     include_once './Services/Link/classes/class.ilLink.php';
     $obj = new ilObjectFactory();
     $instance = $obj->getInstanceByRefId($_GET['ref_id']);
     $link = ilLink::_getLink($_GET['ref_id'], $instance->getType(), array(), '');
     global $lng;
     foreach ($this->getRecipients() as $rcp) {
         $this->initLanguage($rcp);
         $this->initMail();
         $this->setSubject(sprintf($lng->txt('rubric_exercise_graded') . ' ' . ilObject::_lookupTitle($this->getObjId()) . ' ' . $lng->txt('rubric_is_now_available'), $this->getObjectTitle(true)));
         $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
         $this->appendBody("\n\n");
         $this->appendBody($lng->txt('rubric_exercise_graded') . ' ' . ilObject::_lookupTitle($this->getObjId()) . ' ' . $lng->txt('rubric_is_now_available'));
         $this->appendBody("\n");
         $this->appendBody($this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true));
         $this->appendBody("\n");
         $this->appendBody("\n\n");
         $this->appendBody($link);
         $this->getMail()->appendInstallationSignature(true);
         $this->sendMail(array($rcp), array('system'));
     }
 }
 public function send()
 {
     global $lng;
     $customer_array = $this->_getObjectsToRemind();
     foreach ($customer_array as $user_id => $objects_array) {
         $this->initLanguage($user_id);
         $user_lang = $this->getLanguage() ? $this->getLanguage() : $lng;
         $this->initMail();
         $this->setRecipients($user_id);
         $this->setSubject($this->getLanguageText('payment_reminder_notification_subject'));
         $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
         $this->appendBody("\n\n");
         $this->appendBody($user_lang->txt('bought_objects_expire_soon'));
         $this->appendBody("\n\n");
         foreach ($objects_array as $key => $pobject) {
             $this->appendBody("----------------------------------------------------------------------------------------------");
             $this->appendBody("\n\n");
             $this->appendBody($user_lang->txt('title') . ": " . $objects_array[$key]['object_title'] . "\n");
             $this->appendBody($user_lang->txt('access_enddate') . ": " . $objects_array[$key]['access_enddate']);
             $this->appendBody("\n");
             $this->appendBody("\n\n");
         }
         $this->appendBody("----------------------------------------------------------------------------------------------");
         //@todo fix this: $mailbox_link
         $this->appendBody($mailbox_link);
         $this->appendBody("\n\n");
         $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->getLanguage()));
         $this->appendBody(ilMail::_getInstallationSignature());
         $mmail = new ilMimeMail();
         $mmail->autoCheck(false);
         $mmail->From('noreply');
         $mmail->To(ilObjUser::_lookupEmail($user_id));
         $mmail->Subject($this->getSubject());
         $mmail->Body($this->getBody());
         $mmail->Send();
     }
 }
 /**
  * Send notifications
  * @return 
  */
 public function send()
 {
     global $ilSetting;
     if ((int) $this->getRefId() && in_array($this->getType(), array(self::TYPE_ADMISSION_MEMBER))) {
         $obj = ilObjectFactory::getInstanceByRefId((int) $this->getRefId());
         if ($obj->getAutoNotification() == false) {
             return false;
         }
     }
     // #11359
     // parent::send();
     switch ($this->getType()) {
         case self::TYPE_ADMISSION_MEMBER:
             // automatic mails about status change disabled
             if (!$ilSetting->get('mail_crs_member_notification', true)) {
                 return;
             }
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_added_member'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_added_member_body'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_accept_subscriber'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_accept_subscriber_body'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_reject_subscriber'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_reject_subscriber_body'), $this->getObjectTitle()));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_STATUS_CHANGED:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_status_changed'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_status_changed_body'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createCourseStatus($rcp));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_DISMISS_MEMBER:
             // automatic mails about status change disabled
             if (!$ilSetting->get('mail_crs_member_notification', true)) {
                 return;
             }
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_dismiss_member'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_dismiss_member_body'), $this->getObjectTitle()));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_BLOCKED_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_blocked_member'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_blocked_member_body'), $this->getObjectTitle()));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_UNBLOCKED_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_unblocked_member'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_unblocked_member_body'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_NOTIFICATION_REGISTRATION:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_new_subscription'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $info = $this->getAdditionalInformation();
                 $this->appendBody(sprintf($this->getLanguageText('crs_new_subscription_body'), $this->userToString($info['usr_id']), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink(array(), '_mem'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_new_subscription_request'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $info = $this->getAdditionalInformation();
                 $this->appendBody(sprintf($this->getLanguageText('crs_new_subscription_request_body'), $this->userToString($info['usr_id']), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_new_subscription_request_body2'));
                 $this->appendBody("\n");
                 $this->appendBody($this->createPermanentLink(array(), '_mem'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_NOTIFICATION_UNSUBSCRIBE:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_cancel_subscription'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $info = $this->getAdditionalInformation();
                 $this->appendBody(sprintf($this->getLanguageText('crs_cancel_subscription_body'), $this->userToString($info['usr_id']), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_cancel_subscription_body2'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink(array(), '_mem'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_notification_explanation_admin'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_UNSUBSCRIBE_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_unsubscribe_member'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_unsubscribe_member_body'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_unsubscribe_member_explanation'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_SUBSCRIBE_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_subscribe_member'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_subscribe_member_body'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_WAITING_LIST_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('crs_subscribe_wl'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $info = $this->getAdditionalInformation();
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('crs_subscribe_wl_body'), $this->getObjectTitle(), $info['position']));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
     }
     return true;
 }
Esempio n. 18
0
 /**
  * Returns the mailbox address of a role.
  *
  * Example 1: Mailbox address for an ILIAS reserved role name
  * ----------------------------------------------------------
  * The il_crs_member_345 role of the course object "English Course 1" is 
  * returned as one of the following mailbox addresses:
  *
  * a)   Course Member <#member@[English Course 1]>
  * b)   Course Member <#il_crs_member_345@[English Course 1]>
  * c)   Course Member <#il_crs_member_345>
  *
  * Address a) is returned, if the title of the object is unique, and
  * if there is only one local role with the substring "member" defined for
  * the object.
  *
  * Address b) is returned, if the title of the object is unique, but 
  * there is more than one local role with the substring "member" in its title.
  *
  * Address c) is returned, if the title of the course object is not unique.
  *
  *
  * Example 2: Mailbox address for a manually defined role name
  * -----------------------------------------------------------
  * The "Admin" role of the category object "Courses" is 
  * returned as one of the following mailbox addresses:
  *
  * a)   Course Administrator <#Admin@Courses>
  * b)   Course Administrator <#Admin>
  * c)   Course Adminstrator <#il_role_34211>
  *
  * Address a) is returned, if the title of the object is unique, and
  * if there is only one local role with the substring "Admin" defined for
  * the course object.
  *
  * Address b) is returned, if the title of the object is not unique, but 
  * the role title is unique.
  *
  * Address c) is returned, if neither the role title nor the title of the
  * course object is unique. 
  *
  *
  * Example 3: Mailbox address for a manually defined role title that can
  *            contains special characters in the local-part of a 
  *            mailbox address
  * --------------------------------------------------------------------
  * The "Author Courses" role of the category object "Courses" is 
  * returned as one of the following mailbox addresses:
  *
  * a)   "#Author Courses"@Courses
  * b)   Author Courses <#il_role_34234>
  *
  * Address a) is returned, if the title of the role is unique.
  *
  * Address b) is returned, if neither the role title nor the title of the
  * course object is unique, or if the role title contains a quote or a
  * backslash.
  *
  *
  * @param int a role id
  * @param boolean is_localize whether mailbox addresses should be localized
  * @return	String mailbox address or null, if role does not exist.
  * @todo refactor rolf
  */
 function getRoleMailboxAddress($a_role_id, $is_localize = true)
 {
     global $log, $lng, $ilDB;
     include_once "Services/Mail/classes/class.ilMail.php";
     if (ilMail::_usePearMail()) {
         // Retrieve the role title and the object title.
         $query = "SELECT rdat.title role_title,odat.title object_title, " . " oref.ref_id object_ref " . "FROM object_data rdat " . "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id " . "JOIN tree rtree ON rtree.child = fa.parent " . "JOIN object_reference oref ON oref.ref_id = rtree.parent " . "JOIN object_data odat ON odat.obj_id = oref.obj_id " . "WHERE rdat.obj_id = " . $this->ilDB->quote($a_role_id, 'integer') . " " . "AND fa.assign = 'y' ";
         $r = $ilDB->query($query);
         if (!($row = $ilDB->fetchObject($r))) {
             //$log->write('class.ilRbacReview->getMailboxAddress('.$a_role_id.'): error role does not exist');
             return null;
             // role does not exist
         }
         $object_title = $row->object_title;
         $object_ref = $row->object_ref;
         $role_title = $row->role_title;
         // In a perfect world, we could use the object_title in the
         // domain part of the mailbox address, and the role title
         // with prefix '#' in the local part of the mailbox address.
         $domain = $object_title;
         $local_part = $role_title;
         // Determine if the object title is unique
         $q = "SELECT COUNT(DISTINCT dat.obj_id) count " . "FROM object_data dat " . "JOIN object_reference ref ON ref.obj_id = dat.obj_id " . "JOIN tree ON tree.child = ref.ref_id " . "WHERE title = " . $this->ilDB->quote($object_title, 'text') . " " . "AND tree.tree = 1 ";
         $r = $this->ilDB->query($q);
         $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
         // If the object title is not unique, we get rid of the domain.
         if ($row->count > 1) {
             $domain = null;
         }
         // If the domain contains illegal characters, we get rid of it.
         //if (domain != null && preg_match('/[\[\]\\]|[\x00-\x1f]/',$domain))
         // Fix for Mantis Bug: 7429 sending mail fails because of brakets
         // Fix for Mantis Bug: 9978 sending mail fails because of semicolon
         if ($domain != null && preg_match('/[\\[\\]\\]|[\\x00-\\x1f]|[\\x28-\\x29]|[;]/', $domain)) {
             $domain = null;
         }
         // If the domain contains special characters, we put square
         //   brackets around it.
         if ($domain != null && (preg_match('/[()<>@,;:\\".\\[\\]]/', $domain) || preg_match('/[^\\x21-\\x8f]/', $domain))) {
             $domain = '[' . $domain . ']';
         }
         // If the role title is one of the ILIAS reserved role titles,
         //     we can use a shorthand version of it for the local part
         //     of the mailbox address.
         if (strpos($role_title, 'il_') === 0 && $domain != null) {
             $unambiguous_role_title = $role_title;
             $pos = strpos($role_title, '_', 3) + 1;
             $local_part = substr($role_title, $pos, strrpos($role_title, '_') - $pos);
         } else {
             $unambiguous_role_title = 'il_role_' . $a_role_id;
         }
         // Determine if the local part is unique. If we don't have a
         // domain, the local part must be unique within the whole repositry.
         // If we do have a domain, the local part must be unique for that
         // domain.
         if ($domain == null) {
             $q = "SELECT COUNT(DISTINCT dat.obj_id) count " . "FROM object_data dat " . "JOIN object_reference ref ON ref.obj_id = dat.obj_id " . "JOIN tree ON tree.child = ref.ref_id " . "WHERE title = " . $this->ilDB->quote($local_part, 'text') . " " . "AND tree.tree = 1 ";
         } else {
             $q = "SELECT COUNT(rd.obj_id) count " . "FROM object_data rd " . "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id " . "JOIN tree t ON t.child = fa.parent " . "WHERE fa.assign = 'y' " . "AND t.parent = " . $this->ilDB->quote($object_ref, 'integer') . " " . "AND rd.title LIKE " . $this->ilDB->quote('%' . preg_replace('/([_%])/', '\\\\$1', $local_part) . '%', 'text') . " ";
         }
         $r = $this->ilDB->query($q);
         $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
         // if the local_part is not unique, we use the unambiguous role title
         //   instead for the local part of the mailbox address
         if ($row->count > 1) {
             $local_part = $unambiguous_role_title;
         }
         $use_phrase = true;
         // If the local part contains illegal characters, we use
         //     the unambiguous role title instead.
         if (preg_match('/[\\"\\x00-\\x1f]/', $local_part)) {
             $local_part = $unambiguous_role_title;
         } else {
             if (!preg_match('/^[\\x00-\\x7E]+$/i', $local_part)) {
                 // 2013-12-05: According to #12283, we do not accept umlauts in the local part
                 $local_part = $unambiguous_role_title;
                 $use_phrase = false;
             }
         }
         // Add a "#" prefix to the local part
         $local_part = '#' . $local_part;
         // Put quotes around the role title, if needed
         if (preg_match('/[()<>@,;:.\\[\\]\\x20]/', $local_part)) {
             $local_part = '"' . $local_part . '"';
         }
         $mailbox = $domain == null ? $local_part : $local_part . '@' . $domain;
         if ($is_localize) {
             if (substr($role_title, 0, 3) == 'il_') {
                 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title, '_')));
             } else {
                 $phrase = $role_title;
             }
             if ($use_phrase) {
                 // make phrase RFC 822 conformant:
                 // - strip excessive whitespace
                 // - strip special characters
                 $phrase = preg_replace('/\\s\\s+/', ' ', $phrase);
                 $phrase = preg_replace('/[()<>@,;:\\".\\[\\]]/', '', $phrase);
                 $mailbox = $phrase . ' <' . $mailbox . '>';
             }
         }
         require_once './Services/PEAR/lib/Mail/RFC822.php';
         $obj = new Mail_RFC822($mailbox, 'ilias');
         if (@$obj->parseAddressList() instanceof PEAR_Error) {
             $q = "SELECT title " . "FROM object_data " . "WHERE obj_id = " . $this->ilDB->quote($a_role_id, 'integer');
             $r = $this->ilDB->query($q);
             if ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) {
                 return '#' . $row->title;
             } else {
                 return null;
             }
         }
         return $mailbox;
     } else {
         $q = "SELECT title " . "FROM object_data " . "WHERE obj_id = " . $this->ilDB->quote($a_role_id, 'integer');
         $r = $this->ilDB->query($q);
         if ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) {
             return '#' . $row->title;
         } else {
             return null;
         }
     }
 }
 /**
  * Send news mail for 1 object and 1 user
  *
  * @param int $a_user_id
  * @param int $a_ref_id
  * @param array $news
  */
 public function sendMail($a_user_id, $a_ref_id, array $news)
 {
     global $lng, $ilUser;
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     $this->initLanguage($a_user_id);
     $this->getLanguage()->loadLanguageModule("crs");
     $this->getLanguage()->loadLanguageModule("news");
     // needed for ilNewsItem
     $lng = $this->getLanguage();
     $this->initMail();
     $obj_title = $this->getLanguageText($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\"";
     $this->setRecipients($a_user_id);
     $this->setSubject(sprintf($this->getLanguageText("crs_subject_course_group_notification"), $obj_title));
     $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage()));
     $this->appendBody("\n\n");
     $this->appendBody(sprintf($this->getLanguageText("crs_intro_course_group_notification_for"), $obj_title));
     $this->appendBody("\n\n");
     // ilDatePresentation::setUseRelativeDates(false);
     // news summary
     $counter = 1;
     foreach ($news as $item) {
         $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
         $content = ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]);
         /* process sub-item info
         			if($item["aggregation"])
         			{
         				$sub = array();
         				foreach($item["aggregation"] as $subitem)
         				{
         					$sub_id = ilObject::_lookupObjId($subitem["ref_id"]);
         					$sub_title = ilObject::_lookupTitle($sub_id);
         					
         					// to include posting title
         					if($subitem["context_obj_type"] == "frm")
         					{
         						$sub_title = ilNewsItem::determineNewsTitle($subitem["context_obj_type"],
         							$subitem["title"], $subitem["content_is_lang_var"]);
         					}					
         								
         					$sub[] = $sub_title;
         					
         					$sub_content = ilNewsItem::determineNewsContent($subitem["context_obj_type"], 
         						$subitem["content"], $subitem["content_text_is_lang_var"]);								
         					if($sub_content)
         					{
         						$sub[] = strip_tags($sub_content);
         					}
         				}
         				$content .= "\n".implode("\n\n", $sub);
         			} 
         			*/
         $obj_id = ilObject::_lookupObjId($item["ref_id"]);
         $obj_title = ilObject::_lookupTitle($obj_id);
         // path
         include_once './Services/Locator/classes/class.ilLocatorGUI.php';
         $cont_loc = new ilLocatorGUI();
         $cont_loc->addContextItems($item["ref_id"], true);
         $cont_loc->setTextOnly(true);
         // #9954/#10044
         // see ilInitialisation::requireCommonIncludes()
         @(include_once "HTML/Template/ITX.php");
         // new implementation
         if (class_exists("HTML_Template_ITX")) {
             include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php";
         } else {
             include_once "HTML/ITX.php";
             // old implementation
             include_once "./Services/UICore/classes/class.ilTemplateITX.php";
         }
         require_once "./Services/UICore/classes/class.ilTemplate.php";
         $loc = "[" . $cont_loc->getHTML() . "]";
         $this->appendBody("----------------------------------------------------------------------------------------------");
         $this->appendBody("\n\n");
         $this->appendBody('#' . $counter . " - " . $loc . " " . $obj_title . "\n\n");
         $this->appendBody($title);
         if ($content) {
             $this->appendBody("\n");
             $this->appendBody($content);
         }
         $this->appendBody("\n\n");
         ++$counter;
     }
     $this->appendBody("----------------------------------------------------------------------------------------------");
     $this->appendBody("\n\n");
     // link to object
     $this->appendBody($this->getLanguageText("crs_course_group_notification_link"));
     $this->appendBody("\n");
     $object_link = ilUtil::_getHttpPath();
     $object_link .= "/goto.php?target=" . $obj_type . "_" . $a_ref_id . "&client_id=" . CLIENT_ID;
     $this->appendBody($object_link);
     $this->appendBody("\n\n");
     $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->getLanguage()));
     $this->appendBody(ilMail::_getInstallationSignature());
     // #10044
     $mail = new ilMail($ilUser->getId());
     $mail->enableSOAP(false);
     // #10410
     $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $this->getSubject(), $this->getBody(), null, array("system"));
 }
Esempio n. 20
0
 /**
  *
  * @param <type> $a_recipients
  */
 private function validatePear($a_recipients)
 {
     if (ilMail::_usePearMail()) {
         $this->setUsePear(true);
         $tmp_names = $this->explodeRecipients($a_recipients, true);
         if (is_a($tmp_names, 'PEAR_Error')) {
             $this->setUsePear(false);
         }
     } else {
         $this->setUsePear(false);
     }
 }
 public function showMailingLists()
 {
     global $rbacsystem;
     $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_mailing_lists_list.html', 'Services/Contact');
     // check if current user may send mails
     include_once "Services/Mail/classes/class.ilMail.php";
     $mail = new ilMail($_SESSION["AccountId"]);
     $mailing_allowed = $rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
     $tbl = new ilTable2GUI($this);
     $tbl->setId('show_mlng_lists_tbl');
     $tbl->setFormAction($this->ctrl->getFormAction($this), 'showForm');
     $tbl->setTitle($this->lng->txt('mail_mailing_lists'));
     $tbl->setRowTemplate('tpl.mail_mailing_lists_listrow.html', 'Services/Contact');
     $tbl->setDefaultOrderField('title');
     $result = array();
     $tbl->addColumn('', 'check', '10%', true);
     $tbl->addColumn($this->lng->txt('title'), 'title', '30%');
     $tbl->addColumn($this->lng->txt('description'), 'description', '30%');
     $tbl->addColumn($this->lng->txt('members'), 'members', '20%');
     $tbl->addColumn($this->lng->txt('actions'), '', '10%');
     $entries = $this->mlists->getAll();
     if (count($entries)) {
         $tbl->enable('select_all');
         $tbl->setSelectAllCheckbox('ml_id');
         $counter = 0;
         include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
         foreach ($entries as $entry) {
             if ($entry->getMode() == ilMailingList::MODE_TEMPORARY) {
                 continue;
             }
             $result[$counter]['check'] = ilUtil::formCheckbox(0, 'ml_id[]', $entry->getId());
             $result[$counter]['title'] = $entry->getTitle() . " [#il_ml_" . $entry->getId() . "]";
             $result[$counter]['description'] = $entry->getDescription();
             $result[$counter]['members'] = count($entry->getAssignedEntries());
             $this->ctrl->setParameter($this, 'ml_id', $entry->getId());
             //$result[$counter]['edit_text'] = $this->lng->txt("edit");
             //$result[$counter]['edit_url'] = $this->ctrl->getLinkTarget($this, "showForm");
             //$result[$counter]['members_text'] = $this->lng->txt("members");
             //$result[$counter]['members_url'] = $this->ctrl->getLinkTarget($this, "showMembersList");
             $current_selection_list = new ilAdvancedSelectionListGUI();
             $current_selection_list->setListTitle($this->lng->txt("actions"));
             $current_selection_list->setId("act_" . $counter);
             $current_selection_list->addItem($this->lng->txt("edit"), '', $this->ctrl->getLinkTarget($this, "showForm"));
             $current_selection_list->addItem($this->lng->txt("members"), '', $this->ctrl->getLinkTarget($this, "showMembersList"));
             if ($mailing_allowed) {
                 $current_selection_list->addItem($this->lng->txt("send_mail_to"), '', $this->ctrl->getLinkTarget($this, "mailToList"));
             }
             $current_selection_list->addItem($this->lng->txt("delete"), '', $this->ctrl->getLinkTarget($this, "confirmDelete"));
             $result[$counter]['COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
             ++$counter;
         }
         if ($mailing_allowed) {
             $tbl->addMultiCommand('mailToList', $this->lng->txt('send_mail_to'));
         }
         $tbl->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
     } else {
         $tbl->disable('header');
         $tbl->disable('footer');
         $tbl->setNoEntriesText($this->lng->txt('mail_search_no'));
     }
     $tbl->setData($result);
     $tbl->addCommandButton('showForm', $this->lng->txt('add'));
     if (isset($_GET['ref']) && $_GET['ref'] == 'mail') {
         $tbl->addCommandButton('cancel', $this->lng->txt('cancel'));
     }
     $this->tpl->setVariable('MAILING_LISTS', $tbl->getHTML());
     $this->tpl->show();
     return true;
 }
 public function mailMembersObject()
 {
     global $rbacreview, $ilObjDataCache;
     include_once 'Services/AccessControl/classes/class.ilObjRole.php';
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_members.html', 'Services/Contact');
     $this->__setSubTabs('members');
     include_once "./Services/Link/classes/class.ilLink.php";
     $link_to_seminar = ilLink::_getLink($this->object->getRefId());
     include_once 'Services/Mail/classes/class.ilMail.php';
     require_once 'Services/Mail/classes/class.ilMailFormCall.php';
     $this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'mailMembers', array(), array('type' => 'role')));
     $this->tpl->setVariable('ADDITIONAL_MESSAGE_TEXT', $link_to_seminar);
     $this->tpl->setVariable('IMG_ARROW', ilUtil::getImagePath('arrow_downright.png'));
     $this->tpl->setVariable('OK', $this->lng->txt('ok'));
     $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
     $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
     foreach ($role_ids as $role_id) {
         $this->tpl->setCurrentBlock('mailbox_row');
         $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
         $this->tpl->setVariable('CHECK_MAILBOX', ilUtil::formCheckbox(1, 'roles[]', htmlspecialchars($role_addr)));
         if (ilMail::_usePearMail()) {
             // if pear mail is enabled, mailbox addresses are already localized in the language of the user
             $this->tpl->setVariable('MAILBOX', $role_addr);
         } else {
             // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
             $this->tpl->setVariable('MAILBOX', ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . ' (' . $role_addr . ')');
         }
         $this->tpl->parseCurrentBlock();
     }
 }
 /**
  * delete mail
  */
 public function deleteMail()
 {
     global $lng, $ilCtrl;
     $lng->loadLanguageModule('mail');
     $umail = new ilMail($_SESSION['AccountId']);
     $mbox = new ilMailBox($_SESSION['AccountId']);
     if (!$_GET['mobj_id']) {
         $_GET['mobj_id'] = $mbox->getInboxFolder();
     }
     if ($umail->moveMailsToFolder(array($_GET['mail_id']), $mbox->getTrashFolder())) {
         ilUtil::sendInfo($lng->txt('mail_moved_to_trash'), true);
     } else {
         ilUtil::sendInfo($lng->txt('mail_move_error'), true);
     }
     $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
 }
 public function getUserMultiCommands($a_search_form = false)
 {
     global $rbacsystem, $ilUser;
     // see searchResultHandler()
     if ($a_search_form) {
         $cmds = array('activate' => $this->lng->txt('activate'), 'deactivate' => $this->lng->txt('deactivate'), 'accessRestrict' => $this->lng->txt('accessRestrict'), 'accessFree' => $this->lng->txt('accessFree'));
         if ($rbacsystem->checkAccess('delete', $this->object->getRefId())) {
             $cmds["delete"] = $this->lng->txt("delete");
         }
     } else {
         $cmds = array('activateUsers' => $this->lng->txt('activate'), 'deactivateUsers' => $this->lng->txt('deactivate'), 'restrictAccess' => $this->lng->txt('accessRestrict'), 'freeAccess' => $this->lng->txt('accessFree'));
         if ($rbacsystem->checkAccess('delete', $this->object->getRefId())) {
             $cmds["deleteUsers"] = $this->lng->txt("delete");
         }
     }
     // no confirmation needed
     $export_types = array("userfolder_export_excel_x86", "userfolder_export_csv", "userfolder_export_xml");
     foreach ($export_types as $type) {
         $cmd = explode("_", $type);
         $cmd = array_pop($cmd);
         $cmds['usrExport' . ucfirst($cmd)] = $this->lng->txt('export') . ' - ' . $this->lng->txt($type);
     }
     // check if current user may send mails
     include_once "Services/Mail/classes/class.ilMail.php";
     $mail = new ilMail($ilUser->getId());
     if ($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
         $cmds["mail"] = $this->lng->txt("send_mail");
     }
     return $cmds;
 }
Esempio n. 25
0
 static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null)
 {
     global $ilUser, $ilObjDataCache, $ilAccess;
     include_once "./Services/Notification/classes/class.ilNotification.php";
     include_once "./Modules/Wiki/classes/class.ilObjWiki.php";
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
     $wiki = new ilObjWiki($a_wiki_ref_id, true);
     $page = new ilWikiPage($a_page_id);
     // #11138
     $ignore_threshold = $a_action == "comment";
     // 1st update will be converted to new - see below
     if ($a_action == "new") {
         return;
     }
     if ($a_type == ilNotification::TYPE_WIKI_PAGE) {
         $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold);
         $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
         $users = array_merge($users, $wiki_users);
         if (!sizeof($users)) {
             return;
         }
         ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users);
     } else {
         $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
         if (!sizeof($users)) {
             return;
         }
     }
     ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id);
     // #15192 - should always be present
     if ($a_page_id) {
         include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php";
         $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle());
     } else {
         include_once "./Services/Link/classes/class.ilLink.php";
         $link = ilLink::_getLink($a_wiki_ref_id);
     }
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     // see ilBlogPostingGUI::getSnippet()
     // see ilBlogPosting::getNotificationAbstract()
     include_once "Modules/Wiki/classes/class.ilWikiPageGUI.php";
     $pgui = new ilWikiPageGUI($page->getId());
     $pgui->setRawPageContent(true);
     $pgui->setAbstractOnly(true);
     $pgui->setFileDownloadLink(".");
     $pgui->setFullscreenLink(".");
     $pgui->setSourcecodeDownloadScript(".");
     $snippet = $pgui->showPage();
     $snippet = ilPageObject::truncateHTML($snippet, 500, "...");
     // making things more readable
     $snippet = str_replace('<br/>', "\n", $snippet);
     $snippet = str_replace('<br />', "\n", $snippet);
     $snippet = str_replace('</p>', "\n", $snippet);
     $snippet = str_replace('</div>', "\n", $snippet);
     $snippet = trim(strip_tags($snippet));
     // "fake" new (to enable snippet - if any)
     $current_version = array_shift($page->getHistoryEntries());
     $current_version = $current_version["nr"];
     if (!$current_version) {
         $a_type = ilNotification::TYPE_WIKI;
         $a_action = "new";
     }
     foreach (array_unique($users) as $idx => $user_id) {
         if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) {
             // use language of recipient to compose message
             $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
             $ulng->loadLanguageModule('wiki');
             $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
             $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
             if ($a_type == ilNotification::TYPE_WIKI_PAGE) {
                 // update/delete
                 $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n";
                 $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
                 $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
                 $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n";
                 if ($snippet) {
                     $message .= "\n" . $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n";
                 }
                 // include comment/note text
                 if ($a_comment) {
                     $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n";
                 }
                 $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link;
             } else {
                 // new
                 $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n";
                 $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
                 $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
                 $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n";
                 if ($snippet) {
                     $message .= $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n\n";
                 }
                 $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link;
             }
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
         } else {
             unset($users[$idx]);
         }
     }
 }
Esempio n. 26
0
 /**
  * Define the subject line of the email
  * @param string subject any monoline string
  */
 function Subject($subject, $a_add_prefix = false)
 {
     if ($a_add_prefix) {
         // #9096
         include_once "Services/Mail/classes/class.ilMail.php";
         $prefix = ilMail::getSubjectPrefix();
         if (trim($prefix)) {
             $subject = trim($prefix) . " " . $subject;
         }
     }
     $this->xheaders['Subject'] = ilMimeMail::_mimeEncode(strtr($subject, "\r\n", " "));
 }
Esempio n. 27
0
 /**
  * goto target group
  */
 public static function _goto($a_target)
 {
     global $ilAccess, $ilErr, $lng, $rbacsystem;
     require_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($_SESSION["AccountId"]);
     if ($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
         ilUtil::redirect("ilias.php?baseClass=ilMailGUI");
         exit;
     } else {
         if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
             $_GET["cmd"] = "frameset";
             $_GET["target"] = "";
             $_GET["ref_id"] = ROOT_FOLDER_ID;
             $_GET["baseClass"] = "ilRepositoryGUI";
             ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"), ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
             include "ilias.php";
             exit;
         }
     }
     $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
 }
 /**
  * Send notifications
  * @return 
  */
 public function send()
 {
     global $ilSetting;
     // parent::send();
     switch ($this->getType()) {
         case self::TYPE_ADMISSION_MEMBER:
             // automatic mails about status change disabled
             if (!$ilSetting->get('mail_grp_member_notification', false)) {
                 return;
             }
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('grp_mail_admission_new_sub'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('grp_mail_admission_new_bod'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_DISMISS_MEMBER:
             // automatic mails about status change disabled
             if (!$ilSetting->get('mail_grp_member_notification', false)) {
                 return;
             }
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('grp_mail_dismiss_sub'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('grp_mail_dismiss_bod'), $this->getObjectTitle()));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_SUBSCRIBE_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('grp_mail_subscribe_member_sub'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('grp_mail_subscribe_member_bod'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_NOTIFICATION_REGISTRATION_REQUEST:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('grp_mail_notification_reg_req_sub'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $info = $this->getAdditionalInformation();
                 $this->appendBody(sprintf($this->getLanguageText('grp_mail_notification_reg_req_bod'), $this->userToString($info['usr_id']), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('grp_mail_notification_reg_req_bod2'));
                 $this->appendBody("\n");
                 $this->appendBody($this->createPermanentLink(array(), '_mem'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('grp_notification_explanation_admin'));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_REFUSED_SUBSCRIPTION_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('sess_mail_sub_dec_sub'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('sess_mail_sub_dec_bod'), $this->getObjectTitle()));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
         case self::TYPE_ACCEPTED_SUBSCRIPTION_MEMBER:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('sess_mail_sub_acc_sub'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody(sprintf($this->getLanguageText('sess_mail_sub_acc_bod'), $this->getObjectTitle()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('sess_mail_permanent_link'));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->createPermanentLink());
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
     }
     return true;
 }
Esempio n. 29
0
 public function sendUserResultsMail($a_active_id, $a_recipient)
 {
     global $ilUser;
     $finished = $this->object->getSurveyParticipants(array($a_active_id));
     $finished = array_pop($finished);
     $finished = ilDatePresentation::formatDate(new ilDateTime($finished["finished_tstamp"], IL_CAL_UNIX));
     require_once "Services/Mail/classes/class.ilMail.php";
     require_once "Services/Link/classes/class.ilLink.php";
     $body = ilMail::getSalutation($ilUser->getId()) . "\n\n";
     $body .= $this->lng->txt("svy_mail_own_results_body") . "\n";
     $body .= "\n" . $this->lng->txt("obj_svy") . ": " . $this->object->getTitle() . "\n";
     $body .= ilLink::_getLink($this->object->getRefId(), "svy") . "\n";
     $body .= "\n" . $this->lng->txt("survey_results_finished") . ": " . $finished . "\n\n";
     $body .= $this->getUserResultsPlain($a_active_id);
     // $body .= ilMail::_getAutoGeneratedMessageString($this->lng);
     $body .= ilMail::_getInstallationSignature();
     require_once "Services/Mail/classes/class.ilMail.php";
     $mail = new ilMail(ANONYMOUS_USER_ID);
     $mail->sendMimeMail($a_recipient, null, null, sprintf($this->lng->txt("svy_mail_own_results_subject"), $this->object->getTitle()), $body, null, true);
 }
    /**
     * _getMailBoxListData
     *
     * @access	public
     * @static
     * @return	array	Array of mails
     * 
     */
    public static function _getMailBoxListData()
    {
        global $ilDB;
        // initialize array
        $mails = array('cnt' => 0, 'cnt_unread' => 0, 'set' => array());
        // count query
        $queryCount = 'SELECT COUNT(mail_id) cnt FROM mail ' . 'LEFT JOIN usr_data ON usr_id = sender_id ' . 'WHERE user_id = %s ' . 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ' . 'AND folder_id = %s ' . 'UNION ALL ' . 'SELECT COUNT(mail_id) cnt FROM mail ' . 'LEFT JOIN usr_data ON usr_id = sender_id ' . 'WHERE user_id = %s ' . 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ' . 'AND folder_id = %s ' . 'AND m_status = %s';
        $res = $ilDB->queryf($queryCount, array('integer', 'integer', 'integer', 'integer', 'text'), array(self::$userId, self::$folderId, self::$userId, self::$folderId, 'unread'));
        $counter = 0;
        while ($cnt_row = $ilDB->fetchAssoc($res)) {
            if ($counter == 0) {
                $mails['cnt'] = $cnt_row['cnt'];
            } else {
                if ($counter == 1) {
                    $mails['cnt_unread'] = $cnt_row['cnt'];
                } else {
                    break;
                }
            }
            ++$counter;
        }
        $sortColumn = '';
        if (self::$orderColumn == 'rcp_to' && $ilDB->getDBType() == 'oracle') {
            $sortColumn = ", CAST(rcp_to AS VARCHAR2(4000)) SORTCOL";
        }
        if (self::$orderColumn == 'from') {
            // Because of the user id of automatically generated mails and ordering issues we have to do some magic
            $firstname = '
				,(CASE
					WHEN (usr_id = ' . ANONYMOUS_USER_ID . ') THEN firstname 
					ELSE ' . $ilDB->quote(ilMail::_getIliasMailerName(), 'text') . '
				END) fname
			';
        }
        // item query
        $query = 'SELECT mail.*' . $sortColumn . ' ' . $firstname . ' FROM mail ' . 'LEFT JOIN usr_data ON usr_id = sender_id ' . 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ' . 'WHERE user_id = %s ' . 'AND folder_id = %s';
        // order direction
        $orderDirection = '';
        if (in_array(strtolower(self::$orderDirection), array('desc', 'asc'))) {
            $orderDirection = self::$orderDirection;
        } else {
            $orderDirection = 'ASC';
        }
        // order column
        if (self::$orderColumn == 'rcp_to' && $ilDB->getDBType() == 'oracle') {
            $query .= ' ORDER BY SORTCOL ' . $orderDirection;
        } else {
            if (self::$orderColumn == 'from') {
                $query .= ' ORDER BY ' . ' fname ' . $orderDirection . ', ' . ' lastname ' . $orderDirection . ', ' . ' login ' . $orderDirection . ', ' . ' import_name ' . $orderDirection;
            } else {
                if (strlen(self::$orderColumn)) {
                    if (!in_array(strtolower(self::$orderColumn), array('m_subject', 'send_time', 'rcp_to')) && !$ilDB->tableColumnExists('mail', strtolower(self::$orderColumn))) {
                        // @todo: Performance problem...
                        self::$orderColumn = 'send_time';
                    }
                    $query .= ' ORDER BY ' . strtolower(self::$orderColumn) . ' ' . $orderDirection;
                } else {
                    $query .= ' ORDER BY send_time DESC';
                }
            }
        }
        $ilDB->setLimit(self::$limit, self::$offset);
        $res = $ilDB->queryF($query, array('integer', 'integer'), array(self::$userId, self::$folderId));
        while ($row = $ilDB->fetchAssoc($res)) {
            $row['attachments'] = unserialize(stripslashes($row['attachments']));
            $row['m_type'] = unserialize(stripslashes($row['m_type']));
            $mails['set'][] = $row;
        }
        return $mails;
    }