/** * send out the notification messages for the passed topic. The contents * and a link directly to the topic are added to the messages. * * @param string $topic_id */ static function notify($topic_id) { // send message to all abo-users $db = DBManager::get(); $messaging = new ForumBulkMail(); // $messaging = new Messaging(); // get all parent topic-ids, to find out which users to notify $path = ForumEntry::getPathToPosting($topic_id); // fetch all users to notify, exlcude current user $stmt = $db->prepare("SELECT DISTINCT user_id\n FROM forum_abo_users\n WHERE topic_id IN (:topic_ids)\n AND user_id != :user_id"); $stmt->bindParam(':topic_ids', array_keys($path), StudipPDO::PARAM_ARRAY); $stmt->bindParam(':user_id', $GLOBALS['user']->id); $stmt->execute(); // get details for topic $topic = ForumEntry::getConstraints($topic_id); $template_factory = new Flexi_TemplateFactory(dirname(__FILE__) . '/../views'); $template = $template_factory->open('index/_mail_notification'); // notify users while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) { $user_id = $data['user_id']; // create subject and content setTempLanguage(get_userid($user_id)); // check if user wants an email for all or selected messages only $force_email = false; if ($messaging->user_wants_email($user_id)) { $force_email = true; } $parent_id = ForumEntry::getParentTopicId($topic['topic_id']); setTempLanguage($data['user_id']); $notification = sprintf(_("%s hat einen Beitrag geschrieben"), $topic['anonymous'] ? _('Anonym') : $topic['author']); restoreLanguage(); PersonalNotifications::add($user_id, UrlHelper::getUrl('plugins.php/coreforum/index/index/' . $topic['topic_id'] . '#' . $topic['topic_id'], array('cid' => $topic['seminar_id']), true), $notification, "forumposting_" . $topic['topic_id'], Icon::create('forum', 'clickable')->asImagePath(40)); if ($force_email) { $title = implode(' >> ', ForumEntry::getFlatPathToPosting($topic_id)); $subject = addslashes(_('[Forum]') . ' ' . ($title ?: _('Neuer Beitrag'))); $htmlMessage = $template->render(compact('user_id', 'topic', 'path')); $textMessage = trim(kill_format($htmlMessage)); $userWantsHtml = UserConfig::get($user_id)->getValue('MAIL_AS_HTML'); StudipMail::sendMessage(User::find($user_id)->email, $subject, addslashes($textMessage), $userWantsHtml ? $htmlMessage : null); } restoreLanguage(); } $messaging->bulkSend(); }
<? endif ?> <span data-show-topic="<?php echo $post['topic_id']; ?> "> <a href="<?php echo PluginEngine::getLink('coreforum/index/index/' . $post['topic_id'] . '?' . http_build_query(array('highlight' => $highlight))); ?> #<?php echo $post['topic_id']; ?> "> <? if ($show_full_path) : ?> <?php echo ForumHelpers::highlight(htmlReady(implode(' >> ', ForumEntry::getFlatPathToPosting($post['topic_id']))), $highlight); ?> <? elseif ($post['depth'] < 3) : ?> <span data-topic-name="<?php echo $post['topic_id']; ?> "> <? if ($edit_posting != $post['topic_id']) : ?> <?php echo $post['name_raw'] && $post['depth'] < 3 ? ForumHelpers::highlight(htmlReady($post['name_raw']), $highlight) : ''; ?> <? endif ?> </span> <? endif ?> </a> </span>