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 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"));
 }
 /**
  * Compose notification of sequence booking for the creator of that booking.
  *
  * @param array $a_user_id The user who will get the mail.
  *                         Returns nothing.
  */
 private function composeSequenceBookingMailForCreator($a_user_id)
 {
     $lng = $this->lng;
     $this->initLanguage($a_user_id);
     $this->initMail();
     $this->setSubject($this->lng->txt('rep_robj_xrs_mail_sequencebook_creator_subject'));
     $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage()));
     $this->appendBody("\n\n");
     $this->appendBody($lng->txt('rep_robj_xrs_mail_sequencebook_cre ator_message') . "\n");
     $this->appendBody($lng->txt('rep_robj_xrs_room') . " ");
     $this->appendBody($this->s_roomname . " ");
     $this->appendBody($lng->txt('rep_robj_xrs_from') . " ");
     $this->appendBody($this->datestart->get(IL_CAL_FKT_DATE, 'd.m.Y H:s') . " ");
     $this->appendBody($lng->txt('rep_robj_xrs_to') . " ");
     $this->appendBody($this->dateend->get(IL_CAL_FKT_DATE, 'd.m.Y H:s'));
     $this->appendBody("\n\n");
     $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->language));
 }
 /**
  * send notifications about new EContent
  */
 protected function sendNewContentNotification($a_server_id)
 {
     include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php';
     $settings = ilECSSetting::getInstanceByServerId($a_server_id);
     if (!count($rcps = $settings->getEContentRecipients())) {
         return;
     }
     include_once './Services/Mail/classes/class.ilMail.php';
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     $mail = new ilMail(self::MAIL_SENDER);
     $message = $lang->txt('ecs_' . $this->getType() . '_created_body_a') . "\n\n";
     $message .= $lang->txt('title') . ': ' . $this->getTitle() . "\n";
     if (strlen($desc = $this->getDescription())) {
         $message .= $lang->txt('desc') . ': ' . $desc . "\n";
     }
     include_once './Services/Link/classes/class.ilLink.php';
     $href = ilLink::_getStaticLink($this->getRefId(), $this->getType(), true);
     $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
     $message .= ilMail::_getAutoGeneratedMessageString();
     $mail->sendMail($settings->getEContentRecipientsAsString(), '', '', $lang->txt('ecs_new_econtent_subject'), $message, array(), array('normal'));
 }
 /**
  * send notifications about new EContent
  *
  * @return bool
  */
 protected function sendNewContentNotification(ilECSSetting $a_server, $a_econtent_id)
 {
     global $ilLog;
     if (!count($rcps = $a_server->getApprovalRecipients())) {
         return true;
     }
     include_once './Services/Mail/classes/class.ilMail.php';
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     // @TODO: read mail
     $mail = new ilMail(self::MAIL_SENDER);
     $message = $lang->txt('ecs_export_created_body_a') . "\n\n";
     $message .= $lang->txt('title') . ': ' . $this->content_obj->getTitle() . "\n";
     if (strlen($desc = $this->content_obj->getDescription())) {
         $message .= $lang->txt('desc') . ': ' . $desc . "\n";
     }
     // Participant info
     $message .= "\n" . $lang->txt('ecs_published_for');
     try {
         $found = false;
         $receivers = null;
         include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
         $details = ilECSEContentDetails::getInstance($a_server->getServerId(), $a_econtent_id, $this->getECSObjectType());
         if ($details instanceof ilECSEContentDetails) {
             $receivers = $details->getReceivers();
         }
         if ($receivers) {
             foreach ($receivers as $member) {
                 $found = true;
                 include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
                 $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
                 $message .= "\n\n" . $part->getParticipantName() . "\n";
                 $message .= $part->getDescription();
             }
         }
         if ($found) {
             $message .= "\n\n";
         } else {
             $message .= ' ' . $lang->txt('ecs_not_published') . "\n\n";
         }
     } catch (ilECSConnectorException $e) {
         $ilLog->write(__METHOD__ . ': Cannot read approvements.');
         return false;
     }
     include_once './Services/Link/classes/class.ilLink.php';
     $href = ilLink::_getStaticLink($this->content_obj->getRefId(), 'crs', true);
     $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
     $message .= ilMail::_getAutoGeneratedMessageString();
     $mail->sendMail($a_server->getApprovalRecipientsAsString(), '', '', $lang->txt('ecs_new_approval_subject'), $message, array(), array('normal'));
     return true;
 }
    public function send()
    {
        global $ilDB, $lng, $ilSetting;
        $is_message_enabled = $ilSetting->get("mail_notification_message");
        $res = $ilDB->queryF('SELECT mail.* FROM mail_options
						INNER JOIN mail ON mail.user_id = mail_options.user_id
						INNER JOIN mail_obj_data ON mail_obj_data.obj_id = mail.folder_id
						WHERE cronjob_notification = %s
						AND send_time >= %s
						AND m_status = %s', array('integer', 'timestamp', 'text'), array(1, date('Y-m-d H:i:s', time() - 60 * 60 * 24), 'unread'));
        $users = array();
        $user_id = 0;
        while ($row = $ilDB->fetchAssoc($res)) {
            if ($user_id == 0 || $row['user_id'] != $user_id) {
                $user_id = $row['user_id'];
            }
            $users[$user_id][] = $row;
        }
        foreach ($users as $user_id => $mail_data) {
            $this->initLanguage($user_id);
            $user_lang = $this->getLanguage() ? $this->getLanguage() : $lng;
            $this->initMail();
            $this->setRecipients($user_id);
            $this->setSubject($this->getLanguageText('mail_notification_subject'));
            $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
            $this->appendBody("\n\n");
            if (count($mail_data) == 1) {
                $this->appendBody(sprintf($user_lang->txt('mail_at_the_ilias_installation'), count($mail_data), ilUtil::_getHttpPath()));
            } else {
                $this->appendBody(sprintf($user_lang->txt('mails_at_the_ilias_installation'), count($mail_data), ilUtil::_getHttpPath()));
            }
            $this->appendBody("\n\n");
            $counter = 1;
            foreach ($mail_data as $mail) {
                $this->appendBody("----------------------------------------------------------------------------------------------");
                $this->appendBody("\n\n");
                $this->appendBody('#' . $counter . "\n\n");
                $this->appendBody($user_lang->txt('date') . ": " . $mail['send_time']);
                $this->appendBody("\n");
                if ($mail['sender_id'] == ANONYMOUS_USER_ID) {
                    $sender = ilMail::_getIliasMailerName();
                } else {
                    $sender = ilObjUser::_lookupLogin($mail['sender_id']);
                }
                $this->appendBody($user_lang->txt('sender') . ": " . $sender);
                $this->appendBody("\n");
                $this->appendBody($user_lang->txt('subject') . ": " . $mail['m_subject']);
                $this->appendBody("\n\n");
                if ($is_message_enabled == true) {
                    $this->appendBody($user_lang->txt('message') . ": " . $mail['m_message']);
                    $this->appendBody("\n\n");
                }
                ++$counter;
            }
            $this->appendBody("----------------------------------------------------------------------------------------------");
            $this->appendBody("\n\n");
            $this->appendBody($user_lang->txt('follow_link_to_read_mails') . " ");
            $this->appendBody("\n");
            $mailbox_link = ilUtil::_getHttpPath();
            $mailbox_link .= "/goto.php?target=mail&client_id=" . CLIENT_ID;
            $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(ilMail::getIliasMailerAddress());
            $mmail->To(ilObjUser::_lookupEmail($user_id));
            $mmail->Subject($this->getSubject());
            $mmail->Body($this->getBody());
            $mmail->Send();
        }
    }
 /**
  * send notification about new user accounts
  *
  * @access protected
  */
 protected static function _sendNotification(ilECSSetting $server, ilObjUser $user_obj)
 {
     if (!count($server->getUserRecipients())) {
         return true;
     }
     // If sub id is set => mail was send
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($server->getServerId(), $user_obj->getId());
     if ($import->getSubId()) {
         return false;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($server->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
     // Store sub_id = 1 in ecs import which means mail is send
     $import->setSubId(1);
     $import->save();
     return true;
 }
 /**
  * Send notification
  *
  * @access private
  * @param
  * 
  */
 private function sendNotification($user_obj)
 {
     if (!count($this->getCurrentServer()->getUserRecipients())) {
         return true;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     include_once './Services/Language/classes/class.ilLanguage.php';
     $lang = ilLanguageFactory::_getLanguage();
     $GLOBALS['lng'] = $lang;
     $GLOBALS['ilUser'] = $user_obj;
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($this->getCurrentServer()->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
 }
 /**
  * Compose notification to single recipient
  * 
  * @param mixed $a_rcp
  * @param string $a_goto_additional
  * @param string $a_permission
  * @param bool $a_append_signature_direct
  * @return bool
  */
 public function compose($a_user_id, $a_goto_additional = null, $a_permission = "read", $a_append_signature_direct = false)
 {
     $this->initLanguage($a_user_id);
     $this->initMail();
     $this->setSubject(sprintf($this->getLanguageText($this->subject_lang_id), $this->getObjectTitle(true)));
     $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage()));
     $this->appendBody("\n\n");
     if ($this->introduction) {
         $this->appendBody($this->getLanguageText($this->introduction));
         $this->appendBody("\n\n");
     }
     if ($this->introduction_direct) {
         $this->appendBody($this->introduction_direct);
         $this->appendBody("\n\n");
     }
     if ($this->task) {
         $this->appendBody($this->getLanguageText($this->task));
         $this->appendBody("\n\n");
     }
     // details table
     if ($this->getObjId()) {
         $this->appendBody($this->getLanguageText("obj_" . $this->getObjType()) . ": " . $this->getObjectTitle() . "\n");
     }
     if (sizeof($this->additional)) {
         foreach ($this->additional as $lang_id => $item) {
             if (!$item[1]) {
                 $this->appendBody($this->getLanguageText($lang_id) . ": " . $item[0] . "\n");
             } else {
                 $this->appendBody("\n" . $this->getLanguageText($lang_id) . "\n" . $this->getBlockBorder() . $item[0] . "\n" . $this->getBlockBorder() . "\n");
             }
         }
     }
     $this->body = trim($this->body);
     $this->appendBody("\n\n");
     if ($this->changed_by) {
         $this->appendBody($this->getLanguageText("system_notification_installation_changed_by") . ": " . ilUserUtil::getNamePresentation($this->changed_by));
         $this->appendBody("\n\n");
     }
     if ($this->getObjId()) {
         // try to find accessible ref_id
         if (!$this->getRefId() && $this->all_ref_ids) {
             $find_ref_id = true;
             foreach ($this->all_ref_ids as $ref_id) {
                 if ($this->isRefIdAccessible($a_user_id, $ref_id, $a_permission)) {
                     $this->ref_id = $ref_id;
                     break;
                 }
             }
         }
         // check if initially given ref_id is accessible for current recipient
         if ($this->getRefId() && !$find_ref_id && !$this->isRefIdAccessible($a_user_id, $this->getRefId(), $a_permission)) {
             return false;
         }
         $goto = $this->createPermanentLink(array(), $a_goto_additional);
         if ($goto) {
             $this->appendBody($this->getLanguageText($this->goto_caption) . ": " . $goto);
             $this->appendBody("\n\n");
         }
         if ($find_ref_id) {
             $this->ref_id = null;
         }
     }
     if ($this->reason) {
         $this->appendBody($this->getLanguageText($this->reason));
         $this->appendBody("\n\n");
     }
     $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->language));
     // signature will append new lines
     $this->body = trim($this->body);
     if (!$a_append_signature_direct) {
         $this->getMail()->appendInstallationSignature(true);
     } else {
         $this->appendBody(ilMail::_getInstallationSignature());
     }
     return true;
 }