示例#1
0
 /**
  * Prepare message actions display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('id');
     $me = KunenaUserHelper::getMyself();
     $this->category = KunenaForumCategory::getInstance($catid);
     $token = JSession::getFormToken();
     $task = "index.php?option=com_kunena&view=category&task=%s&catid={$catid}&{$token}=1";
     $layout = "index.php?option=com_kunena&view=topic&layout=%s&catid={$catid}";
     $this->template = KunenaFactory::getTemplate();
     $this->categoryButtons = new JObject();
     // Is user allowed to post new topic?
     if ($this->category->getNewTopicCategory()->exists()) {
         $this->categoryButtons->set('create', $this->getButton(sprintf($layout, 'create'), 'create', 'topic', 'communication', true));
     }
     // Is user allowed to mark forums as read?
     if ($me->exists()) {
         $this->categoryButtons->set('markread', $this->getButton(sprintf($task, 'markread'), 'markread', 'category', 'user', true));
     }
     // Is user allowed to subscribe category?
     if ($this->category->isAuthorised('subscribe')) {
         $subscribed = $this->category->getSubscribed($me->userid);
         if (!$subscribed) {
             $this->categoryButtons->set('subscribe', $this->getButton(sprintf($task, 'subscribe'), 'subscribe', 'category', 'user', true));
         } else {
             $this->categoryButtons->set('unsubscribe', $this->getButton(sprintf($task, 'unsubscribe'), 'unsubscribe', 'category', 'user', true));
         }
     }
     JPluginHelper::importPlugin('kunena');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onKunenaGetButtons', array('category.action', $this->categoryButtons, $this));
 }
示例#2
0
 /**
  * Prepare poll display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->topic = KunenaForumTopicHelper::get($this->input->getInt('id'));
     $this->category = $this->topic->getCategory();
     $this->config = KunenaFactory::getConfig();
     $this->me = KunenaUserHelper::getMyself();
     // Need to check if poll is allowed in this category.
     $this->topic->tryAuthorise('poll.read');
     $this->poll = $this->topic->getPoll();
     $this->usercount = $this->poll->getUserCount();
     $this->usersvoted = $this->poll->getUsers();
     $this->voted = $this->poll->getMyVotes();
     if (!empty($this->alwaysVote)) {
         // Authorise forced vote.
         $this->topic->tryAuthorise('poll.vote');
         $this->name = 'Topic/Poll/Vote';
     } elseif (!$this->voted && $this->topic->isAuthorised('poll.vote')) {
         $this->name = 'Topic/Poll/Vote';
     } else {
         $this->name = 'Topic/Poll/Results';
         $this->show_title = true;
         $this->users_voted_list = array();
         $this->users_voted_morelist = array();
         if ($this->config->pollresultsuserslist && !empty($this->usersvoted)) {
             $userids_votes = array();
             foreach ($this->usersvoted as $userid => $vote) {
                 $userids_votes[] = $userid;
             }
             $loaded_users = KunenaUserHelper::loadUsers($userids_votes);
             $i = 0;
             foreach ($loaded_users as $userid => $user) {
                 if ($i <= '4') {
                     $this->users_voted_list[] = $loaded_users[$userid]->getLink();
                 } else {
                     $this->users_voted_morelist[] = $loaded_users[$userid]->getLink();
                 }
                 $i++;
             }
         }
     }
     $this->uri = "index.php?option=com_kunena&view=topic&layout=poll&catid={$this->category->id}&id={$this->topic->id}";
 }
示例#3
0
 /**
  * After render update topic data for the user.
  *
  * @return void
  */
 protected function after()
 {
     parent::after();
     $this->topic->hit();
     $this->topic->markRead();
     // Check if subscriptions have been sent and reset the value.
     if ($this->topic->isAuthorised('subscribe') && $this->userTopic->subscribed == 2) {
         $this->userTopic->subscribed = 1;
         $this->userTopic->save();
     }
 }
