Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 /**
  * Move the submitted thread to the submitted parent
  * 
  * @param string $thread_id    the thread to move
  * @param string $destination  the threads new parent
  */
 function move_thread_action($thread_id, $destination)
 {
     ForumPerm::check('move_thread', $this->getId(), $thread_id);
     ForumPerm::check('move_thread', $this->getId(), $destination);
     $current_area = ForumEntry::getParentTopicId($thread_id);
     ForumEntry::move($thread_id, $destination);
     $this->redirect(PluginEngine::getLink('coreforum/index/index/' . $current_area . '/' . ForumHelpers::getPage()));
 }
Пример #3
0
 /**
  * delete an entry and all his descendants from the mptt-table
  *
  * @param type $topic_id the id of the entry to delete
  *
  * @return void
  */
 function delete($topic_id)
 {
     NotificationCenter::postNotification('ForumBeforeDelete', $topic_id);
     $constraints = ForumEntry::getConstraints($topic_id);
     $parent = ForumEntry::getConstraints(ForumEntry::getParentTopicId($topic_id));
     // #TODO: Zusammenfassen in eine Transaktion!!!
     // get all entry-ids to delete them from the category-reference-table
     $stmt = DBManager::get()->prepare("SELECT topic_id FROM forum_entries\n            WHERE seminar_id = ? AND lft >= ? AND rgt <= ? AND depth = 1");
     $stmt->execute(array($constraints['seminar_id'], $constraints['lft'], $constraints['rgt']));
     $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
     if ($ids != false && !is_array($ids)) {
         $ids = array($ids);
     }
     if (!empty($ids)) {
         $stmt = DBManager::get()->prepare("DELETE FROM forum_categories_entries\n                WHERE topic_id IN (:ids)");
         $stmt->bindParam(':ids', $ids, StudipPDO::PARAM_ARRAY);
         $stmt->execute();
     }
     // delete all entries
     $stmt = DBManager::get()->prepare("DELETE FROM forum_entries\n            WHERE seminar_id = ? AND lft >= ? AND rgt <= ?");
     $stmt->execute(array($constraints['seminar_id'], $constraints['lft'], $constraints['rgt']));
     // update lft and rgt
     $diff = $constraints['rgt'] - $constraints['lft'] + 1;
     $stmt = DBManager::get()->prepare("UPDATE forum_entries SET lft = lft - {$diff}\n            WHERE lft > ? AND seminar_id = ?");
     $stmt->execute(array($constraints['rgt'], $constraints['seminar_id']));
     $stmt = DBManager::get()->prepare("UPDATE forum_entries SET rgt = rgt - {$diff}\n            WHERE rgt > ? AND seminar_id = ?");
     $stmt->execute(array($constraints['rgt'], $constraints['seminar_id']));
     // set the latest_chdate to the latest child's chdate
     $stmt = DBManager::get()->prepare("SELECT chdate FROM forum_entries\n            WHERE lft > ? AND rgt < ? AND seminar_id = ?\n            ORDER BY chdate DESC LIMIT 1");
     $stmt->execute(array($parent['lft'], $parent['rgt'], $parent['seminar_id']));
     $chdate = $stmt->fetchColumn();
     $stmt_insert = DBManager::get()->prepare("UPDATE forum_entries\n            SET chdate = ? WHERE topic_id = ?");
     if ($chdate) {
         $stmt_insert->execute(array($chdate, $parent['topic_id']));
     } else {
         $stmt_insert->execute(array($parent['chdate'], $parent['topic_id']));
     }
 }
Пример #4
0
echo $post['topic_id'];
?>
" <?php 
echo $edit_posting == $post['topic_id'] ? '' : 'style="display: none;"';
?>
>
                <input type="text" name="name" value="<?php 
echo htmlReady($post['name_raw']);
?>
" data-reset="<?php 
echo htmlReady($post['name_raw']);
?>
" style="width: 100%">
            </span>
            <? else : ?>
                <? $parent_topic = ForumEntry::getConstraints(ForumEntry::getParentTopicId($post['topic_id'])) ?>

                <? if($constraint['closed']) : ?>
                <?php 
echo Icon::create('lock-locked', 'info', ['title' => _('Dieses Thema wurde geschlossen. Sie können daher nicht auf diesen Beitrag antworten.')])->asImg(16);
?>
                <? endif ?>

                <span data-edit-topic="<?php 
echo $post['topic_id'];
?>
">
                    <span name="name" value="<?php 
echo htmlReady($parent_topic['name']);
?>
"></span>