public function createParent($messageId = null) { $parent = new stdClass(); $parent->forceSecure = true; $parent->forceMinimal = false; if ($messageId) { $message = KunenaForumMessage::getInstance($messageId); $parent->attachments = $message->getAttachments(); } return $parent; }
/** * Prepare message actions display. * * @return void */ protected function before() { parent::before(); $mesid = $this->input->getInt('mesid'); $me = KunenaUserHelper::getMyself(); $this->message = KunenaForumMessage::getInstance($mesid); $this->topic = $this->message->getTopic(); $id = $this->message->thread; $catid = $this->message->catid; $token = JSession::getFormToken(); $task = "index.php?option=com_kunena&view=topic&task=%s&catid={$catid}&id={$id}&mesid={$mesid}&{$token}=1"; $layout = "index.php?option=com_kunena&view=topic&layout=%s&catid={$catid}&id={$id}&mesid={$mesid}"; $this->template = KunenaFactory::getTemplate(); $this->messageButtons = new JObject(); $this->message_closed = null; if ($this->message->isAuthorised('reply')) { if (version_compare(JVERSION, '3.4', '<') && $me->canDoCaptcha()) { $this->quickreply = false; } elseif (version_compare(JVERSION, '3.4', '>') && $me->canDoCaptcha()) { $this->quickreply = true; } else { $this->quickreply = true; } } else { $this->quickreply = false; } // Reply / Quote if ($this->message->isAuthorised('reply')) { $this->messageButtons->set('reply', $this->getButton(sprintf($layout, 'reply'), 'reply', 'message', 'communication', null, true)); if ($me->exists() && !KunenaSpamRecaptcha::getInstance()->enabled()) { $this->messageButtons->set('quickreply', $this->getButton(sprintf($layout, 'reply'), 'quickreply', 'message', 'communication', "kreply{$mesid}")); } $this->messageButtons->set('quote', $this->getButton(sprintf($layout, 'reply"e=1'), 'quote', 'message', 'communication')); } elseif (!$me->isModerator($this->topic->getCategory())) { // User is not allowed to write a post. $this->message_closed = $this->topic->locked ? JText::_('COM_KUNENA_POST_LOCK_SET') : ($me->exists() ? JText::_('COM_KUNENA_REPLY_USER_REPLY_DISABLED') : ' '); } $login = KunenaLogin::getInstance(); if (!$this->message->isAuthorised('reply') && !$this->message_closed && $login->enabled() || !$this->message->isAuthorised('reply') && !$this->topic->locked && $login->enabled() && !$me->userid) { $logintext = '<a class="btn-link" href="#klogin" rel="nofollow"> ' . JText::_('JLOGIN') . '</a>'; if ($login->getRegistrationUrl()) { $register = ' ' . JText::_('COM_KUNENA_LOGIN_OR') . ' <a class="btn-link" href="' . $login->getRegistrationUrl() . '">' . JText::_('COM_KUNENA_PROFILEBOX_CREATE_ACCOUNT') . '</a>'; } else { $register = ''; } echo '<p>' . JText::sprintf('COM_KUNENA_LOGIN_PLEASE', $logintext, $register) . '</p>'; } // Thank you. if (isset($this->message->thankyou)) { if ($this->message->isAuthorised('thankyou') && !array_key_exists($me->userid, $this->message->thankyou)) { $this->messageButtons->set('thankyou', $this->getButton(sprintf($task, 'thankyou'), 'thankyou', 'message', 'user', null, false)); } } // Unthank you if ($this->message->isAuthorised('unthankyou') && array_key_exists($me->userid, $this->message->thankyou)) { $this->messageButtons->set('unthankyou', $this->getButton(sprintf($task, 'unthankyou&userid=' . $me->userid), 'unthankyou', 'message', 'user', null, false)); } // Report this. if (KunenaFactory::getConfig()->reportmsg && $me->exists()) { $this->messageButtons->set('report', $this->getButton(sprintf($layout, 'report'), 'report', 'message', 'user')); } // Moderation and own post actions. if ($this->message->isAuthorised('edit')) { $this->messageButtons->set('edit', $this->getButton(sprintf($layout, 'edit'), 'edit', 'message', 'moderation')); } if ($this->message->isAuthorised('move')) { $this->messageButtons->set('moderate', $this->getButton(sprintf($layout, 'moderate'), 'moderate', 'message', 'moderation')); } if ($this->message->hold == 1) { if ($this->message->isAuthorised('approve')) { $this->messageButtons->set('publish', $this->getButton(sprintf($task, 'approve'), 'approve', 'message', 'moderation')); } if ($this->message->isAuthorised('delete')) { $this->messageButtons->set('delete', $this->getButton(sprintf($task, 'delete'), 'delete', 'message', 'moderation')); } } elseif ($this->message->hold == 2 || $this->message->hold == 3) { if ($this->message->isAuthorised('undelete')) { $this->messageButtons->set('undelete', $this->getButton(sprintf($task, 'undelete'), 'undelete', 'message', 'moderation')); } if ($this->message->isAuthorised('permdelete')) { $this->messageButtons->set('permdelete', $this->getButton(sprintf($task, 'permdelete'), 'permdelete', 'message', 'permanent')); } } elseif ($this->message->isAuthorised('delete')) { $this->messageButtons->set('delete', $this->getButton(sprintf($task, 'delete'), 'delete', 'message', 'moderation')); } JPluginHelper::importPlugin('kunena'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onKunenaGetButtons', array('message.action', $this->messageButtons, $this)); }
public function displayUnread($tpl = null) { // Redirect unread layout to the page that contains the first unread message $category = $this->get('Category'); $topic = $this->get('Topic'); KunenaForumTopicHelper::fetchNewStatus(array($topic->id => $topic)); $message = KunenaForumMessage::getInstance($topic->lastread ? $topic->lastread : $topic->last_post_id); while (@ob_end_clean()) { } $this->app->redirect($topic->getUrl($category, false, $message)); }
/** * Gets an URL to a post or a category * * @param int|null $forum Forum category * @param int|null $post Forum post * @return null|string URL */ public static function getForumURL($forum = null, $post = null) { if (!class_exists('KunenaForumTopic') || !class_exists('KunenaForumMessage')) { return null; } if ($post) { $url = KunenaForumTopic::getInstance((int) $post)->getUrl(); if (!$url) { $url = KunenaForumMessage::getInstance((int) $post)->getUrl(); } } else { $url = cbforumsModel::getCategory((int) $forum)->getUrl(); } return $url; }