/** * Prepare report message form. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $id = $this->input->getInt('id'); $mesid = $this->input->getInt('mesid'); $me = KunenaUserHelper::getMyself(); if (!$this->config->reportmsg) { // Deny access if report feature has been disabled. throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404); } if (!$me->exists()) { // Deny access if user is guest. throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401); } if (!$mesid) { $this->topic = KunenaForumTopicHelper::get($id); $this->topic->tryAuthorise(); } else { $this->message = KunenaForumMessageHelper::get($mesid); $this->message->tryAuthorise(); $this->topic = $this->message->getTopic(); } $this->category = $this->topic->getCategory(); $this->uri = "index.php?option=com_kunena&view=topic&layout=report&catid={$this->category->id}" . "&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : ''); }
public function onAfterPost(KunenaForumMessage $message) { if (JString::strlen($message->message) > $this->params->get('activity_points_limit', 0)) { CFactory::load ( 'libraries', 'userpoints' ); CUserPoints::assignPoint ( 'com_kunena.thread.new' ); } $act = new stdClass (); $act->cmd = 'wall.write'; $act->actor = $message->userid; $act->target = 0; // no target $act->title = JText::_('{actor} ' . JText::sprintf( 'PLG_KUNENA_COMMUNITY_ACTIVITY_POST_TITLE', ' <a href="' . $message->getTopic()->getUrl() . '">' . $message->displayField('subject') . '</a>') ); $act->content = $this->buildContent($message); $act->app = 'kunena.thread.post'; $act->cid = $message->thread; $act->access = $this->getAccess($message->getCategory()); // Comments and like support $act->comment_id = $message->thread; $act->comment_type = 'kunena.thread.post'; $act->like_id = $message->thread; $act->like_type = 'kunena.thread.post'; // Do not add private activities if ($act->access > 20) return; CFactory::load ( 'libraries', 'activities' ); $table = CActivityStream::add($act); if(is_object($table)) { $table->like_id = $table->id; $table->store(); } }
/** * Prepare topic moderate display. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $catid = $this->input->getInt('catid'); $id = $this->input->getInt('id'); $mesid = $this->input->getInt('mesid'); if (!$mesid) { $this->topic = KunenaForumTopicHelper::get($id); $this->topic->tryAuthorise('move'); } else { $this->message = KunenaForumMessageHelper::get($mesid); $this->message->tryAuthorise('move'); $this->topic = $this->message->getTopic(); } $this->category = $this->topic->getCategory(); $this->uri = "index.php?option=com_kunena&view=topic&layout=moderate" . "&catid={$this->category->id}&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : ''); $this->title = !$this->message ? JText::_('COM_KUNENA_TITLE_MODERATE_TOPIC') : JText::_('COM_KUNENA_TITLE_MODERATE_MESSAGE'); // Load topic icons if available. if ($this->config->topicicons) { $this->template = KunenaTemplate::getInstance(); $this->template->setCategoryIconset(); $this->topicIcons = $this->template->getTopicIcons(false); } // Have a link to moderate user as well. if (isset($this->message)) { $user = $this->message->getAuthor(); if ($user->exists()) { $username = $user->getName(); $this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null; } } if ($this->message) { $this->banHistory = KunenaUserBan::getUserHistory($this->message->userid); $this->me = KunenaFactory::getUser(); // Get thread and reply count from current message: $db = JFactory::getDbo(); $query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->message->id)}"; $db->setQuery($query, 0, 1); $this->replies = $db->loadResult(); if (KunenaError::checkDatabaseError()) { return; } } $this->banInfo = KunenaUserBan::getInstanceByUserid(JFactory::getUser()->id, true); }
public static function getMessageUrl(KunenaForumMessage $message, $xhtml = true, KunenaForumTopic $topic = null, KunenaForumCategory $category = null) { // FIXME: not yet fully implemented... if (!$category) { $category = $message->getCategory(); } if (!$topic) { $topic = $message->getTopic(); } return KunenaRoute::_("index.php?option=com_kunena&view=topic&catid={$category->id}&id={$topic->id}", $xhtml); }