/** * Send news mail for 1 object and 1 user * * @param int $a_user_id * @param int $a_ref_id * @param array $news */ protected 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); include_once "./Services/Notification/classes/class.ilSystemNotification.php"; $ntf = new ilSystemNotification(); $ntf->setLangModules(array("crs", "news")); $ntf->setRefId($a_ref_id); $ntf->setGotoLangId('url'); $ntf->setSubjectLangId('crs_subject_course_group_notification'); // user specific language $lng = $ntf->getUserLanguage($a_user_id); $obj_title = $lng->txt($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\""; $ntf->setIntroductionDirect(sprintf($lng->txt("crs_intro_course_group_notification_for"), $obj_title)); $subject = sprintf($lng->txt("crs_subject_course_group_notification"), $obj_title); // news summary $counter = 1; $txt = ""; 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"]); $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() . "]"; if ($counter > 1) { $txt .= $ntf->getBlockBorder(); } $txt .= '#' . $counter . " - " . $loc . " " . $obj_title . "\n\n"; $txt .= $title; if ($content) { $txt .= "\n" . $content; } $txt .= "\n\n"; ++$counter; } $ntf->addAdditionalInfo("news", $txt, true); // #10044 $mail = new ilMail($ilUser->getId()); $mail->enableSOAP(false); // #10410 $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $subject, $ntf->composeAndGetMessage($a_user_id, null, "read", true), null, array("system")); }