Пример #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
 public static function isClosed($topic_id)
 {
     foreach (ForumEntry::getPathToPosting($topic_id) as $entry) {
         if ($entry['closed']) {
             return true;
         }
     }
     return false;
 }
Пример #3
0
 /**
  * Delete the submitted entry.
  * 
  * @param string $topic_id the entry to delete
  */
 function delete_entry_action($topic_id)
 {
     // get the page of the posting to be able to jump there again
     $page = ForumEntry::getPostingPage($topic_id);
     URLHelper::addLinkParam('page', $page);
     if (ForumPerm::hasEditPerms($topic_id) || ForumPerm::check('remove_entry', $this->getId(), $topic_id)) {
         $path = ForumEntry::getPathToPosting($topic_id);
         $topic = array_pop($path);
         $parent = array_pop($path);
         if ($topic_id != $this->getId()) {
             // only delete directly if passed by ajax, otherwise ask for confirmation
             if (Request::isXhr() || Request::get('approve_delete')) {
                 ForumEntry::delete($topic_id);
                 $this->flash['messages'] = array('success' => sprintf(_('Der Eintrag %s wurde gelöscht!'), $topic['name']));
             } else {
                 $this->flash['messages'] = array('info_html' => sprintf(_('Sind sie sicher dass Sie den Eintrag %s löschen möchten?'), $topic['name']) . '<br>' . \Studip\LinkButton::createAccept(_('Ja'), PluginEngine::getUrl('coreforum/index/delete_entry/' . $topic_id . '?approve_delete=1')) . \Studip\LinkButton::createCancel(_('Nein'), PluginEngine::getUrl('coreforum/index/index/' . ForumEntry::getParentTopicId($topic_id) . '/' . $page)));
             }
         } else {
             $this->flash['messages'] = array('success' => _('Sie können nicht die gesamte Veranstaltung löschen!'));
         }
     }
     if (Request::isXhr()) {
         $this->render_template('messages');
         $this->flash['messages'] = null;
     } else {
         $this->redirect(PluginEngine::getLink('coreforum/index/index/' . $parent['id'] . '/' . $page));
     }
 }
Пример #4
0
echo _('Letzte Beiträge');
?>
        </a>
    <? elseif ($section == 'favorites') : ?>
        <a href="<?php 
echo PluginEngine::getURL('coreforum/index/favorites');
?>
">
            <?php 
echo _('Gemerkte Beiträge');
?>
        </a>        
    <? else: ?>

        <? $first = true ?>
        <? foreach (ForumEntry::getPathToPosting($topic_id) as $path_part) : ?>
            <? if (!$first) : ?> &gt;&gt; <? endif ?>
            <a href="<?php 
echo PluginEngine::getLink('coreforum/index/index/' . $path_part['id']);
?>
">
                <?php 
echo htmlReady(ForumEntry::killFormat($path_part['name']));
?>
            </a>
            <? $first = false ?>
        <? endforeach ?>
    <? endif ?>
    </span>        
</div>
Пример #5
0
 /**
  * move the submitted topics[] to the passed destination
  * 
  * @param string $destination id of seminar to move topics to
  */
 function move_action($destination)
 {
     // check if destination is a category_id. if yes, use seminar_id instead
     if (ForumCat::get($destination)) {
         $category_id = $destination;
         $destination = $this->getId();
     }
     ForumPerm::check('admin', $this->getId(), $destination);
     foreach (Request::getArray('topics') as $topic_id) {
         // make sure every passed topic_id is checked against the current seminar
         ForumPerm::check('admin', $this->getId(), $topic_id);
         // if the source is an area and the target a category, just move this area to the category
         $entry = ForumEntry::getEntry($topic_id);
         if ($entry['depth'] == 1 && $category_id) {
             ForumCat::removeArea($topic_id);
             ForumCat::addArea($category_id, $topic_id);
         } else {
             // first step: move the whole topic with all childs
             ForumEntry::move($topic_id, $destination);
             // if the current topic id is an area, remove it from any categories
             ForumCat::removeArea($topic_id);
             // second step: move all to deep childs a level up (depth > 3)
             $data = ForumEntry::getList('depth_to_large', $topic_id);
             foreach ($data['list'] as $entry) {
                 $path = ForumEntry::getPathToPosting($entry['topic_id']);
                 array_shift($path);
                 // Category
                 array_shift($path);
                 // Area
                 $thread = array_shift($path);
                 // Thread
                 ForumEntry::move($entry['topic_id'], $thread['id']);
             }
             // add entry to passed category when moving to the top
             if ($category_id) {
                 ForumCat::addArea($category_id, $topic_id);
             }
         }
     }
     $this->render_nothing();
 }