protected function populateState() { $app = JFactory::getApplication (); $this->me = KunenaUserHelper::get(); $config = KunenaFactory::getConfig (); $active = $app->getMenu ()->getActive (); $active = $active ? (int) $active->id : 0; $layout = $this->getWord ( 'layout', 'default' ); $layout = $this->me->getTopicLayout (); $this->setState ( 'layout', $layout ); $template = KunenaFactory::getTemplate(); $profile_location = $template->params->get('avatarPosition', 'left'); $profile_direction = $profile_location == 'left' || $profile_location == 'right' ? 'vertical' : 'horizontal'; $this->setState ( 'profile.location', $profile_location ); $this->setState ( 'profile.direction', $profile_direction ); $catid = $this->getInt ( 'catid', 0 ); $this->setState ( 'item.catid', $catid ); $id = $this->getInt ( 'id', 0 ); $this->setState ( 'item.id', $id ); $id = $this->getInt ( 'mesid', 0 ); $this->setState ( 'item.mesid', $id ); $access = KunenaFactory::getAccessControl(); $value = $access->getAllowedHold($this->me, $catid); $this->setState ( 'hold', $value ); $value = $this->getInt ( 'limit', 0 ); if ($value < 1) $value = $config->messages_per_page; $this->setState ( 'list.limit', $value ); $value = $this->getUserStateFromRequest ( "com_kunena.topic_{$active}_{$layout}_list_ordering", 'filter_order', 'time', 'cmd' ); //$this->setState ( 'list.ordering', $value ); $value = $this->getInt ( 'limitstart', 0 ); if ($value < 0) $value = 0; $this->setState ( 'list.start', $value ); $value = $this->getUserStateFromRequest ( "com_kunena.topic_{$active}_{$layout}_list_direction", 'filter_order_Dir', '', 'word' ); if (!$value) { if ($this->me->ordering != '0') { $value = $this->me->ordering == '1' ? 'desc' : 'asc'; } else { $value = $config->default_sort == 'asc' ? 'asc' : 'desc'; } } if ($value != 'asc') $value = 'desc'; $this->setState ( 'list.direction', $value ); }
function getDatabaseError() { $db = JFactory::getDBO(); if ($db->getErrorNum ()) { $app = JFactory::getApplication(); $my = JFactory::getUser(); $acl = KunenaFactory::getAccessControl(); if ($acl->isAdmin ($my)) { return $db->getErrorMsg(); } else { return 'Kunena '.JText::_ ( 'COM_KUNENA_INTERNAL_ERROR' ); } } }
function __construct($func, $page = 0) { $this->func = JString::strtolower($func); $this->userid = JRequest::getInt('userid'); if (!$this->userid) { $this->userid = null; } $this->catid = 0; $this->hasSubCats = ''; $this->mode = 'threads'; $this->header = ''; $this->db = JFactory::getDBO(); $this->user = JFactory::getUser($this->userid); $this->my = JFactory::getUser(); $this->myprofile = KunenaFactory::getUser(); $this->session = KunenaFactory::getSession(); $this->config = KunenaFactory::getConfig(); $this->latestcategory = explode(',', $this->config->latestcategory); $this->latestcategory_in = $this->config->latestcategory_in; $this->page = $page < 1 ? 1 : $page; $this->threads_per_page = $this->config->threads_per_page; $this->offset = ($this->page - 1) * $this->threads_per_page; $this->prevCheck = $this->session->lasttime; $this->app =& JFactory::getApplication(); $this->document =& JFactory::getDocument(); $this->show_list_time = JRequest::getInt('sel', $this->config->show_list_time); $this->allow = 1; $this->highlight = 0; $this->tabclass = array("row1", "row2"); if (!$this->my->id && $this->show_list_time == 0) { $this->show_list_time = $this->config->show_list_time; } $this->columns = CKunenaTools::isModerator($this->my->id, $this->catid) ? 6 : 5; $this->showposts = 0; $access = KunenaFactory::getAccessControl(); $this->hold = $access->getAllowedHold($this->myprofile, $this->catid); $template = KunenaFactory::getTemplate(); $this->params = $template->params; $this->actionDropdown[] = JHTML::_('select.option', '', JText::_('COM_KUNENA_BULK_CHOOSE_ACTION')); }
public function isModerator($catid = 0) { $acl = KunenaFactory::getAccessControl (); return $acl->isModerator ( $this, $catid ); }
/** * Test removeModerator() * * @param KunenaForumCategory $category * @return KunenaForumCategory * @depends testAddModerator */ public function testRemoveModerator(KunenaForumCategory $category) { $admin = KunenaFactory::getUser('admin'); $access = KunenaFactory::getAccessControl (); $this->assertTrue($category->removeModerator($admin), "Check that administrator can loose moderator status ({$category->getError()})"); $this->assertFalse((bool)$admin->moderator, "Check that user is not moderator"); $mod = $access->getModeratorStatus ($admin); $this->assertTrue(empty($mod[$category->id]), "Check that user is not category moderator"); return $category; }
static public function getCategories($ids = false, $reverse = false, $authorise='read') { KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null; if (self::$_instances === false) { self::loadCategories(); } if ($ids === false) { $ids = self::$_instances; if ($authorise == 'none') { KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null; return $ids; } } elseif (is_array ($ids) ) { $ids = array_flip($ids); } else { $ids = array(intval($ids)=>1); } $list = array (); if (!$reverse) { $allowed = $authorise != 'none' ? array_intersect_key($ids, KunenaFactory::getAccessControl ()->getAllowedCategories ( null, 'read' )) : $ids; $list = array_intersect_key(self::$_instances, $allowed); if ($authorise != 'none' && $authorise != 'read') { foreach ( $list as $category ) { if (!$category->authorise($authorise, null, true)) { unset($list [$category->id]); } } } } else { $allowed = $authorise != 'none' ? array_intersect_key(self::$_instances, KunenaFactory::getAccessControl ()->getAllowedCategories ( null, 'read' )) : self::$_instances; $list = array_diff_key($allowed, $ids); if ($authorise != 'none' && $authorise != 'read') { foreach ( $list as $category ) { if (!$category->authorise($authorise, null, true)) { unset($list [$category->id]); } } } } KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null; return $list; }
function save() { $db = JFactory::getDBO (); $app = JFactory::getApplication (); if (! JRequest::checkToken ()) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $app->redirect ( KunenaRoute::_($this->baseurl, false) ); } $newview = JRequest::getVar ( 'newview' ); $newrank = JRequest::getVar ( 'newrank' ); $signature = JRequest::getVar ( 'message' ); $deleteSig = JRequest::getVar ( 'deleteSig' ); $moderator = JRequest::getInt ( 'moderator' ); $uid = JRequest::getInt ( 'uid' ); $avatar = JRequest::getVar ( 'avatar' ); $deleteAvatar = JRequest::getVar ( 'deleteAvatar' ); $neworder = JRequest::getInt ( 'neworder' ); $modCatids = $moderator ? JRequest::getVar ( 'catid', array () ) : array(); if ($deleteSig == 1) { $signature = ""; } $avatar = ''; if ($deleteAvatar == 1) { $avatar = ",avatar=''"; } $db->setQuery ( "UPDATE #__kunena_users SET signature={$db->quote($signature)}, view='$newview', ordering='$neworder', rank='$newrank' $avatar WHERE userid='$uid'" ); $db->query (); if (KunenaError::checkDatabaseError()) return; $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_USER_PROFILE_SAVED_SUCCESSFULLY' ) ); // Update moderator rights $me = KunenaUserHelper::getMyself(); $categories = KunenaForumCategoryHelper::getCategories(false, false, 'admin'); $user = KunenaFactory::getUser($uid); foreach ($categories as $category) { $category->setModerator($user, in_array($category->id, $modCatids)); } // Global moderator is a special case if ($me->isAdmin()) { KunenaFactory::getAccessControl()->setModerator(0, $user, in_array(0, $modCatids)); } $app->redirect ( KunenaRoute::_($this->baseurl, false) ); }
public function getAdminOptions() { $category = $this->getAdminCategory(); if (!$category) return false; $catList = array (); $catList [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_TOPLEVEL' ) ); // make a standard yes/no list $published = array (); $published [] = JHTML::_ ( 'select.option', 1, JText::_ ( 'COM_KUNENA_PUBLISHED' ) ); $published [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_UNPUBLISHED' ) ); // make a standard yes/no list $yesno = array (); $yesno [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_ANN_NO' ) ); $yesno [] = JHTML::_ ( 'select.option', 1, JText::_ ( 'COM_KUNENA_ANN_YES' ) ); //create custom group levels to include into the public group selectList $pub_groups = array (); $adm_groups = array (); $pub_groups [] = JHTML::_ ( 'select.option', 1, JText::_ ( 'COM_KUNENA_NOBODY' ) ); $pub_groups [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_EVERYBODY' ) ); $pub_groups [] = JHTML::_ ( 'select.option', - 1, JText::_ ( 'COM_KUNENA_ALLREGISTERED' ) ); // Create the access control lists if (version_compare(JVERSION, '1.6','>')) { // Joomla 1.6 $accessLists ['pub_access'] = JHTML::_ ( 'access.usergroup', 'pub_access', $category->pub_access, 'class="inputbox" size="10"', false); $accessLists ['admin_access'] = JHTML::_ ( 'access.usergroup', 'admin_access', $category->admin_access, 'class="inputbox" size="10"', false); } else { // Joomla 1.5 $pub_groups = array (); $pub_groups [] = JHTML::_ ( 'select.option', 1, JText::_('COM_KUNENA_NOBODY') ); $pub_groups [] = JHTML::_ ( 'select.option', 0, JText::_('COM_KUNENA_PUBLIC') ); $pub_groups [] = JHTML::_ ( 'select.option', - 1, JText::_('COM_KUNENA_ALLREGISTERED') ); $adm_groups = array (); $adm_groups [] = JHTML::_ ( 'select.option', 0, JText::_('COM_KUNENA_NOBODY') ); $acl = JFactory::getACL (); $joomlagroups = $acl->get_group_children_tree ( null, 'USERS', false ); foreach ($joomlagroups as &$group) { $group->text = preg_replace('/(^ |\. | )/', '- ', $group->text); } $pub_groups = array_merge ( $pub_groups, $joomlagroups ); $adm_groups = array_merge ( $adm_groups, $joomlagroups ); // Create the access control lists for Joomla 1.5 $accessLists ['pub_access'] = JHTML::_ ( 'select.genericlist', $pub_groups, 'pub_access', 'class="inputbox" size="10"', 'value', 'text', $category->pub_access ); $accessLists ['admin_access'] = JHTML::_ ( 'select.genericlist', $adm_groups, 'admin_access', 'class="inputbox" size="10"', 'value', 'text', $category->admin_access ); } // Anonymous posts default $post_anonymous = array (); $post_anonymous [] = JHTML::_ ( 'select.option', '0', JText::_ ( 'COM_KUNENA_CATEGORY_ANONYMOUS_X_REG' ) ); $post_anonymous [] = JHTML::_ ( 'select.option', '1', JText::_ ( 'COM_KUNENA_CATEGORY_ANONYMOUS_X_ANO' ) ); $cat_params = array (); $cat_params['ordering'] = 'ordering'; $cat_params['toplevel'] = JText::_('COM_KUNENA_TOPLEVEL'); $cat_params['sections'] = 1; $cat_params['unpublished'] = 1; $cat_params['catid'] = $category->id; $cat_params['action'] = 'admin'; $channels_params = array(); $channels_params['catid'] = $category->id; $channels_params['action'] = 'admin'; $channels_options = array(); $channels_options [] = JHTML::_ ( 'select.option', 'THIS', JText::_ ( 'COM_KUNENA_CATEGORY_CHANNELS_OPTION_THIS' ) ); $channels_options [] = JHTML::_ ( 'select.option', 'CHILDREN', JText::_ ( 'COM_KUNENA_CATEGORY_CHANNELS_OPTION_CHILDREN' ) ); if (empty($category->channels)) $category->channels = 'THIS'; $topic_ordering_options = array(); $topic_ordering_options[] = JHTML::_ ( 'select.option', 'lastpost', JText::_ ( 'COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_LASTPOST' ) ); $topic_ordering_options[] = JHTML::_ ( 'select.option', 'creation', JText::_ ( 'COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_CREATION' ) ); $topic_ordering_options[] = JHTML::_ ( 'select.option', 'alpha', JText::_ ( 'COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_ALPHA' ) ); $lists = array (); $lists ['accesstypes'] = KunenaFactory::getAccessControl()->getAccessTypesList($category); $lists ['accesslevels'] = KunenaFactory::getAccessControl()->getAccessLevelsList($category); $lists ['access'] = KunenaFactory::getAccessControl()->getAccessLevelsList($category); $lists ['pub_access'] = $accessLists ['pub_access']; $lists ['admin_access'] = $accessLists ['admin_access']; $lists ['categories'] = JHTML::_('kunenaforum.categorylist', 'parent_id', 0, null, $cat_params, 'class="inputbox"', 'value', 'text', $category->parent_id); $lists ['channels'] = JHTML::_('kunenaforum.categorylist', 'channels[]', 0, $channels_options, $channels_params, 'class="inputbox" multiple="multiple"', 'value', 'text', explode(',', $category->channels)); $lists ['published'] = JHTML::_ ( 'select.genericlist', $published, 'published', 'class="inputbox"', 'value', 'text', $category->published ); $lists ['pub_recurse'] = JHTML::_ ( 'select.genericlist', $yesno, 'pub_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->pub_recurse ); $lists ['admin_recurse'] = JHTML::_ ( 'select.genericlist', $yesno, 'admin_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->admin_recurse ); $lists ['forumLocked'] = JHTML::_ ( 'select.genericlist', $yesno, 'locked', 'class="inputbox" size="1"', 'value', 'text', $category->locked ); $lists ['forumReview'] = JHTML::_ ( 'select.genericlist', $yesno, 'review', 'class="inputbox" size="1"', 'value', 'text', $category->review ); $lists ['allow_polls'] = JHTML::_ ( 'select.genericlist', $yesno, 'allow_polls', 'class="inputbox" size="1"', 'value', 'text', $category->allow_polls ); $lists ['allow_anonymous'] = JHTML::_ ( 'select.genericlist', $yesno, 'allow_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->allow_anonymous ); $lists ['post_anonymous'] = JHTML::_ ( 'select.genericlist', $post_anonymous, 'post_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->post_anonymous ); $lists ['topic_ordering'] = JHTML::_ ( 'select.genericlist', $topic_ordering_options, 'topic_ordering', 'class="inputbox" size="1"', 'value', 'text', $category->topic_ordering ); // TODO: /* $topicicons = array (); jimport( 'joomla.filesystem.folder' ); $topiciconslist = JFolder::folders(JPATH_ROOT.'/media/kunena/topicicons'); foreach( $topiciconslist as $icon ) { $topicicons[] = JHTML::_ ( 'select.option', $icon, $icon ); } $lists ['category_iconset'] = JHTML::_ ( 'select.genericlist', $topicicons, 'iconset', 'class="inputbox" size="1"', 'value', 'text', $category->iconset ); */ return $lists; }
function editForum($id, $option) { $kunena_app = JFactory::getApplication(); $kunena_my = JFactory::getUser(); kimport('category'); $category = KunenaCategory::getInstance($id); if ($category->isCheckedOut($kunena_my->id)) { $kunena_app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_CHECKED_OUT', $category->id), 'notice'); while (@ob_end_clean()) { } $kunena_app->redirect(JURI::base() . "index.php?option={$option}&task=showAdministration"); } $kunena_db = JFactory::getDBO(); $kunena_acl = JFactory::getACL(); $kunena_config = KunenaFactory::getConfig(); if ($category->exists()) { $category->checkout($kunena_my->id); } else { // New category is by default child of the first section -- this will help new users to do it right $kunena_db->setQuery("SELECT a.id, a.name FROM #__kunena_categories AS a WHERE parent='0' AND id!='{$category->id}' ORDER BY ordering"); $sections = $kunena_db->loadObjectList(); KunenaError::checkDatabaseError(); $category->parent = empty($sections) ? 0 : $sections[0]->id; $category->published = 0; $category->ordering = 9999; $category->pub_recurse = 1; $category->admin_recurse = 1; if (KUNENA_JOOMLA_COMPAT == '1.5') { $category->accesstype = 'none'; $category->access = 0; $category->pub_access = 0; $category->admin_access = 0; } else { $category->accesstype = 'joomla.level'; $category->access = 1; $category->pub_access = 1; $category->admin_access = 8; } $category->moderated = 1; } $catList = array(); $catList[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_TOPLEVEL')); $categoryList = CKunenaTools::KSelectList('parent', $catList, 'class="inputbox"', true, 'parent', $category->parent); // make a standard yes/no list $yesno = array(); $yesno[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_ANN_NO')); $yesno[] = JHTML::_('select.option', '1', JText::_('COM_KUNENA_ANN_YES')); //Create all kinds of Lists $lists = array(); $accessLists = array(); //create custom group levels to include into the public group selectList if (KUNENA_JOOMLA_COMPAT == '1.5') { $pub_groups = array(); $pub_groups[] = JHTML::_('select.option', 1, JText::_('COM_KUNENA_NOBODY')); $pub_groups[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_PUBLIC')); $pub_groups[] = JHTML::_('select.option', -1, JText::_('COM_KUNENA_ALLREGISTERED')); $adm_groups = array(); $adm_groups[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_NOBODY')); $joomlagroups = $kunena_acl->get_group_children_tree(null, 'USERS', false); foreach ($joomlagroups as &$group) { $group->text = preg_replace('/(^ |\\. | )/', '- ', $group->text); } $pub_groups = array_merge($pub_groups, $joomlagroups); $adm_groups = array_merge($adm_groups, $joomlagroups); // Create the access control lists for Joomla 1.5 $accessLists['pub_access'] = JHTML::_('select.genericlist', $pub_groups, 'pub_access', 'class="inputbox" size="10"', 'value', 'text', $category->pub_access); $accessLists['admin_access'] = JHTML::_('select.genericlist', $adm_groups, 'admin_access', 'class="inputbox" size="10"', 'value', 'text', $category->admin_access); } else { // Create the access control lists for Joomla 1.6 $accessLists['pub_access'] = JHTML::_('access.usergroup', 'pub_access', $category->pub_access, 'class="inputbox" size="10"', false); $accessLists['admin_access'] = JHTML::_('access.usergroup', 'admin_access', $category->admin_access, 'class="inputbox" size="10"', false); } // Anonymous posts default $post_anonymous = array(); $post_anonymous[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_CATEGORY_ANONYMOUS_X_REG')); $post_anonymous[] = JHTML::_('select.option', '1', JText::_('COM_KUNENA_CATEGORY_ANONYMOUS_X_ANO')); $lists['accesstypes'] = KunenaFactory::getAccessControl()->getAccessTypesList($category); $lists['accesslevels'] = KunenaFactory::getAccessControl()->getAccessLevelsList($category); $lists['pub_recurse'] = JHTML::_('select.genericlist', $yesno, 'pub_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->pub_recurse); $lists['admin_recurse'] = JHTML::_('select.genericlist', $yesno, 'admin_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->admin_recurse); $lists['forumLocked'] = JHTML::_('select.genericlist', $yesno, 'locked', 'class="inputbox" size="1"', 'value', 'text', $category->locked); $lists['forumModerated'] = JHTML::_('select.genericlist', $yesno, 'moderated', 'class="inputbox" size="1"', 'value', 'text', $category->moderated); $lists['forumReview'] = JHTML::_('select.genericlist', $yesno, 'review', 'class="inputbox" size="1"', 'value', 'text', $category->review); $lists['allow_polls'] = JHTML::_('select.genericlist', $yesno, 'allow_polls', 'class="inputbox" size="1"', 'value', 'text', $category->allow_polls); $lists['allow_anonymous'] = JHTML::_('select.genericlist', $yesno, 'allow_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->allow_anonymous); $lists['post_anonymous'] = JHTML::_('select.genericlist', $post_anonymous, 'post_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->post_anonymous); //get a list of moderators, if forum/category is moderated $moderatorList = array(); if ($category->moderated == 1 && $category->exists()) { $kunena_db->setQuery("SELECT * FROM #__kunena_moderation AS a INNER JOIN #__users as u ON a.userid=u.id where a.catid={$category->id}"); $moderatorList = $kunena_db->loadObjectList(); KunenaError::checkDatabaseError(); } html_Kunena::editForum($category, $categoryList, $moderatorList, $lists, $accessLists, $option, $kunena_config); }
protected function authoriseRead($user) { // Check that user can read topic if (!$this->exists()) { return JText::_ ( 'COM_KUNENA_NO_ACCESS' ); } if ($this->hold > 1 || ($this->hold && !$this->getUserTopic($user)->owner)) { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($user->userid, $this->category_id, false); if (!in_array($this->hold, $hold)) { return JText::_ ( 'COM_KUNENA_NO_ACCESS' ); } } }
function getAllowedForums($uid) { $acl = KunenaFactory::getAccessControl(); return $acl->getAllowedCategories($uid); }
public function canRead($action = '-read-') { // Load must have been performed successfully! if (!$this->parent) { return false; // Error has already been set, either in construct() or load() } // Do not perform rest of the checks to administrators if (CKunenaTools::isAdmin()) { return true; // ACCEPT! } // Category must be visible if (!$this->_session->canRead($this->parent->catid)) { return $this->setError($action, JText::_('COM_KUNENA_NO_ACCESS')); } // Check unapproved, deleted etc messages $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($this->_my->id, $this->parent->catid, false); if ($this->parent->hold == 1 && $this->_my->id == $this->parent->userid) { // User can see his own post before it gets approved } else { if (!in_array($this->parent->hold, $hold) || !in_array($this->parent->topichold, $hold)) { // User is not allowed to see this post return $this->setError($action, JText::_('COM_KUNENA_POST_INVALID')); } } return true; }
public function getLocation($mesid, $direction = 'asc', $hold=null) { if (!$hold) { $me = KunenaFactory::getUser(); $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($me->userid, $mesid, false); } if (!isset(self::$_location [$mesid])) { self::loadLocation(array($mesid)); } $location = self::$_location [$mesid]; $count = 0; foreach ($location->hold as $meshold=>$values) { if (isset($hold[$meshold])) { $count += $values[$direction = 'asc' ? 'before' : 'after']; if ($direction == 'both') $count += $values['before']; } } return $count; }
function GetMessageURL($pid, $catid = 0, $limit = 0, $xhtml = true) { $kunena_config = KunenaFactory::getConfig(); $myprofile = KunenaFactory::getUser(); if ($myprofile->ordering != '0') { $topic_ordering = $myprofile->ordering == '1' ? '>=' : '<='; } else { $topic_ordering = $kunena_config->default_sort == 'asc' ? '<=' : '>='; } $maxmin = $topic_ordering == '<=' ? 'MAX' : 'MIN'; if ($limit < 1) { $limit = $kunena_config->messages_per_page; } $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($myprofile, $catid); $kunena_db = JFactory::getDBO(); // First determine the thread, latest post and number of posts for the post supplied $kunena_db->setQuery("SELECT a.thread AS thread, {$maxmin}(a.id) AS latest_id, MAX(a.catid) AS catid, COUNT(*) AS totalmessages\n FROM #__kunena_messages AS a, (SELECT thread FROM #__kunena_messages WHERE id={$kunena_db->Quote($pid)}) AS b\n WHERE a.thread = b.thread AND a.hold IN ({$hold}) AND a.id {$topic_ordering} {$kunena_db->Quote($pid)}\n GROUP BY a.thread"); $result = $kunena_db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } if (!is_object($result)) { return KunenaRoute::_(KUNENA_LIVEURLREL . '&func=showcat&catid=' . $result->catid, $xhtml); } return CKunenaLink::GetThreadPageURL('view', $result->catid, $result->thread, ceil($result->totalmessages / $limit), $limit, $result->latest_id, $xhtml); }
function getCategoryTree(&$xmap, &$parent, &$params, $parentCat) { $database =& JFactory::getDBO(); $kunenaSession = KunenaFactory::getSession(); $kunenaSession->updateAllowedForums(); $catlist = $kunenaSession->allowed; $list = array(); $query = "SELECT id as cat_id, name as cat_title, ordering FROM #__kunena_categories WHERE parent={$parentCat} AND published=1 and id in ({$catlist}) ORDER BY name"; $database->setQuery($query); $cats = $database->loadObjectList(); /* get list of categories */ $xmap->changeLevel(1); foreach ($cats as $cat) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 'c' . $cat->cat_id; $node->name = $cat->cat_title; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = 'index.php?option=com_kunena&func=showcat&catid=' . $cat->cat_id . '&Itemid=' . $parent->id; $node->expandible = true; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->cat_id); } } if ($params['include_topics']) { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold(self::$profile, $parentCat); $query = "SELECT t.id, t.catid as cat_id, t.subject as forum_name, max(m.time) as modified, count(m.id) as msgcount " . "FROM #__kunena_messages AS t " . "INNER JOIN #__kunena_messages AS m ON t.id = m.thread " . "WHERE t.catid={$parentCat} " . "AND t.hold in ({$hold}) " . "AND t.parent=0 " . $params['days'] . "GROUP BY m.`thread`" . "ORDER BY " . $params['topics_order'] . $params['limit']; $database->setQuery($query); #echo str_replace('#__','jos_',$database->getQuery()); $forums = $database->loadObjectList(); //get list of forums foreach ($forums as $forum) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 't' . $forum->id; $node->name = $forum->forum_name; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval($forum->modified); $node->link = 'index.php?option=com_kunena&func=view&catid=' . $forum->cat_id . '&id=' . $forum->id . '&Itemid=' . $parent->id; $node->expandible = false; if ($xmap->printNode($node) !== FALSE) { if ($params['include_pagination'] && $forum->msgcount > self::$config->messages_per_page) { $msgPerPage = self::$config->messages_per_page; $threadPages = ceil($forum->msgcount / $msgPerPage); for ($i = 2; $i <= $threadPages; $i++) { $subnode = new stdclass(); $subnode->id = $node->id; $subnode->uid = $node->uid . 'p' . $i; $subnode->name = "[{$i}]"; $subnode->seq = $i; $subnode->link = $node->link . '&limit=' . $msgPerPage . '&limitstart=' . ($i - 1) * $msgPerPage; $subnode->browserNav = $node->browserNav; $subnode->priority = $node->priority; $subnode->changefreq = $node->changefreq; $subnode->modified = $node->modified; $xmap->printNode($subnode); } } } } } $xmap->changeLevel(-1); }
function report() { $app = JFactory::getApplication (); if (! JRequest::checkToken ()) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $this->redirectBack (); } $config = KunenaFactory::getConfig (); $me = KunenaUserHelper::getMyself(); if (!$me->exists() || $config->reportmsg == 0) { // Deny access if report feature has been disabled or user is guest $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_NO_ACCESS' ), 'notice' ); $this->redirectBack (); } jimport ( 'joomla.mail.helper' ); if (! $config->email || ! JMailHelper::isEmailAddress ( $config->email )) { // Error: email address is invalid $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_EMAIL_INVALID' ), 'error' ); $this->redirectBack (); } // Get target object for the report if ($this->mesid) { $message = $target = KunenaForumMessageHelper::get($this->mesid); $topic = $target->getTopic(); $messagetext = $message->message; $baduser = KunenaFactory::getUser($message->userid); } else { $topic = $target = KunenaForumTopicHelper::get($this->id); $messagetext = $topic->first_post_message; $baduser = KunenaFactory::getUser($topic->first_post_userid); } if (!$target->authorise('read')) { // Deny access if user cannot read target $app->enqueueMessage ( $target->getError(), 'notice' ); $this->redirectBack (); } $category = $topic->getCategory(); $reason = JRequest::getString ( 'reason' ); $text = JRequest::getString ( 'text' ); if (empty ( $reason ) && empty ( $text )) { // Do nothing: empty subject or reason is empty $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_REPORT_FORG0T_SUB_MES' ) ); $this->redirectBack (); } else { $acl = KunenaFactory::getAccessControl(); $emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false, $me->userid); if (!empty ( $emailToList )) { $mailsender = JMailHelper::cleanAddress ( $config->board_title . ' ' . JText::_ ( 'COM_KUNENA_GEN_FORUM' ) . ': ' . $me->getName() ); $mailsubject = "[" . $config->board_title . " " . JText::_ ( 'COM_KUNENA_GEN_FORUM' ) . "] " . JText::_ ( 'COM_KUNENA_REPORT_MSG' ) . ": "; if ($reason) { $mailsubject .= $reason; } else { $mailsubject .= $topic->subject; } jimport ( 'joomla.environment.uri' ); $uri = JURI::getInstance ( JURI::base () ); $msglink = $uri->toString ( array ('scheme', 'host', 'port' ) ) . $target->getPermaUrl(null, false); $mailmessage = "" . JText::_ ( 'COM_KUNENA_REPORT_RSENDER' ) . " {$me->username} ($me->name)"; $mailmessage .= "\n"; $mailmessage .= "" . JText::_ ( 'COM_KUNENA_REPORT_RREASON' ) . " " . $reason; $mailmessage .= "\n"; $mailmessage .= "" . JText::_ ( 'COM_KUNENA_REPORT_RMESSAGE' ) . " " . $text; $mailmessage .= "\n\n"; $mailmessage .= "" . JText::_ ( 'COM_KUNENA_REPORT_POST_POSTER' ) . " {$baduser->username} ($baduser->name)"; $mailmessage .= "\n"; $mailmessage .= "" . JText::_ ( 'COM_KUNENA_REPORT_POST_SUBJECT' ) . ": " . $topic->subject; $mailmessage .= "\n"; $mailmessage .= "" . JText::_ ( 'COM_KUNENA_REPORT_POST_MESSAGE' ) . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext); $mailmessage .= "\n-----\n\n"; $mailmessage .= "" . JText::_ ( 'COM_KUNENA_REPORT_POST_LINK' ) . " " . $msglink; $mailmessage .= "\n\n\n\n** Powered by Kunena! - http://www.kunena.org **"; $mailmessage = JMailHelper::cleanBody ( strtr ( $mailmessage, array (' ' => '' ) ) ); foreach ( $emailToList as $emailTo ) { if (! $emailTo->email || ! JMailHelper::isEmailAddress ( $emailTo->email )) continue; JUtility::sendMail ( $config->email, $mailsender, $emailTo->email, $mailsubject, $mailmessage ); } $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_REPORT_SUCCESS' ) ); } else { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_REPORT_NOT_SEND' ) ); } } $app->redirect ( $target->getUrl($this->return, false) ); }
function onAfterEventsUserBlocked() { if (!self::kunenaOnline()) { return; } $access = KunenaFactory::getAccessControl(); $access->clearCache(); }
static function getCategoryTree($xmap, $parent, &$params, $parentCat) { $db = JFactory::getDBO(); // Load categories if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ $catlink = 'index.php?option=com_kunena&view=category&catid=%s&Itemid=' . $parent->id; $toplink = 'index.php?option=com_kunena&view=topic&catid=%s&id=%s&Itemid=' . $parent->id; // kimport('kunena.forum.category.helper'); $categories = KunenaForumCategoryHelper::getChildren($parentCat); } else { $catlink = 'index.php?option=com_kunena&func=showcat&catid=%s&Itemid=' . $parent->id; $toplink = 'index.php?option=com_kunena&func=view&catid=%s&id=%s&Itemid=' . $parent->id; if (self::getKunenaMajorVersion() >= '1.6') { // Kunena 1.6+ kimport('session'); $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $allowed = $session->allowed; $query = "SELECT id, name FROM `#__kunena_categories` WHERE parent={$parentCat} AND id IN ({$allowed}) ORDER BY ordering"; } else { // Kunena 1.0+ $query = "SELECT id, name FROM `{$params['table_prefix']}_categories` WHERE parent={$parentCat} AND published=1 AND pub_access=0 ORDER BY ordering"; } $db->setQuery($query); $categories = $db->loadObjectList(); } /* get list of categories */ $xmap->changeLevel(1); foreach ($categories as $cat) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = 'com_kunenac' . $cat->id; $node->name = $cat->name; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = sprintf($catlink, $cat->id); $node->expandible = true; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->id); } } if ($params['include_topics']) { if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ // kimport('kunena.forum.topic.helper'); // TODO: orderby parameter is missing: $topics = KunenaForumTopicHelper::getLatestTopics($parentCat, 0, $params['limit'], array('starttime', $params['days'])); if (count($topics) == 2 && is_numeric($topics[0])) { $topics = $topics[1]; } } else { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold(self::$profile, $parentCat); // Kunena 1.0+ $query = "SELECT t.id, t.catid, t.subject, max(m.time) as time, count(m.id) as msgcount\n FROM {$params['table_prefix']}_messages t\n INNER JOIN {$params['table_prefix']}_messages AS m ON t.id = m.thread\n WHERE t.catid={$parentCat} AND t.parent=0\n AND t.hold in ({$hold})\n GROUP BY m.`thread`\n ORDER BY {$params['topics_order']} DESC"; if ($params['days']) { $query = "SELECT * FROM ({$query}) as topics WHERE time >= {$params['days']}"; } #echo str_replace('#__','mgbj2_',$query); $db->setQuery($query, 0, $params['limit']); $topics = $db->loadObjectList(); } //get list of topics foreach ($topics as $topic) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = 'com_kunenat' . $topic->id; $node->name = $topic->subject; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval(@$topic->last_post_time ? $topic->last_post_time : $topic->time); $node->link = sprintf($toplink, @$topic->category_id ? $topic->category_id : $topic->catid, $topic->id); $node->expandible = false; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { // Pagination will not work with K2.0, revisit this when that version is out and stable if ($params['include_pagination'] && isset($topic->msgcount) && $topic->msgcount > self::$config->messages_per_page) { $msgPerPage = self::$config->messages_per_page; $threadPages = ceil($topic->msgcount / $msgPerPage); for ($i = 2; $i <= $threadPages; $i++) { $subnode = new stdclass(); $subnode->id = $node->id; $subnode->uid = $node->uid . 'p' . $i; $subnode->name = "[{$i}]"; $subnode->seq = $i; $subnode->link = $node->link . '&limit=' . $msgPerPage . '&limitstart=' . ($i - 1) * $msgPerPage; $subnode->browserNav = $node->browserNav; $subnode->priority = $node->priority; $subnode->changefreq = $node->changefreq; $subnode->modified = $node->modified; $subnode->secure = $node->secure; $xmap->printNode($subnode); } } } } } $xmap->changeLevel(-1); }
public function getTopics() { if ($this->topics === false) { $catid = $this->getState ( 'item.id'); $limitstart = $this->getState ( 'list.start'); $limit = $this->getState ( 'list.limit'); $format = $this->getState ( 'format'); $topic_ordering = $this->getCategory()->topic_ordering; $access = KunenaFactory::getAccessControl(); $hold = $format == 'feed' ? 0 : $access->getAllowedHold($this->me, $catid); $moved = $format == 'feed' ? 0 : 1; $params = array( 'hold'=>$hold, 'moved'=>$moved); switch ($topic_ordering) { case 'alpha': $params['orderby'] = 'tt.ordering DESC, tt.subject ASC '; break; case 'creation': $params['orderby'] = 'tt.ordering DESC, tt.first_post_time ' . strtoupper($this->getState ( 'list.direction')); break; case 'lastpost': default: $params['orderby'] = 'tt.ordering DESC, tt.last_post_time ' . strtoupper($this->getState ( 'list.direction')); } if ($format == 'feed') { $catid = array_keys(KunenaForumCategoryHelper::getChildren($catid, 100)+array($catid=>1)); } list($this->total, $this->topics) = KunenaForumTopicHelper::getLatestTopics($catid, $limitstart, $limit, $params); if ($this->total > 0) { // collect user ids for avatar prefetch when integrated $userlist = array(); foreach ( $this->topics as $topic ) { $userlist[intval($topic->first_post_userid)] = intval($topic->first_post_userid); $userlist[intval($topic->last_post_userid)] = intval($topic->last_post_userid); $lastpostlist[intval($topic->last_post_id)] = intval($topic->last_post_id); } // Prefetch all users/avatars to avoid user by user queries during template iterations if ( !empty($userlist) ) KunenaUserHelper::loadUsers($userlist); KunenaForumTopicHelper::getUserTopics(array_keys($this->topics)); KunenaForumTopicHelper::getKeywords(array_keys($this->topics)); $lastreadlist = KunenaForumTopicHelper::fetchNewStatus($this->topics); // Fetch last / new post positions when user can see unapproved or deleted posts if (($lastpostlist || $lastreadlist) && $this->me->userid && $this->me->isModerator()) { KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist); } } } return $this->topics; }
public function getListmodcats() { $db = JFactory::getDBO (); $user = $this->getUser(); $modCatList = array_keys(KunenaFactory::getAccessControl()->getModeratorStatus($user)); if (empty($modCatList)) $modCatList[] = 0; $categoryList = array(JHTML::_('select.option', 0, JText::_('COM_KUNENA_GLOBAL_MODERATOR'))); $params = array ( 'sections' => false, 'action' => 'read'); $modCats = JHTML::_('kunenaforum.categorylist', 'catid[]', 0, $categoryList, $params, 'class="inputbox" multiple="multiple" size="15"', 'value', 'text', $modCatList, 'kforums'); return $modCats; }
function __construct($layout, $catid, $id, $limitstart = 0, $limit = 0, $mesid = 0) { require_once KUNENA_PATH_LIB . '/kunena.smile.class.php'; require_once KUNENA_PATH_LIB . '/kunena.link.class.php'; $this->db = JFactory::getDBO(); $this->config = KunenaFactory::getConfig(); $this->session = KunenaFactory::getSession(); $this->my = JFactory::getUser(); $this->myprofile = KunenaFactory::getUser(); $this->app = JFactory::getApplication(); $this->layout = $this->config->enable_threaded_layouts && $layout && $layout != 'flat' ? $layout : 'view'; $this->catid = $catid; $this->id = $id; $this->mesid = $mesid; //prepare paging $this->limitstart = $limitstart; if ($this->limitstart < 0) { $this->limitstart = 0; } $this->limit = $limit; if ($this->limit < 1) { $this->limit = $this->config->messages_per_page; } $template = KunenaFactory::getTemplate(); $this->params = $template->params; if ($this->myprofile->ordering != '0') { $this->ordering = $this->myprofile->ordering == '1' ? 'DESC' : 'ASC'; } else { $this->ordering = $this->config->default_sort == 'asc' ? 'ASC' : 'DESC'; // Just to make sure only valid options make it } $access = KunenaFactory::getAccessControl(); $this->hold = $access->getAllowedHold($this->myprofile, $this->catid); }
function GetMessageURL($pid, $catid=0, $limit = 0, $xhtml = true) { kimport ('kunena.error'); $config = KunenaFactory::getConfig (); $myprofile = KunenaFactory::getUser (); if ($myprofile->ordering != '0') { $topic_ordering = $myprofile->ordering == '1' ? '>=' : '<='; } else { $topic_ordering = $config->default_sort == 'asc' ? '<=' : '>='; } $maxmin = $topic_ordering == '<=' ? 'MAX' : 'MIN'; if ($limit < 1) $limit = $config->messages_per_page; $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($myprofile, $catid); $db = JFactory::getDBO (); // First determine the thread, latest post and number of posts for the post supplied $db->setQuery ( "SELECT a.thread AS thread, {$maxmin}(a.id) AS latest_id, MAX(a.catid) AS catid, COUNT(*) AS totalmessages FROM #__kunena_messages AS a, (SELECT thread FROM #__kunena_messages WHERE id={$db->Quote($pid)}) AS b WHERE a.thread = b.thread AND a.hold IN ({$hold}) AND a.id {$topic_ordering} {$db->Quote($pid)} GROUP BY a.thread" ); $result = $db->loadObject (); if (KunenaError::checkDatabaseError()) return; if (! is_object ( $result )) return KunenaRoute::_ ( "index.php?option=com_kunena&view=showcat&catid={$catid}", $xhtml ); return self::GetThreadPageURL ( 'view', $catid, $result->thread, $result->totalmessages, $limit, $result->latest_id, $xhtml ); }
protected function authoriseRead($user) { // Check that user has the right to see the post (user can see his own unapproved posts) if ($this->hold > 1 || ($this->hold == 1 && $this->userid != $user->userid)) { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($user->userid, $this->catid, false); if (!in_array($this->hold, $hold)) { $this->setError ( JText::_ ( 'COM_KUNENA_NO_ACCESS' ) ); return false; } } return true; }
protected function authoriseRead($user) { static $catids = false; if ($catids === false) { $catids = KunenaFactory::getAccessControl ()->getAllowedCategories ( $user, 'read' ); } // Checks if user can read category if (!$this->exists()) { return JText::_ ( 'COM_KUNENA_NO_ACCESS' ); } if (empty($catids[0]) && empty($catids[$this->id])) { return JText::_ ( 'COM_KUNENA_NO_ACCESS' ); } }
function __construct($catid, $page = 0) { kimport('html.parser'); $this->func = 'showcat'; $this->catid = $catid; $this->page = $page; $this->hasSubCats = ''; $template = KunenaFactory::getTemplate(); $this->params = $template->params; $this->db = JFactory::getDBO(); $this->my = JFactory::getUser(); $this->myprofile = KunenaFactory::getUser(); $this->session = KunenaFactory::getSession(); $this->config = KunenaFactory::getConfig(); if (!$this->catid) { return; } if (!$this->session->canRead($this->catid)) { return; } $this->allow = 1; $this->tabclass = array("row1", "row2"); $this->prevCheck = $this->session->lasttime; $this->app =& JFactory::getApplication(); //Get the category information $query = "SELECT c.*, s.catid AS subscribeid\n\t\t\t\tFROM #__kunena_categories AS c\n\t\t\t\tLEFT JOIN #__kunena_subscriptions_categories AS s ON c.id = s.catid\n\t\t\t\tAND s.userid = '{$this->my->id}'\n\t\t\t\tWHERE c.id={$this->db->Quote($this->catid)}"; $this->db->setQuery($query); $this->objCatInfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } //Get the Category's parent category name for breadcrumb $this->db->setQuery("SELECT name, id FROM #__kunena_categories WHERE id={$this->db->Quote($this->objCatInfo->parent)}"); $objCatParentInfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } //check if this forum is locked $this->kunena_forum_locked = $this->objCatInfo->locked; //check if this forum is subject to review $this->kunena_forum_reviewed = $this->objCatInfo->review; $threads_per_page = $this->config->threads_per_page; $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold($this->myprofile, $this->catid); /*//////////////// Start selecting messages, prepare them for threading, etc... /////////////////*/ $this->page = $this->page < 1 ? 1 : $this->page; $offset = ($this->page - 1) * $threads_per_page; $row_count = $this->page * $threads_per_page; $this->db->setQuery("SELECT COUNT(*) FROM #__kunena_messages WHERE parent='0' AND catid={$this->db->Quote($this->catid)} AND hold IN ({$hold})"); $this->total = (int) $this->db->loadResult(); KunenaError::checkDatabaseError(); $this->totalpages = ceil($this->total / $threads_per_page); $query = "SELECT t.id, MAX(m.id) AS lastid FROM #__kunena_messages AS t\n\tINNER JOIN #__kunena_messages AS m ON t.id = m.thread\n\tWHERE t.parent='0' AND t.hold IN ({$hold}) AND t.catid={$this->db->Quote($this->catid)} AND m.hold IN ({$hold}) AND m.catid={$this->db->Quote($this->catid)}\n\tGROUP BY m.thread ORDER BY t.ordering DESC, lastid DESC"; $this->db->setQuery($query, $offset, $threads_per_page); $threadids = $this->db->loadResultArray(); KunenaError::checkDatabaseError(); $idstr = implode(",", $threadids); $this->messages = array(); $this->threads = array(); $this->highlight = 0; $routerlist = array(); if (count($threadids) > 0) { $query = "SELECT a.*, j.id AS userid, t.message AS message, l.myfavorite, l.favcount, l.attachments,\n\t\t\t\t\t\t\tl.msgcount, l.lastid, l.lastid AS lastread, 0 AS unread, j.username, j.name AS uname, u.avatar, c.id AS catid, c.name AS catname, c.class_sfx\n\tFROM (\n\t\tSELECT m.thread, MAX(f.userid='{$this->my->id}') AS myfavorite, COUNT(DISTINCT f.userid) AS favcount, COUNT(a.mesid) AS attachments,\n\t\t\tCOUNT(DISTINCT m.id) AS msgcount, MAX(m.id) AS lastid, MAX(m.time) AS lasttime\n\t\tFROM #__kunena_messages AS m"; if ($this->config->allowfavorites) { $query .= " LEFT JOIN #__kunena_favorites AS f ON f.thread = m.thread"; } else { $query .= " LEFT JOIN #__kunena_favorites AS f ON f.thread = 0"; } $query .= "\n\t\tLEFT JOIN #__kunena_attachments AS a ON a.mesid = m.thread\n\t\tWHERE m.hold IN ({$hold}) AND m.thread IN ({$idstr})\n\t\tGROUP BY thread\n\t) AS l\n\tINNER JOIN #__kunena_messages AS a ON a.thread = l.thread\n\tINNER JOIN #__kunena_messages_text AS t ON a.thread = t.mesid\n\tLEFT JOIN #__users AS j ON j.id = a.userid\n\tLEFT JOIN #__kunena_users AS u ON u.userid = j.id\n\tLEFT JOIN #__kunena_categories AS c ON c.id = a.catid\n\tWHERE (a.parent='0' OR a.id=l.lastid)\n\tORDER BY ordering DESC, lastid DESC"; $this->db->setQuery($query); $this->messages = $this->db->loadObjectList('id'); KunenaError::checkDatabaseError(); // collect user ids for avatar prefetch when integrated $userlist = array(); foreach ($this->messages as $message) { if ($message->parent == 0) { $this->threads[$message->thread] = $message; $routerlist[$message->id] = $message->subject; if ($message->ordering) { $this->highlight++; } } if ($message->id == $message->lastid) { $this->lastreply[$message->thread] = $message; } $userlist[intval($message->userid)] = intval($message->userid); $userlist[intval($message->modified_by)] = intval($message->modified_by); } require_once KUNENA_PATH . '/router.php'; KunenaRouter::loadMessages($routerlist); if ($this->config->shownew && $this->my->id) { $readlist = $this->session->readtopics; $this->db->setQuery("SELECT thread, MIN(id) AS lastread, SUM(1) AS unread FROM #__kunena_messages " . "WHERE hold IN ({$hold}) AND moved='0' AND thread NOT IN ({$readlist}) AND thread IN ({$idstr}) AND time>{$this->db->Quote($this->prevCheck)} GROUP BY thread"); $msgidlist = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); foreach ($msgidlist as $msgid) { $this->messages[$msgid->thread]->lastread = $msgid->lastread; $this->messages[$msgid->thread]->unread = $msgid->unread; } } } //Perform subscriptions check $kunena_cansubscribecat = 0; if ($this->config->allowsubscriptions && $this->config->category_subscriptions != 'disabled' && ("" != $this->my->id || 0 != $this->my->id)) { if ($this->objCatInfo->subscribeid == '') { $kunena_cansubscribecat = 1; } } //meta description and keywords $metaKeys = kunena_htmlspecialchars(JText::_('COM_KUNENA_CATEGORIES') . ", {$objCatParentInfo->name}, {$this->objCatInfo->name}, {$this->config->board_title}, " . $this->app->getCfg('sitename')); $metaDesc = kunena_htmlspecialchars("{$this->objCatInfo->description} ({$this->page}/{$this->totalpages})"); $document =& JFactory::getDocument(); $cur = $document->get('description'); $metaDesc = $cur . '. ' . $metaDesc; $document =& JFactory::getDocument(); $document->setMetadata('keywords', $metaKeys); $document->setDescription($metaDesc); $this->headerdesc = $this->objCatInfo->headerdesc; if (CKunenaTools::isModerator($this->my->id, $this->catid) || !$this->kunena_forum_locked) { //this user is allowed to post a new topic: $this->forum_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 ($this->my->id != 0 && $this->total) { $this->forum_markread = CKunenaLink::GetCategoryActionLink('markthisread', $this->catid, CKunenaTools::showButton('markread', JText::_('COM_KUNENA_BUTTON_MARKFORUMREAD')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_MARKFORUMREAD_LONG')); } // Thread Subscription if ($kunena_cansubscribecat == 1) { // this user is allowed to subscribe - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_subscribecat = CKunenaLink::GetCategoryActionLink('subscribecat', $this->catid, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_CATEGORY')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_CATEGORY_LONG')); } if ($this->my->id != 0 && $this->config->allowsubscriptions && $this->config->category_subscriptions != 'disabled' && $kunena_cansubscribecat == 0) { // this user is allowed to unsubscribe $this->thread_subscribecat = CKunenaLink::GetCategoryActionLink('unsubscribecat', $this->catid, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_CATEGORY')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_CATEGORY_LONG')); } //get the Moderator list for display $this->db->setQuery("SELECT * 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(); foreach ($this->modslist as $mod) { $userlist[intval($mod->userid)] = intval($mod->userid); } // Prefetch all users/avatars to avoid user by user queries during template iterations if (!empty($userlist)) { KunenaUser::loadUsers($userlist); } $this->columns = CKunenaTools::isModerator($this->my->id, $this->catid) ? 6 : 5; $this->showposts = 0; $this->actionDropdown[] = JHTML::_('select.option', '', JText::_('COM_KUNENA_BULK_CHOOSE_ACTION')); }