/** * 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)); }
/** * 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; }
function shKUTopicName($topicid, $option, $shLangIso, $shLangName) { static $topics = array(); $sefConfig =& shRouter::shGetConfig(); if (empty($topicid) || !$sefConfig->shFbInsertMessageSubject) { return ''; } if (class_exists('KunenaForum')) { // Kunena 2.0 support $topic = KunenaForumTopic::getInstance($topicid); $topicsubject = $topic->subject; } elseif (class_exists('KunenaRouter')) { // Kunena 1.6 support if (empty(KunenaRouter::$msgidcache[$topicid])) { $database =& JFactory::getDBO(); $query = 'SELECT subject, id FROM #__kunena_messages WHERE id=' . (int) $topicid; $database->setQuery($query); KunenaRouter::$msgidcache[$topicid] = $database->loadResult(); } $topicsubject = KunenaRouter::$msgidcache[$topicid]; } else { // Kunena 1.0 / 1.5 support if (empty($topics[$topicid])) { $database =& JFactory::getDBO(); $query = 'SELECT id, subject FROM #__fb_messages WHERE id = ' . (int) $topicid; $database->setQuery($query); if (!shTranslateUrl($option, $shLangName)) { $topicDetails = $database->loadObject(false); } else { $topicDetails = $database->loadObject(); } $topics[$topicid] = empty($topicDetails) ? '' : $topicDetails->subject; } $topicsubject = $topics[$topicid]; } // we have a user name $topicstring = empty($topicsubject) ? 't' . $sefConfig->replacement . $topicid : ($sefConfig->shFbInsertMessageId ? $topicid . $sefConfig->replacement : ''); // if name, put ID only if requested $topicstring = $topicstring . (empty($topicsubject) ? '' : $topicsubject); return $topicstring; }
function shKUTopicName($topicid, $option, $shLangIso, $shLangName) { static $topics = array(); $sefConfig =& Sh404sefFactory::getConfig(); if (empty($topicid) || !$sefConfig->shFbInsertMessageSubject) { return ''; } if (class_exists('KunenaForum')) { // Kunena 2.0 support $topic = KunenaForumTopic::getInstance($topicid); $topicsubject = $topic->subject; } elseif (class_exists('KunenaRouter')) { // Kunena 1.6 support if (empty(KunenaRouter::$msgidcache[$topicid])) { try { KunenaRouter::$msgidcache[$topicid] = ShlDbHelper::selectResult('#__kunena_messages', array('subject', 'id'), array('id' => $topicid)); } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } } $topicsubject = KunenaRouter::$msgidcache[$topicid]; } else { // Kunena 1.0 / 1.5 support if (empty($topics[$topicid])) { try { $topicDetails = ShlDbHelper::selectObject('#__fb_messages', array('id', 'subject'), array('id' => $topicid)); } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } $topics[$topicid] = empty($topicDetails) ? '' : $topicDetails->subject; } $topicsubject = $topics[$topicid]; } // we have a user name $topicstring = empty($topicsubject) ? 't' . $sefConfig->replacement . $topicid : ($sefConfig->shFbInsertMessageId ? $topicid . $sefConfig->replacement : ''); // if name, put ID only if requested $topicstring = $topicstring . (empty($topicsubject) ? '' : $topicsubject); return $topicstring; }