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]); } } }
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"; 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; } include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle()); 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; } include_once "./Services/Link/classes/class.ilLink.php"; $link = ilLink::_getLink($a_wiki_ref_id); } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_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"; 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()); $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"; // 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"; $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]); } } }