示例#4
0
 /**
  * Prepare topic actions display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $id = $this->input->getInt('id');
     $this->topic = KunenaForumTopic::getInstance($id);
     $catid = $this->topic->category_id;
     $token = JSession::getFormToken();
     $task = "index.php?option=com_kunena&view=topic&task=%s&catid={$catid}&id={$id}&{$token}=1";
     $layout = "index.php?option=com_kunena&view=topic&layout=%s&catid={$catid}&id={$id}";
     $userTopic = $this->topic->getUserTopic();
     $this->template = KunenaFactory::getTemplate();
     $this->topicButtons = new JObject();
     if ($this->topic->isAuthorised('reply')) {
         // Add Reply topic button.
         $this->topicButtons->set('reply', $this->getButton(sprintf($layout, 'reply'), 'reply', 'topic', 'communication'));
     }
     if ($userTopic->subscribed) {
         // User can always remove existing subscription.
         $this->topicButtons->set('subscribe', $this->getButton(sprintf($task, 'unsubscribe'), 'unsubscribe', 'topic', 'user'));
     } elseif ($this->topic->isAuthorised('subscribe')) {
         // Add subscribe topic button.
         $this->topicButtons->set('subscribe', $this->getButton(sprintf($task, 'subscribe'), 'subscribe', 'topic', 'user'));
     }
     if ($userTopic->favorite) {
         // User can always remove existing favorite.
         $this->topicButtons->set('favorite', $this->getButton(sprintf($task, 'unfavorite'), 'unfavorite', 'topic', 'user'));
     } elseif ($this->topic->isAuthorised('favorite')) {
         // Add favorite topic button.
         $this->topicButtons->set('favorite', $this->getButton(sprintf($task, 'favorite'), 'favorite', 'topic', 'user'));
     }
     if ($this->topic->getCategory()->isAuthorised('moderate')) {
         // Add moderator specific buttons.
         $sticky = $this->topic->ordering ? 'unsticky' : 'sticky';
         $lock = $this->topic->locked ? 'unlock' : 'lock';
         $this->topicButtons->set('sticky', $this->getButton(sprintf($task, $sticky), $sticky, 'topic', 'moderation'));
         $this->topicButtons->set('lock', $this->getButton(sprintf($task, $lock), $lock, 'topic', 'moderation'));
         $this->topicButtons->set('moderate', $this->getButton(sprintf($layout, 'moderate'), 'moderate', 'topic', 'moderation'));
         if ($this->topic->hold == 1) {
             $this->topicButtons->set('approve', $this->getButton(sprintf($task, 'approve'), 'moderate', 'topic', 'moderation'));
         }
         if ($this->topic->hold == 1 || $this->topic->hold == 0) {
             $this->topicButtons->set('delete', $this->getButton(sprintf($task, 'delete'), 'delete', 'topic', 'moderation'));
         } elseif ($this->topic->hold == 2 || $this->topic->hold == 3) {
             $this->topicButtons->set('undelete', $this->getButton(sprintf($task, 'undelete'), 'undelete', 'topic', 'moderation'));
         }
     }
     // Add buttons for changing between different layout modes.
     if (KunenaFactory::getConfig()->enable_threaded_layouts) {
         $url = "index.php?option=com_kunena&view=user&task=change&topic_layout=%s&{$token}=1";
         if ($this->layout != 'default') {
             $this->topicButtons->set('flat', $this->getButton(sprintf($url, 'flat'), 'flat', 'layout', 'user'));
         }
         if ($this->layout != 'threaded') {
             $this->topicButtons->set('threaded', $this->getButton(sprintf($url, 'threaded'), 'threaded', 'layout', 'user'));
         }
         if ($this->layout != 'indented') {
             $this->topicButtons->set('indented', $this->getButton(sprintf($url, 'indented'), 'indented', 'layout', 'user'));
         }
     }
     JPluginHelper::importPlugin('kunena');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onKunenaGetButtons', array('topic.action', $this->topicButtons, $this));
 }