public function __construct($params) { static $cssadded = false; require_once KUNENA_PATH_LIB . DS . 'kunena.link.class.php'; require_once KUNENA_PATH_LIB . DS . 'kunena.image.class.php'; require_once KUNENA_PATH_LIB . DS . 'kunena.timeformat.class.php'; require_once KUNENA_PATH_FUNCS . DS . 'latestx.php'; require_once JPATH_ADMINISTRATOR . '/components/com_kunena/libraries/html/parser.php'; $this->kunena_config = KunenaFactory::getConfig(); $this->myprofile = KunenaFactory::getUser(); // load Kunena main language file so we can leverage langaueg strings from it KunenaFactory::loadLanguage(); // Initialize session $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $this->document = JFactory::getDocument(); $kloadcss = $params->get('kunena_load_css'); if ($cssadded == false && $kloadcss) { $this->document->addStyleSheet(JURI::root() . 'modules/mod_kunenalatest/tmpl/css/kunenalatest.css'); $cssadded = true; } $this->latestdo = null; if ($params->get('choosemodel') != 'latest') { $this->latestdo = $params->get('choosemodel'); } $this->params = $params; $this->ktemplate = KunenaFactory::getTemplate(); $this->klistpost = modKunenaLatestHelper::getKunenaLatestList($params); $this->topic_ordering = modKunenaLatestHelper::getTopicsOrdering($this->myprofile, $this->kunena_config); require JModuleHelper::getLayoutPath('mod_kunenalatest'); }
public function display() { static $cssadded = false; require_once (KUNENA_PATH_LIB . DS . 'kunena.link.class.php'); require_once (KUNENA_PATH_LIB . DS . 'kunena.image.class.php'); require_once (KUNENA_PATH_LIB . DS . 'kunena.timeformat.class.php'); require_once (KUNENA_PATH_FUNCS . DS . 'latestx.php'); require_once (JPATH_ADMINISTRATOR . '/components/com_kunena/libraries/html/parser.php'); $this->kunena_config = KunenaFactory::getConfig (); $this->myprofile = KunenaFactory::getUser (); // load Kunena main language file so we can leverage langaueg strings from it KunenaFactory::loadLanguage(); // Initialize session $session = KunenaFactory::getSession (); $session->updateAllowedForums(); $this->latestdo = null; if ($this->params->get ( 'choosemodel' ) != 'latest') { $this->latestdo = $this->params->get ( 'choosemodel' ); } $this->ktemplate = KunenaFactory::getTemplate(); $this->klistpost = modKunenaLatestHelper::getKunenaLatestList ( $this->params ); $this->topic_ordering = modKunenaLatestHelper::getTopicsOrdering($this->myprofile, $this->kunena_config); require (JModuleHelper::getLayoutPath ( 'mod_kunenalatest' )); }
function __construct() { $this->_db =& JFactory::getDBO(); $this->_my =& JFactory::getUser(); $this->_config = KunenaFactory::getConfig(); $this->_session = KunenaFactory::getSession(); }
static public function getNewTopics($catids) { $session = KunenaFactory::getSession (); if (!$session->userid || !KunenaFactory::getConfig()->shownew) { return; } $readlist = $session->readtopics; $prevCheck = $session->lasttime; $categories = self::getCategories($catids); $catlist = array(); foreach ($categories as $category) { $catlist += $category->getChannels(); $catlist += $category->getChildren(); } if (empty($catlist)) return; $catlist = implode(',', array_keys($catlist)); $db = JFactory::getDBO (); $query = "SELECT DISTINCT(category_id), COUNT(*) AS new FROM #__kunena_topics WHERE category_id IN ($catlist) AND hold='0' AND last_post_time>{$db->Quote($prevCheck)} AND id NOT IN ({$readlist}) GROUP BY category_id"; $db->setQuery ( $query ); $newlist = (array) $db->loadObjectList ('category_id'); if (KunenaError::checkDatabaseError()) return; if (empty($newlist)) return; $new = array(); foreach ($newlist AS $id=>$item) { $new[$id] = (int) $item->new; } foreach ($categories as $category) { $channels = $category->getChannels(); $channels += $category->getChildren(); $category->getNewCount(array_sum(array_intersect_key($new, $channels))); } }
function __construct() { $this->do = JRequest::getCmd('do', ''); $this->action = JRequest::getCmd('action', ''); $this->_app =& JFactory::getApplication(); $this->config = KunenaFactory::getConfig(); $this->_session = KunenaFactory::getSession(); $this->_db =& JFactory::getDBO(); $this->document = JFactory::getDocument(); require_once KPATH_SITE . '/lib/kunena.poll.class.php'; $this->poll =& CKunenaPolls::getInstance(); $this->my = JFactory::getUser(); $this->me = KunenaFactory::getUser(); $this->id = JRequest::getInt('id', 0); if (!$this->id) { $this->id = JRequest::getInt('parentid', 0); } if (!$this->id) { // Support for old $replyto variable in post reply/quote $this->id = JRequest::getInt('replyto', 0); } $this->catid = JRequest::getInt('catid', 0); $this->msg_cat = null; $this->allow = 1; $this->cat_default_allow = null; $this->allow_topic_icons = null; $template = KunenaFactory::getTemplate(); $this->params = $template->params; $this->numLink = null; $this->replycount = null; }
protected function __construct($db, $config) { $this->_db = $db; $this->_my =& JFactory::getUser(); $this->_session = KunenaFactory::getSession(); $this->_allowed = $this->_session->allowed != '' ? explode(',', $this->_session->allowed) : array(); $this->_ResetErrorMessage(); $this->_config = $config; }
protected function __construct($db, $config) { $this->_db = $db; $this->_my = &JFactory::getUser (); $this->_me = KunenaUserHelper::getMyself(); $this->_session = KunenaFactory::getSession (); // FIXME: $this->_allowed = array(); $this->_ResetErrorMessage (); $this->_config = $config; }
function __construct($userid = null) { $this->_config = KunenaFactory::getConfig(); $this->_session = KunenaFactory::getSession(); $this->_db = JFactory::getDBO(); $this->_my = JFactory::getUser($userid); $this->_myuser = KunenaFactory::getUser($userid); $this->_app = JFactory::getApplication(); $this->setError('-load-', JText::_('COM_KUNENA_POSTING_NOT_LOADED')); }
protected function __construct($db, $config) { kimport('kunena.forum.category.helper'); $this->_db = $db; $this->_my = &JFactory::getUser (); $this->_me = KunenaFactory::getUser (); $this->_session = KunenaFactory::getSession (); // FIXME: $this->_allowed = array(); $this->_ResetErrorMessage (); $this->_config = $config; }
public function isNew() { static $readtopics = false; if (!KunenaFactory::getConfig()->shownew) { return false; } $session = KunenaFactory::getSession (); if (!$session->userid) return false; if ($readtopics === false) $readtopics = explode(',', $session->readtopics); return $this->time > $session->lasttime && !in_array($this->thread, $readtopics); }
function __construct($catid = null) { $this->_db = JFactory::getDBO(); $this->_my = JFactory::getUser(); $this->_session = KunenaFactory::getSession(); $this->_config = KunenaFactory::getConfig(); $this->_isimage = false; $this->_isfile = false; $me = KunenaUserHelper::getMyself(); $this->validImageExts = (array) KunenaForumMessageAttachmentHelper::getImageExtensions($catid, $me->userid); $this->validFileExts = (array) KunenaForumMessageAttachmentHelper::getFileExtensions($catid, $me->userid); $this->setImageResize(intval($this->_config->imagesize) * 1024, intval($this->_config->imagewidth), intval($this->_config->imageheight), intval($this->_config->imagequality)); }
public function __construct($params) { require_once KPATH_SITE . '/lib/kunena.link.class.php'; $this->params = $params; $this->type = $this->params->get('type', 'general'); $this->items = (int) $this->params->get('items', 5); // load Kunena main language file so we can leverage langaueg strings from it KunenaFactory::loadLanguage(); // Initialize session $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $this->api = Kunena::getStatsAPI(); }
function __construct($params) { // Include the syndicate functions only once require_once KUNENA_PATH . DS . 'class.kunena.php'; require_once KUNENA_PATH_LIB . DS . 'kunena.link.class.php'; require_once KUNENA_PATH_LIB . DS . 'kunena.image.class.php'; require_once KUNENA_PATH_LIB . DS . 'kunena.login.php'; require_once KUNENA_PATH_LIB . DS . 'kunena.timeformat.class.php'; $this->params = $params; // load Kunena main language file so we can leverage language strings from it KunenaFactory::loadLanguage(); // Initialize session $session = KunenaFactory::getSession(); $session->updateAllowedForums(); }
function __construct() { $this->_db = &JFactory::getDBO (); $this->_my = &JFactory::getUser (); $this->_session = &KunenaFactory::getSession (); $this->_config = KunenaFactory::getConfig (); $this->_isimage = false; $this->_isfile = false; $me = KunenaUserHelper::getMyself(); if (($me->isModerator()) || ($this->_my->id && $this->_config->allowimageregupload) || (!$this->_my->id && $this->_config->allowimageupload)) { $this->validImageExts = explode ( ',', $this->_config->imagetypes ); } if (($me->isModerator()) || ($this->_my->id && $this->_config->allowfileregupload) || (!$this->_my->id && $this->_config->allowfileupload)) { $this->validFileExts = explode ( ',', $this->_config->filetypes ); } $this->setImageResize(intval($this->_config->imagesize)*1024, intval($this->_config->imagewidth), intval($this->_config->imageheight), intval($this->_config->imagequality)); }
protected static function kunenaOnline() { // Kunena detection and version check $minKunenaVersion = '1.6.3'; if (!class_exists('Kunena') || Kunena::versionBuild() < 4344) { return false; } // Kunena online check if (!Kunena::enabled()) { return false; } // Initialize session $session = KunenaFactory::getSession(); $session->updateAllowedForums(); return true; }
public function __construct($params) { $this->document = JFactory::getDocument(); require_once KUNENA_PATH_LIB . '/kunena.link.class.php'; // Initialize session $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $this->ksearch_button = $params->get('ksearch_button', ''); $this->ksearch_button_pos = $params->get('ksearch_button_pos', 'right'); $this->ksearch_button_txt = $params->get('ksearch_button_txt', JText::_('Search')); $this->ksearch_width = intval($params->get('ksearch_width', 20)); $this->ksearch_maxlength = $this->ksearch_width > 20 ? $this->ksearch_width : 20; $this->ksearch_txt = $params->get('ksearch_txt', JText::_('Search...')); $this->ksearch_moduleclass_sfx = $params->get('moduleclass_sfx', ''); $this->params = $params; require JModuleHelper::getLayoutPath('mod_kunenasearch'); }
function markread() { $app = JFactory::getApplication (); if (! JRequest::checkToken ('request')) { $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $this->redirectBack (); } $catid = JRequest::getInt('catid', 0); if (!$catid) { // All categories $session = KunenaFactory::getSession(); $session->markAllCategoriesRead (); if (!$session->save ()) { $app->enqueueMessage ( JText::_('COM_KUNENA_ERROR_SESSION_SAVE_FAILED'), 'error' ); } else { $app->enqueueMessage ( JText::_('COM_KUNENA_GEN_ALL_MARKED') ); } } else { // One category $category = KunenaForumCategoryHelper::get($catid); if (!$category->authorise('read')) { $app->enqueueMessage ( $category->getError(), 'error' ); $this->redirectBack (); } $db = JFactory::getDBO(); $session = KunenaFactory::getSession(); if ($session->userid) { // Mark all unread topics in the category to read $readTopics = $session->readtopics; $db->setQuery ( "SELECT id FROM #__kunena_topics WHERE category_id={$db->quote($category->id)} AND id NOT IN ({$readTopics}) AND last_post_time>={$db->quote($session->lasttime)}" ); $readForum = $db->loadResultArray (); if (KunenaError::checkDatabaseError()) $this->redirectBack (); $readTopics = implode(',', array_merge(explode(',', $readTopics), $readForum)); $session->readtopics = $readTopics; if (!$session->save ()) { $app->enqueueMessage ( JText::_('COM_KUNENA_ERROR_SESSION_SAVE_FAILED'), 'error' ); } else { $app->enqueueMessage ( JText::_('COM_KUNENA_GEN_FORUM_MARKED') ); } } } $this->redirectBack (); }
function markread() { if (!JSession::checkToken('request')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $catid = JRequest::getInt('catid', 0); $children = JRequest::getBool('children', 0); if (!$catid) { // All categories $session = KunenaFactory::getSession(); $session->markAllCategoriesRead(); if (!$session->save()) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_SESSION_SAVE_FAILED'), 'error'); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_GEN_ALL_MARKED')); } } else { // One category $category = KunenaForumCategoryHelper::get($catid); if (!$category->authorise('read')) { $this->app->enqueueMessage($category->getError(), 'error'); $this->setRedirectBack(); return; } $session = KunenaFactory::getSession(); if ($session->userid) { $categories = array($category->id => $category); if ($children) { // Include all levels of child categories. $categories += $category->getChildren(-1); } // Mark all unread topics in selected categories as read. KunenaForumCategoryUserHelper::markRead(array_keys($categories)); if (count($categories) > 1) { $this->app->enqueueMessage(JText::_('COM_KUNENA_GEN_ALL_MARKED')); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_GEN_FORUM_MARKED')); } } } $this->setRedirectBack(); }
protected static function kunenaOnline() { // Kunena detection and version check $minKunenaVersion = '1.6.3'; if (!class_exists('Kunena') || Kunena::versionBuild() < 4344) { JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_COMMUNITY_KUNENAGROUPS_KUNENA_NOT_INSTALLED', $minKunenaVersion), 'notice'); return false; } // Kunena online check if (!Kunena::enabled()) { JFactory::getApplication()->enqueueMessage(JText::_('PLG_COMMUNITY_KUNENAGROUPS_KUNENA_OFFLINE'), 'notice'); return false; } // Initialize session $session = KunenaFactory::getSession(); $session->updateAllowedForums(); kimport('category'); return true; }
public function isNew($user = null) { $user = KunenaUserHelper::get($user); if (!KunenaFactory::getConfig()->shownew || !$user->exists()) { return false; } $session = KunenaFactory::getSession(); if ($this->time < $session->lasttime) { return false; } $allreadtime = KunenaForumCategoryUserHelper::get($this->getCategory(), $user)->allreadtime; if ($allreadtime && $this->time < JFactory::getDate($allreadtime)->toUnix()) { return false; } $read = KunenaForumTopicUserReadHelper::get($this->getTopic(), $user); if ($this->id == $read->message_id || $this->time < $read->time) { return false; } return true; }
function __construct($catid) { kimport('html.parser'); $this->catid = $catid; $this->db = JFactory::getDBO(); $this->my = JFactory::getUser(); $this->session = KunenaFactory::getSession(); $this->config = KunenaFactory::getConfig(); if ($this->catid && !$this->session->canRead($this->catid)) { return; } $this->allow = 1; $this->prevCheck = $this->session->lasttime; $kunena_app = JFactory::getApplication(); // Start getting the categories if ($this->catid) { $catlist = $this->catid; $where = ""; } else { $catlist = $this->session->allowed; $where = "parent='0' AND"; } $this->categories = array(); $this->db->setQuery("SELECT * FROM #__kunena_categories WHERE {$where} published='1' AND id IN ({$catlist}) ORDER BY ordering, name"); $this->categories[0] = $this->db->loadObjectList(); if (KunenaError::checkDatabaseError()) { return; } //meta description and keywords $metaDesc = JText::_('COM_KUNENA_CATEGORIES') . ' - ' . $this->config->board_title; $metaKeys = JText::_('COM_KUNENA_CATEGORIES') . ', ' . $this->config->board_title . ', ' . $kunena_app->getCfg('sitename'); $document = JFactory::getDocument(); $cur = $document->get('description'); $metaDesc = $cur . '. ' . $metaDesc; $document = JFactory::getDocument(); $document->setMetadata('keywords', $metaKeys); $document->setDescription($metaDesc); $template = KunenaFactory::getTemplate(); $this->params = $template->params; }
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')); }
function markread() { if (! JSession::checkToken ('request')) { $this->app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); $this->redirectBack (); } $catid = JRequest::getInt('catid', 0); if (!$catid) { // All categories $session = KunenaFactory::getSession(); $session->markAllCategoriesRead (); if (!$session->save ()) { $this->app->enqueueMessage ( JText::_('COM_KUNENA_ERROR_SESSION_SAVE_FAILED'), 'error' ); } else { $this->app->enqueueMessage ( JText::_('COM_KUNENA_GEN_ALL_MARKED') ); } } else { // One category $category = KunenaForumCategoryHelper::get($catid); if (!$category->authorise('read')) { $this->app->enqueueMessage ( $category->getError(), 'error' ); $this->redirectBack (); } $session = KunenaFactory::getSession(); if ($session->userid) { // Mark all unread topics in the category to read $userinfo = $category->getUserInfo(); // FIXME: Joomla 2.5 ->toSql() $userinfo->allreadtime = JFactory::getDate()->toSql(); if (!$userinfo->save()) { $this->app->enqueueMessage ( JText::_('COM_KUNENA_ERROR_SESSION_SAVE_FAILED'), 'error' ); } else { $this->app->enqueueMessage ( JText::_('COM_KUNENA_GEN_FORUM_MARKED') ); } } } $this->redirectBack (); }
public function testGetSession() { $instance = KunenaFactory::getSession(); $this->assertInstanceOf('KunenaSession', $instance); }
/** * Prepare category list display. * * @return void */ protected function before() { parent::before(); require_once KPATH_SITE . '/models/topics.php'; $this->model = new KunenaModelTopics(array(), $this->input); $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false)); $this->state = $this->model->getState(); $this->me = KunenaUserHelper::getMyself(); $this->moreUri = null; $this->embedded = $this->getOptions()->get('embedded', false); if ($this->embedded) { $this->moreUri = new JUri('index.php?option=com_kunena&view=topics&layout=posts&mode=' . $this->state->get('list.mode') . '&userid=' . $this->state->get('user') . '&sel=' . $this->state->get('list.time') . '&limit=' . $this->state->get('list.limit')); $this->moreUri->setVar('Itemid', KunenaRoute::getItemID($this->moreUri)); } $start = $this->state->get('list.start'); $limit = $this->state->get('list.limit'); // Handle &sel=x parameter. $time = $this->state->get('list.time'); if ($time < 0) { $time = null; } elseif ($time == 0) { $time = new JDate(KunenaFactory::getSession()->lasttime); } else { $time = new JDate(JFactory::getDate()->toUnix() - $time * 3600); } $userid = $this->state->get('user'); $user = is_numeric($userid) ? KunenaUserHelper::get($userid) : null; // Get categories for the filter. $categoryIds = $this->state->get('list.categories'); $reverse = !$this->state->get('list.categories.in'); $authorise = 'read'; $order = 'time'; $finder = new KunenaForumMessageFinder(); $finder->filterByTime($time); switch ($this->state->get('list.mode')) { case 'unapproved': $authorise = 'topic.post.approve'; $finder->filterByUser(null, 'author')->filterByHold(array(1)); break; case 'deleted': $authorise = 'topic.post.undelete'; $finder->filterByUser($user, 'author')->filterByHold(array(2, 3)); break; case 'mythanks': $finder->filterByUser($user, 'thanker')->filterByHold(array(0)); break; case 'thankyou': $finder->filterByUser($user, 'thankee')->filterByHold(array(0)); break; default: $finder->filterByUser($user, 'author')->filterByHold(array(0)); break; } $categories = KunenaForumCategoryHelper::getCategories($categoryIds, $reverse, $authorise); $finder->filterByCategories($categories); $this->pagination = new KunenaPagination($finder->count(), $start, $limit); if ($this->moreUri) { $this->pagination->setUri($this->moreUri); } $this->messages = $finder->order($order, -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find(); // Load topics... $topicIds = array(); foreach ($this->messages as $message) { $topicIds[(int) $message->thread] = (int) $message->thread; } $this->topics = KunenaForumTopicHelper::getTopics($topicIds, 'none'); $userIds = $mesIds = array(); foreach ($this->messages as $message) { $userIds[(int) $message->userid] = (int) $message->userid; $mesIds[(int) $message->id] = (int) $message->id; } if ($this->topics) { $this->prepareTopics($userIds, $mesIds); } switch ($this->state->get('list.mode')) { case 'unapproved': $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_UNAPPROVED'); $actions = array('approve', 'delete', 'permdelete'); break; case 'deleted': $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DELETED'); $actions = array('undelete', 'delete', 'permdelete'); break; case 'mythanks': $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_MYTHANKS'); $actions = array('approve', 'delete', 'permdelete'); break; case 'thankyou': $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_THANKYOU'); $actions = array('approve', 'delete', 'permdelete'); break; case 'recent': default: $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DEFAULT'); $actions = array('delete', 'permdelete'); } $this->actions = $this->getMessageActions($this->messages, $actions); }
protected function getRecentTopics() { $catid = $this->getState ( 'item.id' ); $limitstart = $this->getState ( 'list.start' ); $limit = $this->getState ( 'list.limit' ); $time = $this->getState ( 'list.time' ); if ($time < 0) { $time = 0; } elseif ($time == 0) { $time = KunenaFactory::getSession ()->lasttime; } else { $time = JFactory::getDate ()->toUnix () - ($time * 3600); } $latestcategory = $this->getState ( 'list.categories' ); $latestcategory_in = $this->getState ( 'list.categories.in' ); $hold = 0; $where = ''; $lastpost = true; switch ($this->getState ( 'list.mode' )) { case 'topics' : $lastpost = false; break; case 'sticky' : $where = 'AND tt.ordering>0'; break; case 'locked' : $where = 'AND tt.locked>0'; break; case 'noreplies' : $where = 'AND tt.posts=1'; break; case 'unapproved' : $allowed = KunenaForumCategoryHelper::getCategories(false, false, 'topic.approve'); if (empty($allowed)) { return array(0, array()); } $allowed = implode(',', array_keys($allowed)); $hold = '1'; $where = "AND tt.category_id IN ({$allowed})"; break; case 'deleted' : $allowed = KunenaForumCategoryHelper::getCategories(false, false, 'topic.undelete'); if (empty($allowed)) { return array(0, array()); } $allowed = implode(',', array_keys($allowed)); $hold = '2'; $where = "AND tt.category_id IN ({$allowed})"; break; case 'replies' : default : break; } $params = array ( 'reverse' => ! $latestcategory_in, 'orderby' => $lastpost ? 'tt.last_post_time DESC' : 'tt.first_post_time DESC', 'starttime' => $time, 'hold' => $hold, 'where' => $where ); list ( $this->total, $this->topics ) = KunenaForumTopicHelper::getLatestTopics ( $latestcategory, $limitstart, $limit, $params ); $this->_common (); }
/** * @param KunenaForumTopic[] $topics * @param mixed $user * * @return array */ public static function fetchNewStatus(array $topics, $user = null) { $user = KunenaUserHelper::get($user); if (!KunenaFactory::getConfig()->shownew || empty($topics) || !$user->exists()) { return array(); } $session = KunenaFactory::getSession(); $ids = array(); foreach ($topics as $topic) { if ($topic->last_post_time < $session->getAllReadTime()) { continue; } $allreadtime = $topic->getCategory()->getUserInfo()->allreadtime; if ($allreadtime && $topic->last_post_time < $allreadtime) { continue; } $ids[] = $topic->id; } if ($ids) { $idstr = implode(",", $ids); $db = JFactory::getDBO(); $db->setQuery("SELECT m.thread AS id, MIN(m.id) AS lastread, SUM(1) AS unread\r\n\t\t\t\tFROM #__kunena_messages AS m\r\n\t\t\t\tLEFT JOIN #__kunena_user_read AS ur ON ur.topic_id=m.thread AND user_id={$db->Quote($user->userid)}\r\n\t\t\t\tWHERE m.hold=0 AND m.moved=0 AND m.thread IN ({$idstr}) AND m.time>{$db->Quote($session->getAllReadTime())} AND (ur.time IS NULL OR m.time>ur.time)\r\n\t\t\t\tGROUP BY thread"); $topiclist = (array) $db->loadObjectList('id'); KunenaError::checkDatabaseError(); } $list = array(); foreach ($topics as $topic) { if (isset($topiclist[$topic->id])) { $topic->lastread = $topiclist[$topic->id]->lastread; $topic->unread = $topiclist[$topic->id]->unread; } else { $topic->lastread = $topic->last_post_id; $topic->unread = 0; } $list[$topic->id] = $topic->lastread; } return $list; }
/** * @param bool|array|int $categories * @param int $limitstart * @param int $limit * @param array $params * * @return array */ public static function getLatestMessages($categories = false, $limitstart = 0, $limit = 0, $params = array()) { $reverse = isset($params['reverse']) ? (int) $params['reverse'] : 0; $orderby = isset($params['orderby']) ? (string) $params['orderby'] : 'm.time DESC'; $starttime = isset($params['starttime']) ? (int) $params['starttime'] : 0; $mode = isset($params['mode']) ? $params['mode'] : 'recent'; $user = isset($params['user']) ? $params['user'] : false; $where = isset($params['where']) ? (string) $params['where'] : ''; $childforums = isset($params['childforums']) ? (bool) $params['childforums'] : false; $db = JFactory::getDBO(); // FIXME: use right config setting if ($limit < 1 && empty($params['nolimit'])) { $limit = KunenaFactory::getConfig()->threads_per_page; } $query = $db->getQuery(true); $query->select('m.*, t.message')->from('#__kunena_messages AS m')->innerJoin('#__kunena_messages_text AS t ON m.id = t.mesid')->where('m.moved=0')->order($orderby); $authorise = 'read'; $hold = 'm.hold=0'; $userfield = 'm.userid'; switch ($mode) { case 'unapproved': $authorise = 'approve'; $hold = "m.hold=1"; break; case 'deleted': $authorise = 'undelete'; $hold = "m.hold>=2"; break; case 'mythanks': $userfield = 'th.userid'; $query->innerJoin('#__kunena_thankyou AS th ON m.id = th.postid'); break; case 'thankyou': $userfield = 'th.targetuserid'; $query->innerJoin('#__kunena_thankyou AS th ON m.id = th.postid'); break; case 'recent': default: } if (is_array($categories) && in_array(0, $categories)) { $categories = false; } $categories = KunenaForumCategoryHelper::getCategories($categories, $reverse, 'topic.' . $authorise); if ($childforums) { $categories += KunenaForumCategoryHelper::getChildren($categories, -1, array('action' => 'topic.' . $authorise)); } $catlist = array(); foreach ($categories as $category) { $catlist += $category->getChannels(); } if (empty($catlist)) { return array(0, array()); } $allowed = implode(',', array_keys($catlist)); $query->where("m.catid IN ({$allowed})"); $query->where($hold); if ($user) { $query->where("{$userfield}={$db->Quote($user)}"); } // Negative time means no time if ($starttime == 0) { $starttime = KunenaFactory::getSession()->lasttime; } elseif ($starttime > 0) { $starttime = JFactory::getDate()->toUnix() - $starttime * 3600; } if ($starttime > 0) { $query->where("m.time>{$db->Quote($starttime)}"); } if ($where) { $query->where($where); } $cquery = clone $query; $cquery->clear('select')->clear('order')->select('COUNT(*)'); $db->setQuery($cquery); $total = (int) $db->loadResult(); if (KunenaError::checkDatabaseError() || !$total) { return array(0, array()); } // If out of range, use last page if ($limit && $total < $limitstart) { $limitstart = intval($total / $limit) * $limit; } $db->setQuery($query, $limitstart, $limit); $results = $db->loadAssocList(); if (KunenaError::checkDatabaseError()) { return array(0, array()); } $messages = array(); foreach ($results as $result) { $instance = new KunenaForumMessage($result); $instance->exists(true); self::$_instances[$instance->id] = $instance; $messages[$instance->id] = $instance; } unset($results); return array($total, $messages); }
JLog::add("Kunena: spoofed access denied: " . JUri::getInstance()->toString(array('path', 'query')), JLog::WARNING, 'kunena'); JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); } } // Load router require_once KPATH_SITE . '/router.php'; // Initialize Kunena Framework. KunenaForum::setup(); // Initialize custom error handlers. KunenaError::initialize(); // Initialize session. $ksession = KunenaFactory::getSession(true); if ($ksession->userid > 0) { // Create user if it does not exist $kuser = KunenaUserHelper::getMyself(); if (!$kuser->exists()) { $kuser->save(); } // Save session if (!$ksession->save()) { JFactory::getApplication()->enqueueMessage(JText::_('COM_KUNENA_ERROR_SESSION_SAVE_FAILED'), 'error'); } }
function plgContentKunenaDiscuss(&$subject, $params) { $this->_app = JFactory::getApplication ( 'site' ); // If plugin is not enabled in current scope, do not register it if (! $this->enabled ()) return null; $jversion = new JVersion(); if ($jversion->RELEASE != '1.5') { $this->basepath = 'plugins/content/kunenadiscuss'; } else { $this->basepath = 'plugins/content'; } // Load language files $this->loadLanguage ( 'plg_content_kunenadiscuss', JPATH_ADMINISTRATOR ); // Kunena detection and version check $minKunenaVersion = '1.6.3'; if (!class_exists('Kunena') || Kunena::versionBuild() < 4344) { $this->_app->enqueueMessage( JText::sprintf ( 'PLG_KUNENADISCUSS_DEPENDENCY_FAIL', $minKunenaVersion ) ); return null; } // Kunena online check if (!Kunena::enabled()) { return null; } // Initialize session $session = KunenaFactory::getSession (); $session->updateAllowedForums(); // Initialize plugin parent::__construct ( $subject, $params ); // Initialize variables $this->_db = JFactory::getDbo (); $this->_my = JFactory::getUser (); require_once (KUNENA_PATH . DS . 'class.kunena.php'); $this->config = KunenaFactory::getConfig (); // load Kunena main language file so we can leverage language strings from it KunenaFactory::loadLanguage(); // Create plugin table if doesn't exist $query = "SHOW TABLES LIKE '{$this->_db->getPrefix()}kunenadiscuss'"; $this->_db->setQuery ( $query ); if (!$this->_db->loadResult ()) { CKunenaTools::checkDatabaseError (); $query = "CREATE TABLE IF NOT EXISTS `#__kunenadiscuss` (`content_id` int(11) NOT NULL default '0', `thread_id` int(11) NOT NULL default '0', PRIMARY KEY (`content_id`) )"; $this->_db->setQuery ( $query ); $this->_db->query (); CKunenaTools::checkDatabaseError (); $this->debug ( "Created #__kunenadiscuss cross reference table." ); // Migrate data from old FireBoard discussbot if it exists $query = "SHOW TABLES LIKE '{$this->_db->getPrefix()}fb_discussbot'"; $this->_db->setQuery ( $query ); if ($this->_db->loadResult ()) { $query = "REPLACE INTO `#__kunenadiscuss` SELECT `content_id` , `thread_id` FROM `#__fb_discussbot`"; $this->_db->setQuery ( $query ); $this->_db->query (); CKunenaTools::checkDatabaseError (); $this->debug ( "Migrated old data." ); } } $this->debug ( "Constructor called in " . $this->_app->scope ); }