function displayDefault($tpl = null) { $this->config = KunenaFactory::getConfig(); if (!$this->config->enablerss) { JError::raiseError ( 404, JText::_ ( 'COM_KUNENA_RSS_DISABLED' ) ); } $this->assignRef ( 'category', $this->get ( 'Category' ) ); if (! $this->category->authorise('read')) { JError::raiseError ( 404, $this->category->getError() ); } $this->template = KunenaTemplate::getInstance(); $this->assignRef ( 'topics', $this->get ( 'Topics' ) ); $title = JText::_('COM_KUNENA_THREADS_IN_FORUM').': '. $this->category->name; $this->setTitle ( $title ); $metaDesc = $this->document->get ( 'description' ) . '. ' . $this->escape ( "{$this->category->name} - {$this->config->board_title}" ); $this->document->setDescription ( $metaDesc ); // Create image for feed $image = new JFeedImage(); $image->title = $this->document->getTitle(); $image->url = $this->template->getImagePath('icons/rss.png'); $image->description = $this->document->getDescription(); $this->document->image = $image; foreach ( $this->topics as $topic ) { $id = $topic->last_post_id; $page = ceil ( $topic->posts / $this->config->messages_per_page ); $description = $topic->last_post_message; $date = new JDate($topic->last_post_time); $userid = $topic->last_post_userid; $username = KunenaFactory::getUser($userid)->getName($topic->last_post_guest_name); $title = $topic->subject; $url = CKunenaLink::GetThreadPageURL('view', $topic->category_id, $topic->id, $page, $this->config->messages_per_page, $id, true ); $category = $topic->getCategory()->name; $this->createItem($title, $url, $description, $category, $date, $userid, $username); } }
public function onAfterThankyou($thankyoutargetid, $username , $message) { CFactory::load ( 'libraries', 'userpoints' ); CUserPoints::assignPoint ( 'com_kunena.thread.thankyou', $thankyoutargetid ); // Check for permisions of the current category - activity only if public or registered if ($message->getCategory()->pub_access <= 0) { //activity stream - reply post require_once KPATH_SITE.'/lib/kunena.link.class.php'; $JSPostLink = CKunenaLink::GetThreadPageURL ( 'view', $message->catid, $message->thread, 0 ); $act = new stdClass (); $act->cmd = 'wall.write'; $act->actor = JFactory::getUser()->id; $act->target = $thankyoutargetid; $act->title = JText::_ ( '{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_( 'COM_KUNENA_JS_ACTIVITYSTREAM_THANKYOU' ).' <a href="' . $JSPostLink . '">' . $message->subject . '</a> ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG2' ) ); $act->content = NULL; $act->app = 'kunena.thankyou'; $act->cid = $message->id; // jomsocial 0 = public, 20 = registered members if ($message->getCategory()->pub_access == 0) { $act->access = 0; } else { $act->access = 20; } CFactory::load ( 'libraries', 'activities' ); CActivityStream::add ( $act ); } }
unset($rt[$key]); $readtopics = implode(",", $rt); $kunena_db->setQuery("UPDATE #__fb_sessions SET readtopics='{$readtopics}' WHERE userid={$userid}"); $kunena_db->query(); check_dberror("Unable to update sessions."); } } unset($result); $kunena_db->setQuery("SELECT COUNT(*) AS totalmessages FROM #__fb_messages WHERE thread='{$querythread}'"); $result = $kunena_db->loadObject(); check_dberror("Unable to load messages."); $threadPages = ceil($result->totalmessages / $fbConfig->messages_per_page); //construct a useable URL (for plaintext - so no & encoding!) jimport('joomla.environment.uri'); $uri =& JURI::getInstance(JURI::base()); $LastPostUrl = $uri->toString(array('scheme', 'host', 'port')) . str_replace('&', '&', CKunenaLink::GetThreadPageURL($fbConfig, 'view', $catid, $querythread, $threadPages, $fbConfig->messages_per_page, $pid)); //Now manage the subscriptions (only if subscriptions are allowed) if ($fbConfig->allowsubscriptions == 1 && $holdPost == 0) { //they're allowed //get the proper user credentials for each subscription to this topic //clean up the message $mailmessage = smile::purify($message); $kunena_db->setQuery("SELECT * FROM #__fb_subscriptions AS a" . " LEFT JOIN #__users AS u ON a.userid=u.id " . " WHERE u.block='0' AND a.thread='{$querythread}'"); $subsList = $kunena_db->loadObjectList(); check_dberror("Unable to load subscriptions."); if (count($subsList) > 0) { //we got more than 0 subscriptions require_once KUNENA_PATH_LIB . DS . 'kunena.mail.php'; // include fbMail class for mailing $_catobj = new jbCategory($kunena_db, $catid); foreach ($subsList as $subs) {
/** * Pulls together data and options and outputs the build feed. * Header and mime is automaticly set. * * @access private * @param array $items */ private function buildFeed($items = array()) { // Build items for feed foreach ($items as $data) { $item = new JFeedItem(); // Calcution to define the last page of the topic $threadPages = ceil($data->msgcount / $this->config->messages_per_page); // Build unique direct linking url for each item (htmlspecialchars_decode because FeedCreator uses htmlspecialchars on input) $url = CKunenaLink::GetThreadPageURL('view', $data->catid, $data->thread, $threadPages, $this->config->messages_per_page, $data->id); // Extract the data, we want to present and store it in $tmp $tmp = array(); $tmp['title'] = $data->subject; // Remove confidential information from message $data->message = preg_replace('/\\[confidential\\](.*?)\\[\\/confidential\\]/s', '', $data->message); $data->message = preg_replace('/\\[hide\\](.*?)\\[\\/hide\\]/s', '', $data->message); $data->message = preg_replace('/\\[spoiler\\]/s', '[spoilerlight]', $data->message); $data->message = preg_replace('/\\[\\/spoiler\\]/s', '[/spoilerlight]', $data->message); $data->message = preg_replace('/\\[code\\](.*?)\\[\\/code]/s', '', $data->message); $tmp['text'] = $data->message; $tmp['date'] = $data->time; $tmp['email'] = $data->email; $tmp['name'] = $data->name; $tmp['cat_name'] = $data->catname; // Link and source is always the same $tmp['link'] = $this->uri->toString(array('scheme', 'host', 'port')) . $url; $tmp['source'] = $this->uri->toString(array('scheme', 'host', 'port')) . $url; // Determine title format if ($this->old_titles) { $tmp['title'] = JText::_('COM_KUNENA_GEN_SUBJECT') . ': ' . $tmp['title']; } // Determine author format switch ($this->author_format) { case 'both': $tmp['author'] = $tmp['email'] . ' (' . $tmp['name'] . ')'; break; case 'email': $tmp['author'] = $tmp['email']; break; case 'name': default: $tmp['author'] = $tmp['name']; } // Do we want author in item titles? if ($this->author_in_title) { $tmp['title'] .= ' - ' . JText::_('COM_KUNENA_GEN_BY') . ': ' . $tmp['name']; } // Limit number of words if ($this->word_count) { $Newmessage = ''; $t_newString = explode(" ", $tmp['text']); foreach ($t_newString as $key => $word) { if ($key < $this->word_count) { $Newmessage .= $word . ' '; } } // Append userfriendly '...' string if (strlen($tmp['text']) != strlen($Newmessage)) { $Newmessage .= ' ...'; } $tmp['text'] = $Newmessage; } if ($this->allow_html) { // Not nessecary to convert specialchars or use parsetext. // ParseBBCode does it for us $tmp['text'] = KunenaParser::parseBBCode($tmp['text']); } else { // Not nessecary to convert specialchars. // FeedCreator does it for us $tmp['text'] = KunenaParser::parseText($tmp['text']); } // Assign values to feed item $item->title = $tmp['title']; $item->link = $tmp['link']; $item->description = $tmp['text']; $item->date = $tmp['date']; $item->source = $tmp['source']; $item->author = $tmp['author']; $item->category = $tmp['cat_name']; // Finally add item to feed $this->document->addItem($item); } }
protected function _sendReportToMail($message, $subject, $emailToList) { jimport('joomla.mail.helper'); $sender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_GEN_FORUM') . ': ' . $this->_getSenderName()); $subject = JMailHelper::cleanSubject($subject); $message = JMailHelper::cleanBody($message); foreach ($emailToList as $emailTo) { if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) { continue; } JUtility::sendMail($this->config->email, $sender, $emailTo->email, $subject, $message); } $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS')); while (@ob_end_clean()) { } $this->app->redirect(CKunenaLink::GetThreadPageURL('view', $this->catid, $this->id, NULL, NULL, $this->id, false)); }
if (count($this_message) < 1) { echo '<p align="center">' . _MODERATION_INVALID_ID . '</p>'; } else { $thread = $this_message->parent == 0 ? $this_message->id : $this_message->thread; // Test if this is a valid SEO URL if not we should redirect using a 301 - permanent redirect if ($thread != $this_message->id || $catid != $this_message->catid) { // Invalid SEO URL detected! // Create permanent re-direct and quit // This query to calculate the page this reply is sitting on within this thread $query = "SELECT COUNT(*) FROM #__fb_messages AS a WHERE a.thread='{$thread}' AND hold='0' AND a.id<='{$id}'"; $kunena_db->setQuery($query); $replyCount = $kunena_db->loadResult(); check_dberror('Unable to calculate location of current message.'); $replyPage = $replyCount > $fbConfig->messages_per_page ? ceil($replyCount / $fbConfig->messages_per_page) : 1; header("HTTP/1.1 301 Moved Permanently"); header("Location: " . htmlspecialchars_decode(CKunenaLink::GetThreadPageURL($fbConfig, 'view', $this_message->catid, $thread, $replyPage, $fbConfig->messages_per_page, $this_message->id))); $app->close(); } if ($kunena_my->id) { //mark this topic as read $kunena_db->setQuery("SELECT readtopics FROM #__fb_sessions WHERE userid='{$kunena_my->id}'"); $readTopics = $kunena_db->loadResult(); if ($readTopics == "") { $readTopics = $thread; } else { //get all readTopics in an array $_read_topics = @explode(',', $readTopics); if (!@in_array($thread, $_read_topics)) { $readTopics .= "," . $thread; } }
protected function approve() { if ($this->tokenProtection('get')) { return false; } if (!$this->load()) { return false; } if ($this->moderatorProtection()) { return false; } if ($this->isUserBanned()) { return false; } if ($this->isIPBanned()) { return false; } require_once KUNENA_PATH_LIB . '/kunena.posting.class.php'; $message = new CKunenaPosting(); $message->action($this->id); if ($message->canApprove()) { $success_msg = JText::_('COM_KUNENA_MODERATE_1APPROVE_FAIL'); $this->_db->setQuery("UPDATE #__kunena_messages SET hold=0 WHERE id={$this->_db->Quote($this->id)}"); if ($this->id && $this->_db->query() && $this->_db->getAffectedRows() == 1) { $success_msg = JText::_('COM_KUNENA_MODERATE_APPROVE_SUCCESS'); $this->_db->setQuery("SELECT COUNT(*) AS totalmessages FROM #__kunena_messages WHERE thread={$this->_db->Quote($this->msg_cat->thread)}"); $result = $this->_db->loadObject(); KunenaError::checkDatabaseError(); $threadPages = ceil($result->totalmessages / $this->config->messages_per_page); //construct a useable URL (for plaintext - so no & encoding!) jimport('joomla.environment.uri'); $uri =& JURI::getInstance(JURI::base()); $LastPostUrl = $uri->toString(array('scheme', 'host', 'port')) . str_replace('&', '&', CKunenaLink::GetThreadPageURL('view', $this->catid, $this->msg_cat->thread, $threadPages, $this->config->messages_per_page, $this->id)); $message->emailToSubscribers($LastPostUrl, $this->config->allowsubscriptions, $this->config->mailmod, $this->config->mailadmin); CKunenaTools::modifyCategoryStats($this->id, $this->msg_cat->parent, $this->msg_cat->time, $this->msg_cat->catid); } } while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->id, $this->catid, 0, false), $success_msg); }
function displayPostRows() { require_once KPATH_SITE.'/lib/kunena.link.class.php'; foreach ( $this->messages as $message ) { if (!isset($this->topics[$message->thread])) { // TODO: INTERNAL ERROR return; } $topic = $this->topics[$message->thread]; $title = $message->subject; // TODO: link must point into right page $url = CKunenaLink::GetThreadPageURL('view', $message->catid, $message->thread, 0, $this->config->messages_per_page, 0, true ); $description = $message->message; $category = $topic->getCategory()->name; $date = new JDate($message->time); $userid = $message->userid; $username = KunenaFactory::getUser($userid)->getName($message->name); $this->createItem($title, $url, $description, $category, $date, $userid, $username); } }
public function polldo() { $vote = JRequest::getInt('kpollradio', ''); $id = JRequest::getInt('kpoll-id', 0); $catid = JRequest::getInt('catid', 0); switch ($this->do) { case 'vote': case 'pollvote': $result = $this->save_results($id, $this->my->id, $vote); if ($result['results'] == '1') { $message = JText::_('COM_KUNENA_POLL_SAVE_ALERT_OK'); } elseif ($result['results'] == '2') { $message = JText::_('COM_KUNENA_POLL_SAVE_VOTE_ALREADY'); } elseif ($result['results'] == '3') { $message = JText::_('COM_KUNENA_POLL_WAIT_BEFORE_VOTE'); } elseif ($result['results'] == '4') { $message = JText::_('COM_KUNENA_POLL_SAVE_ALERT_ERROR_NOT_CHECK'); } elseif ($result['results'] == '5') { $message = JText::sprintf('COM_KUNENA_POLL_MAXIMUM_VOTES_ALLOWED_REACH', $result['user_votes']); } $this->_app->enqueueMessage($message); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetThreadPageURL('view', $catid, $id, 1, $this->config->messages_per_page, '', false)); break; case 'pollchangevote': $result = $this->save_changevote($id, $this->my->id, $vote); if ($result['results'] == 1) { $message = JText::_('COM_KUNENA_POLL_SAVE_ALERT_OK'); } elseif ($result['results'] == 3) { $message = JText::_('COM_KUNENA_POLL_WAIT_BEFORE_VOTE'); } $this->_app->enqueueMessage($message); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetThreadPageURL('view', $catid, $id, 1, $this->config->messages_per_page, '', false)); break; } }
public function onAfterThankyou($thankyoutargetid, $username, $message) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_kunena.thread.thankyou', $thankyoutargetid); if (!empty($message->parent)) { //activity stream - reply post require_once KPATH_SITE . '/lib/kunena.link.class.php'; $JSPostLink = CKunenaLink::GetThreadPageURL('view', $message->get('catid'), $message->get('thread'), 1); $act = new stdClass(); $act->cmd = 'wall.write'; $act->actor = JFactory::getUser()->id; $act->target = $thankyoutargetid; $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_('COM_KUNENA_JS_ACTIVITYSTREAM_THANKYOU') . ' <a href="' . $JSPostLink . '">' . $message->get('subject') . '</a> '); $act->content = NULL; $act->app = 'kunena.thankyou'; $act->cid = $thankyoutargetid; $act->access = $this->getAccess($message); CFactory::load('libraries', 'activities'); CActivityStream::add($act); } }
function getView() { // Is user allowed to read category from the URL? if ($this->catid && !$this->session->canRead($this->catid)) { return; } $this->allow = 1; $where[] = "a.hold IN ({$this->hold})"; $where = implode(' AND ', $where); $query = "SELECT a.*, b.*, p.id AS poll_id, modified.name AS modified_name, modified.username AS modified_username\n\t\t\tFROM #__kunena_messages AS a\n\t\t\tLEFT JOIN #__kunena_messages_text AS b ON a.id=b.mesid\n\t\t\tLEFT JOIN #__users AS modified ON a.modified_by = modified.id\n\t\t\tLEFT JOIN #__kunena_polls AS p ON a.id=p.threadid\n\t\t\tWHERE a.id={$this->db->Quote($this->id)} AND {$where}"; $this->db->setQuery($query); $this->first_message = $this->db->loadObject(); // Invalid message id (deleted, on hold?) if (KunenaError::checkDatabaseError() || !$this->first_message) { return; } // Is user allowed to see the forum specified in the message? if (!$this->session->canRead($this->first_message->catid)) { $this->allow = 0; return; } $this->thread = $this->first_message->thread; // Test if this is a valid URL. If not, redirect browser to the right location if ($this->first_message->moved || $this->thread != $this->id || $this->catid != $this->first_message->catid) { $this->catid = $this->first_message->catid; if ($this->first_message->moved) { $newurl = array(); parse_str($this->first_message->message, $newloc); $this->id = $newloc['id']; $query = "SELECT catid, thread FROM #__kunena_messages AS a WHERE a.id='{$this->id}'"; $this->db->setQuery($query); $newpos = $this->db->loadObject(); if (!$newpos) { $this->allow = 0; return; } if (KunenaError::checkDatabaseError()) { return; } $this->thread = $newpos->thread; $this->catid = $newpos->catid; } // This query to calculate the page this reply is sitting on within this thread $query = "SELECT COUNT(*) FROM #__kunena_messages AS a WHERE a.thread={$this->db->Quote($this->thread)} AND {$where} AND a.id<={$this->db->Quote($this->id)}"; $this->db->setQuery($query); $replyCount = $this->db->loadResult(); if (KunenaError::checkDatabaseError()) { return; } $replyPage = $replyCount > $this->config->messages_per_page ? ceil($replyCount / $this->config->messages_per_page) : 1; $this->redirect = CKunenaLink::GetThreadPageURL('view', $this->catid, $this->thread, $replyPage, $this->config->messages_per_page, $this->first_message->id, false); } //Get the category name for breadcrumb $this->db->setQuery("SELECT * FROM #__kunena_categories WHERE id={$this->db->Quote($this->catid)}"); $this->catinfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } //Get Parent's cat.name for breadcrumb $this->db->setQuery("SELECT id, name FROM #__kunena_categories WHERE id={$this->db->Quote($this->catinfo->parent)}"); $objCatParentInfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } // START $this->emoticons = smile::getEmoticons(0); $this->prevCheck = $this->session->lasttime; $this->read_topics = explode(',', $this->session->readtopics); $showedEdit = 0; $this->kunena_forum_locked = $this->catinfo->locked; //check if topic is locked $this->topicLocked = $this->first_message->locked; if (!$this->topicLocked) { //topic not locked; check if forum is locked $this->topicLocked = $this->catinfo->locked; } $this->topicSticky = $this->first_message->ordering; CKunenaTools::markTopicRead($this->thread, $this->my->id); //update the hits counter for this topic & exclude the owner if ($this->my->id == 0 || $this->first_message->userid != $this->my->id) { $this->db->setQuery("UPDATE #__kunena_messages SET hits=hits+1 WHERE id={$this->db->Quote($this->thread)} AND parent='0'"); $this->db->query(); KunenaError::checkDatabaseError(); } $query = "SELECT COUNT(*) FROM #__kunena_messages AS a WHERE a.thread={$this->db->Quote($this->thread)} AND {$where}"; $this->db->setQuery($query); $this->total_messages = $this->db->loadResult(); KunenaError::checkDatabaseError(); // If page does not exist, redirect to the last page if ($this->total_messages <= $this->limitstart) { $page = ceil($this->total_messages / $this->limit); $this->redirect = CKunenaLink::GetThreadPageURL('view', $this->catid, $this->id, $page, $this->limit, '', false); } $maxpages = 7 - 2; // odd number here (show - 2) $totalpages = ceil($this->total_messages / $this->limit); $page = floor($this->limitstart / $this->limit) + 1; $firstpage = 1; if ($this->ordering == 'desc') { $firstpage = $totalpages; } // Get replies of current thread $query = "SELECT a.*, b.*, modified.name AS modified_name, modified.username AS modified_username\n\t\t\t\t\tFROM #__kunena_messages AS a\n\t\t\t\t\tLEFT JOIN #__kunena_messages_text AS b ON a.id=b.mesid\n\t\t\t\t\tLEFT JOIN #__users AS modified ON a.modified_by = modified.id\n\t\t\t\t\tWHERE a.thread={$this->db->Quote($this->thread)} AND {$where}\n\t\t\t\t\tORDER BY id {$this->ordering}"; $this->db->setQuery($query, $this->limitstart, $this->limit); $this->messages = (array) $this->db->loadObjectList('id'); KunenaError::checkDatabaseError(); // First collect the message ids of the first message and all replies $messageids = array(); $this->threaded = array(); $userlist = array(); foreach ($this->messages as $message) { $messageids[] = $message->id; // Threaded ordering if (isset($this->messages[$message->parent])) { $this->threaded[$message->parent][] = $message->id; } else { $this->threaded[0][] = $message->id; } $userlist[intval($message->userid)] = intval($message->userid); $userlist[intval($message->modified_by)] = intval($message->modified_by); } if (!isset($this->messages[$this->mesid])) { $this->mesid = reset($messageids); } if ($this->layout != 'view') { if (!isset($this->messages[$this->id])) { $this->messages = $this->getThreadedOrdering(0, array('edge')); } else { $this->messages = $this->getThreadedOrdering(); } } // create a list of ids we can use for our sql $idstr = @join(",", $messageids); // Load attachments require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php'; $attachments = CKunenaAttachments::getInstance(); if (is_a($attachments, 'CKunenaAttachments')) { $message_attachments = $attachments->get($idstr); // Now that we have all relevant messages in messages, asign any matching attachments foreach ($this->messages as $message) { // Mark as new if ($this->my->id && $this->prevCheck < $message->time && !in_array($message->thread, $this->read_topics)) { $message->new = true; } else { $message->new = false; } // Assign attachments if (isset($message_attachments[$message->id])) { $message->attachments = $message_attachments[$message->id]; } } // Done with attachments } $this->pagination = $this->getPagination($this->catid, $this->thread, $page, $totalpages, $maxpages); //meta description and keywords $metaKeys = kunena_htmlspecialchars("{$this->first_message->subject}, {$objCatParentInfo->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . $this->app->getCfg('sitename')); // Create Meta Description form the content of the first message // better for search results display but NOT for search ranking! $metaDesc = KunenaParser::stripBBCode($this->first_message->message); $metaDesc = strip_tags($metaDesc); // Now remove all tags $metaDesc = preg_replace('/\\s+/', ' ', $metaDesc); // remove newlines $metaDesc = preg_replace('/^[^\\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers $metaDesc = trim($metaDesc); // Remove trailing spaces and beginning // remove multiple spaces while (strpos($metaDesc, ' ') !== false) { $metaDesc = str_replace(' ', ' ', $metaDesc); } // limit to 185 characters - google will cut off at ~150 if (strlen($metaDesc) > 185) { $metaDesc = rtrim(JString::substr($metaDesc, 0, 182)) . '...'; } $metaDesc = htmlspecialchars($metaDesc); $document =& JFactory::getDocument(); $document->setMetadata('keywords', $metaKeys); $document->setDescription($metaDesc); $this->layout_buttons = array(); if ($this->config->enable_threaded_layouts) { if ($this->layout != 'view') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('flat', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-flat', JText::_('COM_KUNENA_BUTTON_LAYOUT_FLAT')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_FLAT_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } if ($this->layout != 'threaded') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('threaded', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-threaded', JText::_('COM_KUNENA_BUTTON_LAYOUT_THREADED')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_THREADED_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } if ($this->layout != 'indented') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('indented', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-indented', JText::_('COM_KUNENA_BUTTON_LAYOUT_INDENTED')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_INDENTED_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } } //Perform subscriptions check only once $this->cansubscribe = 0; if ($this->config->allowsubscriptions && $this->config->topic_subscriptions != 'disabled' && $this->my->id) { $this->db->setQuery("SELECT thread, future1 FROM #__kunena_subscriptions WHERE userid={$this->db->Quote($this->my->id)} AND thread={$this->db->Quote($this->thread)}"); $fb_subscribed = $this->db->loadObject(); KunenaError::checkDatabaseError(); if (!$fb_subscribed) { $this->cansubscribe = 1; } elseif ($fb_subscribed->future1 == 1) { $query_thread = "UPDATE #__kunena_subscriptions\n\t\t\t\t\tSET future1=0 WHERE thread={$this->db->Quote($this->thread)} AND userid={$this->db->Quote($this->my->id)}"; $this->db->setQuery($query_thread); $this->db->query(); } } //Perform favorites check only once $fb_canfavorite = 0; $this->db->setQuery("SELECT MAX(userid={$this->db->Quote($this->my->id)}) AS favorited, COUNT(*) AS totalfavorited FROM #__kunena_favorites WHERE thread={$this->db->Quote($this->thread)}"); list($this->favorited, $this->totalfavorited) = $this->db->loadRow(); KunenaError::checkDatabaseError(); if ($this->config->allowfavorites && $this->my->id) { if (!$this->favorited) { $fb_canfavorite = 1; } } //get the Moderator list for display $this->db->setQuery("SELECT m.*, u.* FROM #__kunena_moderation AS m INNER JOIN #__users AS u ON u.id=m.userid WHERE m.catid={$this->db->Quote($this->catid)} AND u.block=0"); $this->modslist = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); $this->catModerators = array(); foreach ($this->modslist as $mod) { $this->catModerators[] = $mod->userid; $userlist[intval($mod->userid)] = intval($mod->userid); } // Prefetch all users/avatars to avoid user by user queries during template iterations KunenaUser::loadUsers($userlist); //data ready display now if (CKunenaTools::isModerator($this->my->id, $this->catid) || $this->topicLocked == 0) { //this user is allowed to reply to this topic $this->thread_reply = CKunenaLink::GetTopicPostReplyLink('reply', $this->catid, $this->thread, CKunenaTools::showButton('reply', JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC_LONG')); } // Thread Subscription if ($this->cansubscribe == 1) { // this user is allowed to subscribe - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_subscribe = CKunenaLink::GetTopicPostLink('subscribe', $this->catid, $this->id, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_TOPIC_LONG')); } if ($this->my->id != 0 && $this->config->allowsubscriptions && $this->config->topic_subscriptions != 'disabled' && $this->cansubscribe == 0) { // this user is allowed to unsubscribe $this->thread_subscribe = CKunenaLink::GetTopicPostLink('unsubscribe', $this->catid, $this->id, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_TOPIC_LONG')); } //START: FAVORITES if ($fb_canfavorite == 1) { // this user is allowed to add a favorite - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_favorite = CKunenaLink::GetTopicPostLink('favorite', $this->catid, $this->id, CKunenaTools::showButton('favorite', JText::_('COM_KUNENA_BUTTON_FAVORITE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_FAVORITE_TOPIC_LONG')); } if ($this->my->id != 0 && $this->config->allowfavorites && $fb_canfavorite == 0) { // this user is allowed to unfavorite $this->thread_favorite = CKunenaLink::GetTopicPostLink('unfavorite', $this->catid, $this->id, CKunenaTools::showButton('favorite', JText::_('COM_KUNENA_BUTTON_UNFAVORITE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNFAVORITE_TOPIC_LONG')); } // FINISH: FAVORITES if (CKunenaTools::isModerator($this->my->id, $this->catid) || !$this->kunena_forum_locked) { //this user is allowed to post a new topic $this->thread_new = CKunenaLink::GetPostNewTopicLink($this->catid, CKunenaTools::showButton('newtopic', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC_LONG')); } if (CKunenaTools::isModerator($this->my->id, $this->catid)) { // offer the moderator always the move link to relocate a topic to another forum // and the (un)sticky bit links // and the (un)lock links if ($this->topicSticky == 0) { $this->thread_sticky = CKunenaLink::GetTopicPostLink('sticky', $this->catid, $this->id, CKunenaTools::showButton('sticky', JText::_('COM_KUNENA_BUTTON_STICKY_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_STICKY_TOPIC_LONG')); } else { $this->thread_sticky = CKunenaLink::GetTopicPostLink('unsticky', $this->catid, $this->id, CKunenaTools::showButton('sticky', JText::_('COM_KUNENA_BUTTON_UNSTICKY_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNSTICKY_TOPIC_LONG')); } if ($this->topicLocked == 0) { $this->thread_lock = CKunenaLink::GetTopicPostLink('lock', $this->catid, $this->id, CKunenaTools::showButton('lock', JText::_('COM_KUNENA_BUTTON_LOCK_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_LOCK_TOPIC_LONG')); } else { $this->thread_lock = CKunenaLink::GetTopicPostLink('unlock', $this->catid, $this->id, CKunenaTools::showButton('lock', JText::_('COM_KUNENA_BUTTON_UNLOCK_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNLOCK_TOPIC_LONG')); } $this->thread_delete = CKunenaLink::GetTopicPostLink('deletethread', $this->catid, $this->id, CKunenaTools::showButton('delete', JText::_('COM_KUNENA_BUTTON_DELETE_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_DELETE_TOPIC_LONG')); $this->thread_moderate = CKunenaLink::GetTopicPostReplyLink('moderatethread', $this->catid, $this->id, CKunenaTools::showButton('moderate', JText::_('COM_KUNENA_BUTTON_MODERATE_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_MODERATE')); } $this->headerdesc = nl2br(smile::smileReplace($this->catinfo->headerdesc, 0, $this->config->disemoticons, $this->emoticons)); $tabclass = array("row1", "row2"); $this->mmm = 0; $this->replydir = $this->ordering == 'DESC' ? -1 : 1; if ($this->replydir < 0) { $this->replynum = $this->total_messages - $this->limitstart + 1; } else { $this->replynum = $this->limitstart; } $this->myname = $this->config->username ? $this->my->username : $this->my->name; $this->allow_anonymous = !empty($this->catinfo->allow_anonymous) && $this->my->id; $this->anonymous = $this->allow_anonymous && !empty($this->catinfo->post_anonymous); }
function GetLatestPageAutoRedirectURL($fbConfig, $pid, $limit, $catid = 0) { $kunena_db =& JFactory::getDBO(); // First determine the thread, latest post and number of posts for the post supplied $where = ''; if ($catid > 0) { $where .= " AND a.catid = {$catid} "; } $kunena_db->setQuery("SELECT a.thread AS thread, MAX(a.id) AS latest_id, MAX(a.catid) AS catid, COUNT(*) AS totalmessages\n FROM #__fb_messages AS a,\n (SELECT MAX(thread) AS thread FROM #__fb_messages WHERE id='{$pid}') AS b\n WHERE a.thread = b.thread AND a.hold='0' {$where}\n GROUP BY a.thread"); $result = $kunena_db->loadObject(); check_dberror("Unable to retrieve latest post."); if (!is_object($result)) { return htmlspecialchars_decode(JRoute::_(KUNENA_LIVEURLREL . '&func=showcat&catid=' . $catid)); } // Now Calculate the number of pages for this particular thread $catid = $result->catid; $threadPages = ceil($result->totalmessages / $limit); // Finally build output block return htmlspecialchars_decode(CKunenaLink::GetThreadPageURL($fbConfig, 'view', $catid, $result->thread, $threadPages, $limit)); }
<image> <url><?php echo KUNENA_URLEMOTIONSPATH; ?> rss.gif</url> <title>Powered by Kunena</title> <link><?php echo JURI::root(); ?> </link> <description>Kunena Site Syndication</description> </image> <?php foreach ($rows as $row) { echo " <item>\n"; echo " <title>" . _GEN_SUBJECT . ": " . stripslashes(kunena_htmlspecialchars($row->subject)) . " - " . _GEN_BY . ": " . stripslashes(kunena_htmlspecialchars($row->lastpostname)) . "</title>" . "\n"; echo " <link>"; $uri =& JURI::getInstance(JURI::base()); $itemlink = $uri->toString(array('scheme', 'host', 'port')) . CKunenaLink::GetThreadPageURL($fbConfig, 'view', $row->catid, $row->thread, ceil($row->numberposts / $fbConfig->messages_per_page), $fbConfig->messages_per_page, $row->lastpostid); echo $itemlink; echo "</link>\n"; $words = $row->lastpostmessage; $words = smile::purify($words); echo " <description>" . kunena_htmlspecialchars($words) . "</description>" . "\n"; echo " <pubDate>" . date('r', $row->lastposttime) . "</pubDate>" . "\n"; echo " </item>\n"; } ?> </channel> </rss>
function GetAutoRedirectThreadPageHTML($func, $catid, $threadid, $page, $limit = '', $anker = '', $timeout) { $p_url = CKunenaLink::GetThreadPageURL($func, $catid, $threadid, $page, $limit, $anker); return CKunenaLink::GetAutoRedirectHTML($p_url, $timeout); }
function displayDefault($tpl = null) { $this->me = KunenaFactory::getUser(); $this->layout = $this->state->get('layout'); if ($this->layout == 'flat') $this->layout = 'default'; $this->setLayout($this->layout); $this->assignRef ( 'category', $this->get ( 'Category' ) ); $this->assignRef ( 'topic', $this->get ( 'Topic' ) ); $channels = $this->category->getChannels(); if ($this->category->id && ! $this->category->authorise('read')) { // User is not allowed to see the category $this->setError($this->category->getError()); } elseif (! $this->topic) { // Moved topic loop detected (1 -> 2 -> 3 -> 2) $this->setError(JText::_('COM_KUNENA_VIEW_TOPIC_ERROR_LOOP')); } elseif (! $this->topic->authorise('read')) { // User is not allowed to see the topic $this->setError($this->topic->getError()); } elseif ($this->state->get('item.id') != $this->topic->id || ($this->category->id != $this->topic->category_id && !isset($channels[$this->topic->category_id]))) { // Topic has been moved or it doesn't belong to the current category $db = JFactory::getDBO(); $query = "SELECT COUNT(*) FROM #__kunena_messages WHERE thread={$db->Quote($this->topic->id)} AND hold IN ({$this->state->get('hold')}) AND id<={$db->Quote($this->state->get('item.id'))}"; $db->setQuery ( $query ); $replyCount = $db->loadResult (); if (KunenaError::checkDatabaseError()) return; $app = JFactory::getApplication(); $app->redirect(CKunenaLink::GetThreadPageURL ( 'view', $this->topic->category_id, $this->topic->id, $replyCount, $this->state->get('list.limit'), $this->state->get('item.id'), false )); } $errors = $this->getErrors(); if ($errors) { return $this->displayNoAccess($errors); } $this->assignRef ( 'messages', $this->get ( 'Messages' ) ); $this->assignRef ( 'total', $this->get ( 'Total' ) ); // If page does not exist, redirect to the last page /* if ($this->total <= $this->state->get('list.start')) { $app = JFactory::getApplication(); $app->redirect(CKunenaLink::GetThreadPageURL('view', $this->topic->category_id, $this->topic->id, $this->total, $this->state->get('list.start'), '', false)); } */ $this->assignRef ( 'moderators', $this->get ( 'Moderators' ) ); $this->assignRef ( 'usertopic',$this->topic->getUserTopic()); $this->headerText = JText::_('COM_KUNENA_MENU_LATEST_DESC'); $this->title = JText::_('COM_KUNENA_ALL_DISCUSSIONS'); $this->pagination = $this->getPagination ( 5 ); $this->me = KunenaFactory::getUser(); $this->config = KunenaFactory::getConfig(); // Mark topic read $this->topic->markRead (); $this->topic->hits++; $this->topic->save(); // Check is subscriptions were sent and reset the value if ($this->topic->authorise('subscribe')) { $usertopic = $this->topic->getUserTopic(); if ($usertopic->subscribed == 2) { $usertopic->subscribed = 1; $usertopic->save(); } } $this->keywords = $this->topic->getKeywords(false, ', '); $this->buttons(); //meta description and keywords // TODO: use real keywords, too $metaKeys = $this->escape ( "{$this->topic->subject}, {$this->category->getParent()->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . JFactory::getapplication()->getCfg ( 'sitename' ) ); // Create Meta Description form the content of the first message // better for search results display but NOT for search ranking! $metaDesc = KunenaHtmlParser::stripBBCode($this->topic->first_post_message); $metaDesc = preg_replace('/\s+/', ' ', $metaDesc); // remove newlines $metaDesc = preg_replace('/^[^\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers $metaDesc = trim($metaDesc); // Remove trailing spaces and beginning // remove multiple spaces while (strpos($metaDesc, ' ') !== false){ $metaDesc = str_replace(' ', ' ', $metaDesc); } // limit to 185 characters - google will cut off at ~150 if (strlen($metaDesc) > 185){ $metaDesc = rtrim(JString::substr($metaDesc, 0, 182)).'...'; } $this->document->setMetadata ( 'keywords', $metaKeys ); $this->document->setDescription ( $this->escape($metaDesc) ); $this->setTitle(JText::sprintf('COM_KUNENA_VIEW_TOPICS_DEFAULT', $this->topic->subject)); $this->display($tpl); }
public function resetvotes() { $app = JFactory::getApplication (); if (!JRequest::checkToken('get')) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $this->redirectBack (); } $pollid = JRequest::getInt ( 'pollid', 0 ); $topic = KunenaForumTopicHelper::get($this->id); $result = $topic->resetvotes($pollid); $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_TOPIC_VOTE_RESET_SUCCESS' ) ); $app->redirect ( CKunenaLink::GetThreadPageURL ( 'view', $this->return, $this->id, 0, NULL, $this->id, false ) ); }