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); }
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() { $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() { 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")); }
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); }
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(); } }
/** * 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; }
/** * Delete own account dialog - action incl. notification email */ protected function deleteOwnAccount4() { global $ilUser, $ilAuth, $ilSetting, $ilLog; if (!(bool) $ilSetting->get('user_delete_own_account') || $ilUser->getId() == SYSTEM_USER_ID || !$ilUser->hasDeletionFlag()) { $this->ctrl->redirect($this, "showGeneralSettings"); } include_once "Services/Mail/classes/class.ilMail.php"; $mail = new ilMail(ANONYMOUS_USER_ID); // send mail(s) $subject = $this->lng->txt("user_delete_own_account_email_subject"); $message = $this->lng->txt("user_delete_own_account_email_body"); // salutation/info ilDatePresentation::setUseRelativeDates(false); $message = ilMail::getSalutation($ilUser->getId()) . "\n\n" . sprintf($message, $ilUser->getLogin(), ILIAS_HTTP_PATH, ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX))); // add profile data (see ilAccountRegistrationGUI) $message .= "\n\n" . $ilUser->getProfileAsString($this->lng); // signatur $message .= ilMail::_getInstallationSignature(); $user_email = $ilUser->getEmail(); $admin_mail = $ilSetting->get("user_delete_own_account_email"); // to user, admin as bcc if ($user_email) { $mail->sendMimeMail($user_email, null, $admin_mail, $subject, $message, null, true); } else { if ($admin_mail) { $mail->sendMimeMail($admin_mail, null, null, $subject, $message, null, true); } } $ilLog->write("Account deleted: " . $ilUser->getLogin() . " (" . $ilUser->getId() . ")"); $ilUser->delete(); // terminate session $ilAuth->logout(); session_destroy(); ilUtil::redirect("login.php?accdel=1"); }
/** * generates the notificiation message, if a post has been answered * * @param array $thread_data * @param array $post_data * @param object $user_obj ilObjUser * @return string */ private function __formatMessage($thread_data, $post_data = array(), $user_obj) { include_once "./Services/Object/classes/class.ilObjectFactory.php"; $user_lang = self::_getLanguageInstanceByUsrId($user_obj->getId()); $frm_obj =& ilObjectFactory::getInstanceByRefId($this->getForumRefId()); $title = $frm_obj->getTitle(); unset($frm_obj); $message = ''; $message .= ilMail::getSalutation($user_obj->getId(), $user_lang); $message .= "\n\n"; $message .= $this->lng->txt("forum_post_replied"); $message .= $this->lng->txt("forum") . ": " . $title . " -> " . $thread_data["thr_subject"] . "\n\n"; $message .= "\n------------------------------------------------------------\n"; $message .= $post_data["pos_message"]; $message .= "\n------------------------------------------------------------\n"; $message .= sprintf($this->lng->txt("forums_notification_show_post"), "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]) . "/goto.php?target=frm_" . $post_data["ref_id"] . "_" . $post_data["pos_thr_fk"] . '&client_id=' . CLIENT_ID) . "\n\n"; $message .= ilMail::_getInstallationSignature(); return $message; }