예제 #1
0
 /**
  * Prepare category display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     require_once KPATH_SITE . '/models/category.php';
     $this->model = new KunenaModelCategory();
     $this->me = KunenaUserHelper::getMyself();
     $catid = $this->input->getInt('catid');
     $limitstart = $this->input->getInt('limitstart', 0);
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = $this->config->threads_per_page;
     }
     // TODO:
     $direction = 'DESC';
     $this->category = KunenaForumCategoryHelper::get($catid);
     $this->category->tryAuthorise();
     $this->headerText = JText::_('COM_KUNENA_THREADS_IN_FORUM') . ': ' . $this->category->name;
     $topic_ordering = $this->category->topic_ordering;
     $access = KunenaAccess::getInstance();
     $hold = $access->getAllowedHold($this->me, $catid);
     $moved = 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 ' . $direction;
             break;
         case 'lastpost':
         default:
             $params['orderby'] = 'tt.ordering DESC, tt.last_post_time ' . $direction;
     }
     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();
         $lastpostlist = 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 ($lastreadlist || $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) {
             KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist);
         }
     }
     $this->topicActions = $this->model->getTopicActions();
     $this->actionMove = $this->model->getActionMove();
     $this->pagination = new KunenaPagination($this->total, $limitstart, $limit);
     $this->pagination->setDisplayedPages(5);
 }
예제 #2
0
	/**
	 * Method to get the options of the topic
	 *
	 * @return array
	 */
	public function getTopicOptions()
	{
		$options = array();

		// Start with default options.
		if (!$this->message)
		{
			$options[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_MODERATION_MOVE_TOPIC'));
		}
		else
		{
			$options[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_MODERATION_CREATE_TOPIC'));
		}

		$options[] = JHtml::_('select.option', -1, JText::_('COM_KUNENA_MODERATION_ENTER_TOPIC'));

		// Then list a few topics.
		$db     = JFactory::getDbo();
		$params = array(
			'orderby' => 'tt.last_post_time DESC',
			'where'   => " AND tt.id != {$db->Quote($this->topic->id)} ");
		list ($total, $topics) = KunenaForumTopicHelper::getLatestTopics($this->category->id, 0, 30, $params);

		foreach ($topics as $topic)
		{
			$options[] = JHtml::_('select.option', $topic->id, $this->escape($topic->subject));
		}

		return $options;
	}
	/**
	 * Test getTopics()
	 */
	public function testGetTopics() {
		list($count, $topics) = KunenaForumTopicHelper::getLatestTopics(false, 0, 20);
		$topicusers = KunenaForumTopicUserHelper::getTopics($topics);
		foreach ($topics as $topic) {
			$this->assertTrue(isset($topicusers[$topic->id]));
			$this->assertEquals($topic->id, $topicusers[$topic->id]->topic_id);
		}
	}
	/**
	 * Test new KunenaForumTopicUser()
	 */
	public function testNew() {
		$admin = KunenaFactory::getUser('admin');
		list($count, $topics) = KunenaForumTopicHelper::getLatestTopics(false, 0, 1);
		self::$topic = reset($topics);
		$topicuser = new KunenaForumTopicUser(self::$topic->id, $admin);
		$this->assertInstanceOf('KunenaForumTopicUser', $topicuser);
		$this->assertFalse($topicuser->exists());
		$this->assertEquals(self::$topic->id, $topicuser->topic_id);
		$this->assertEquals($admin->userid, $topicuser->user_id);
	}
예제 #5
0
파일: prune.php 프로젝트: rich20/Kunena
	function doprune() {
		$app = JFactory::getApplication ();
		if (!JRequest::checkToken()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}
		$category = KunenaForumCategoryHelper::get(JRequest::getInt ( 'prune_forum', 0 ));
		if (!$category->authorise('admin')) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_CHOOSEFORUMTOPRUNE' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}

		// Convert days to seconds for timestamp functions...
		$prune_days = JRequest::getInt ( 'prune_days', 36500 );
		$prune_date = JFactory::getDate()->toUnix() - ($prune_days * 86400);

		$trashdelete = JRequest::getInt( 'trashdelete', 0);

		// Get up to 100 oldest topics to be deleted
		$params = array(
			'orderby'=>'tt.last_post_time ASC',
			'where'=>"AND tt.last_post_time<{$prune_date} AND ordering=0",
		);
		list($count, $topics) = KunenaForumTopicHelper::getLatestTopics($category->id, 0, 100, $params);
		$deleted = 0;
		foreach ( $topics as $topic ) {
			$deleted++;
			if ( $trashdelete ) $topic->delete(false);
			else $topic->trash();
		}
		KunenaUserHelper::recount();
		KunenaForumCategoryHelper::recount();
		KunenaForumMessageAttachmentHelper::cleanup();
		if ( $trashdelete ) $app->enqueueMessage ( "" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNEDELETED') . " {$deleted}/{$count} " . JText::_('COM_KUNENA_PRUNETHREADS') );
		else $app->enqueueMessage ( "" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNETRASHED') . " {$deleted}/{$count} " . JText::_('COM_KUNENA_PRUNETHREADS') );
		$this->setRedirect(KunenaRoute::_($this->baseurl, false));
	}
예제 #6
0
파일: trash.php 프로젝트: rich20/Kunena
	/**
	 * Method to get all deleted topics.
	 *
	 * @return	Array
	 * @since	1.6
	 */
	public function getTopicsItems() {
		/*$db = JFactory::getDBO ();
		$where = '';
		if ($this->getState ( 'list.search')) {
			$where = ' AND LOWER( subject ) LIKE '.$db->Quote( '%'.$db->getEscaped( $this->getState ( 'list.search'), true ).'%', false ).' OR LOWER( username )LIKE '.$db->Quote( '%'.$db->getEscaped( $this->getState ( 'list.search'), true ).'%', false ).' OR id LIKE '.$db->Quote( '%'.$db->getEscaped( $this->getState ( 'list.search'), true ).'%', false );
		}*/

		$cats = KunenaForumCategoryHelper::getCategories();
		$cats_array =array();
		foreach ($cats as $cat) {
			if ( $cat->id ) $cats_array[] = $cat->id;
		}
		list($total,$topics) = KunenaForumTopicHelper::getLatestTopics ( $cats_array, $this->getState('list.start'), $this->getState('list.limit'), array ('hold' => '2,3') );
		$this->setState ( 'list.total', $total );

		return $topics;
	}
예제 #7
0
파일: topics.php 프로젝트: rich20/Kunena
	protected function getUserTopics() {
		$catid = $this->getState ( 'item.id' );
		$limitstart = $this->getState ( 'list.start' );
		$limit = $this->getState ( 'list.limit' );

		$latestcategory = $this->getState ( 'list.categories' );
		$latestcategory_in = $this->getState ( 'list.categories.in' );

		$started = false;
		$posts = false;
		$favorites = false;
		$subscriptions = false;
		// Set order by
		$orderby = "tt.last_post_time DESC";
		switch ($this->getState ( 'list.mode' )) {
			case 'posted' :
				$posts = true;
				$orderby = "ut.last_post_id DESC";
				break;
			case 'started' :
				$started = true;
				break;
			case 'favorites' :
				$favorites = true;
				break;
			case 'subscriptions' :
				$subscriptions = true;
				break;
			default :
				$posts = true;
				$favorites = true;
				$subscriptions = true;
				$orderby = "ut.favorite DESC, tt.last_post_time DESC";
				break;
		}

		$params = array (
			'reverse' => ! $latestcategory_in,
			'orderby' => $orderby,
			'hold' => 0,
			'user' => $this->getState ( 'user' ),
			'started' => $started,
			'posted' => $posts,
			'favorited' => $favorites,
			'subscribed' => $subscriptions );

		list ( $this->total, $this->topics ) = KunenaForumTopicHelper::getLatestTopics ( $latestcategory, $limitstart, $limit, $params );
		$this->_common ();
	}
예제 #8
0
 protected function displayModerate($tpl = null)
 {
     $this->mesid = JRequest::getInt('mesid', 0);
     $this->id = $this->state->get('item.id');
     $this->catid = $this->state->get('item.catid');
     if ($this->config->topicicons) {
         $this->topicIcons = $this->ktemplate->getTopicIcons(false);
     }
     if (!$this->mesid) {
         $this->topic = KunenaForumTopicHelper::get($this->id);
         if (!$this->topic->authorise('move')) {
             $this->app->enqueueMessage($this->topic->getError(), 'notice');
             return;
         }
     } else {
         $this->message = KunenaForumMessageHelper::get($this->mesid);
         if (!$this->message->authorise('move')) {
             $this->app->enqueueMessage($this->message->getError(), 'notice');
             return;
         }
         $this->topic = $this->message->getTopic();
     }
     $this->category = $this->topic->getCategory();
     $options = array();
     if (!$this->mesid) {
         $options[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_MODERATION_MOVE_TOPIC'));
     } else {
         $options[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_MODERATION_CREATE_TOPIC'));
     }
     $options[] = JHtml::_('select.option', -1, JText::_('COM_KUNENA_MODERATION_ENTER_TOPIC'));
     $db = JFactory::getDBO();
     $params = array('orderby' => 'tt.last_post_time DESC', 'where' => " AND tt.id != {$db->Quote($this->topic->id)} ");
     list($total, $topics) = KunenaForumTopicHelper::getLatestTopics($this->catid, 0, 30, $params);
     foreach ($topics as $cur) {
         $options[] = JHtml::_('select.option', $cur->id, $this->escape($cur->subject));
     }
     $this->topiclist = JHtml::_('select.genericlist', $options, 'targettopic', 'class="inputbox"', 'value', 'text', 0, 'kmod_topics');
     $options = array();
     $cat_params = array('sections' => 0, 'catid' => 0);
     $this->categorylist = JHtml::_('kunenaforum.categorylist', 'targetcategory', 0, $options, $cat_params, 'class="inputbox kmove_selectbox"', 'value', 'text', $this->catid, 'kmod_categories');
     if (isset($this->message)) {
         $this->user = KunenaFactory::getUser($this->message->userid);
         $username = $this->message->getAuthor()->getName();
         $this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null;
     }
     if ($this->mesid) {
         // Get thread and reply count from current message:
         $query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->mesid)}";
         $db->setQuery($query, 0, 1);
         $this->replies = $db->loadResult();
         if (KunenaError::checkDatabaseError()) {
             return;
         }
     }
     $this->render('Topic/Moderate', $tpl);
 }
예제 #9
0
 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);
 }
예제 #10
0
파일: category.php 프로젝트: madcsaba/li-de
 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 = KunenaAccess::getInstance();
         $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();
             $lastpostlist = 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->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus())) {
                 KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist);
             }
         }
     }
     return $this->topics;
 }
예제 #11
0
	/**
	 * @return array
	 */
	public function topics()
	{
		$options			=	array();

		if ( $this->installed() ) {
			$rows			=	KunenaForumTopicHelper::getLatestTopics();

			if ( $rows[1] ) foreach ( $rows[1] as $row ) {
				$options[]	=	moscomprofilerHTML::makeOption( (string) $row->id, $row->subject );
			}
		}

		return $options;
	}
예제 #12
0
파일: view.html.php 프로젝트: rich20/Kunena
	protected function displayModerate($tpl = null) {
		$this->mesid = JRequest::getInt('mesid', 0);
		$this->id = $this->state->get('item.id');
		$this->catid = $this->state->get('item.catid');
		$this->config = KunenaFactory::getConfig();
		$app = JFactory::getApplication();

		if (!$this->mesid) {
			$this->topic = KunenaForumTopicHelper::get($this->id);
			if (!$this->topic->authorise('move')) {
				$app->enqueueMessage ( $this->topic->getError(), 'notice' );
				return;
			}
		} else {
			$this->message = KunenaForumMessageHelper::get($this->mesid);
			if (!$this->message->authorise('move')) {
				$app->enqueueMessage ( $this->message->getError(), 'notice' );
				return;
			}
			$this->topic = $this->message->getTopic();
		}
		$this->category = $this->topic->getCategory();

		$options =array ();
		if (!$this->mesid) {
			$options [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_MODERATION_MOVE_TOPIC' ) );
		} else {
			$options [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_MODERATION_CREATE_TOPIC' ) );
		}
		$options [] = JHTML::_ ( 'select.option', -1, JText::_ ( 'COM_KUNENA_MODERATION_ENTER_TOPIC' ) );

		$db = JFactory::getDBO();
		$params = array(
			'orderby'=>'tt.last_post_time DESC',
			'where'=>" AND tt.id != {$db->Quote($this->topic->id)} ");
		list ($total, $topics) = KunenaForumTopicHelper::getLatestTopics($this->catid, 0, 30, $params);
		foreach ( $topics as $cur ) {
			$options [] = JHTML::_ ( 'select.option', $cur->id, $this->escape ( $cur->subject ) );
		}
		$this->topiclist = JHTML::_ ( 'select.genericlist', $options, 'targettopic', 'class="inputbox"', 'value', 'text', 0, 'kmod_topics' );

		$options = array ();
		$cat_params = array ('sections'=>0, 'catid'=>0);
		$this->assignRef ( 'categorylist', JHTML::_('kunenaforum.categorylist', 'targetcategory', 0, $options, $cat_params, 'class="inputbox kmove_selectbox"', 'value', 'text', $this->catid, 'kmod_categories'));
		if (isset($this->message)) $this->user = KunenaFactory::getUser($this->message->userid);

		if ($this->mesid) {
			// Get thread and reply count from current message:
			$query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m
				INNER JOIN #__kunena_messages AS t ON m.thread=t.id
				LEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.id > m.id
				WHERE m.id={$db->Quote($this->mesid)}";
			$db->setQuery ( $query, 0, 1 );
			$this->replies = $db->loadResult ();
			if (KunenaError::checkDatabaseError()) return;
		}

		$this->display($tpl);
	}
예제 #13
0
 /**
  * Un-subscribe from a topic
  *
  * @param  string|int   $postid  Forum Post id
  * @param  UserTable    $user    Viewed at User
  * @param  PluginTable  $plugin  Current Plugin
  * @return boolean               Result
  */
 public static function unSubscribe($postid, $user, $plugin)
 {
     if (!class_exists('KunenaForumTopicHelper')) {
         return false;
     }
     if ($postid == 'all') {
         $topics = KunenaForumTopicHelper::getLatestTopics(false, 0, 0, array('user' => (int) $user->id, 'subscribed' => true));
         $ids = array_keys(array_pop($topics));
     } else {
         $ids = array((int) $postid);
     }
     if (!$ids || !KunenaForumTopicHelper::subscribe($ids, 0, (int) $user->id)) {
         return false;
     }
     return true;
 }
예제 #14
0
 /**
  * @param XmapDisplayerInterface $xmap
  * @param stdClass $parent
  * @param array $params
  * @param int $catid
  */
 private static function getTopics($xmap, stdClass $parent, array &$params, $catid)
 {
     self::getCategoryTree($xmap, $parent, $params, $catid);
     if (!$params['include_topics']) {
         return;
     }
     /** @var KunenaForumTopic[] $topics */
     $topics = KunenaForumTopicHelper::getLatestTopics($catid, 0, $params['limit'], array('nolimit' => true, 'starttime' => $params['days']));
     $topics = $topics[1];
     if (empty($topics)) {
         return;
     }
     $xmap->changeLevel(1);
     foreach ($topics as $topic) {
         $node = new stdClass();
         $node->id = $parent->id;
         $node->browserNav = $parent->browserNav;
         $node->uid = $parent->uid . '_t_' . $topic->id;
         $node->name = $topic->subject;
         $node->priority = $params['topic_priority'];
         $node->changefreq = $params['topic_changefreq'];
         $node->modified = $topic->last_post_time;
         $node->link = 'index.php?option=com_kunena&view=topic&catid=' . $topic->category_id . '&id=' . $topic->id;
         $node->secure = $parent->secure;
         if ($xmap->printNode($node) && $params['include_pagination']) {
             $msgPerPage = KunenaFactory::getConfig()->get('messages_per_page');
             $threadPages = ceil($topic->getTotal() / $msgPerPage);
             if ($threadPages > 1) {
                 $xmap->changeLevel(1);
                 for ($i = 2; $i <= $threadPages; $i++) {
                     $subnode = new stdClass();
                     $subnode->id = $node->id;
                     $subnode->uid = $node->uid . '_p_' . $i;
                     $subnode->name = '[' . $i . ']';
                     $subnode->link = $node->link . '&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);
             }
         }
     }
     $xmap->changeLevel(-1);
 }
 /**
  * Puts users subscription posts into object
  *
  * @param moscomprofilerUser $user
  * @param object             $forum
  * @return object
  */
 function getUserFavorites($user, $forum)
 {
     global $_CB_database;
     $pagingParams = $this->_getPaging(array(), array('ffavs_'));
     $postsNumber = $this->params->get('postsNumber', 10);
     if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) {
         switch ($pagingParams['ffavs_sortby']) {
             case 'subjectASC':
                 $order = 'a.' . $_CB_database->NameQuote('subject') . ' ASC';
                 break;
             case 'subjectDESC':
                 $order = 'a.' . $_CB_database->NameQuote('subject') . ' DESC';
                 break;
             case 'categoryASC':
                 $order = 'b.' . $_CB_database->NameQuote('id') . ' ASC';
                 break;
             case 'categoryDESC':
                 $order = 'b.' . $_CB_database->NameQuote('id') . ' DESC';
                 break;
             case 'dateASC':
                 $order = 'a.' . $_CB_database->NameQuote('time') . ' ASC';
                 break;
             case 'dateDESC':
             default:
                 $order = 'a.' . $_CB_database->NameQuote('time') . ' DESC';
                 break;
         }
         $query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote('name') . ' AS catname' . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages') . ' AS a' . ', ' . $_CB_database->NameQuote('#__' . $forum->prefix . '_categories') . ' AS b' . ', ' . $_CB_database->NameQuote('#__' . $forum->prefix . '_favorites') . ' AS s' . "\n WHERE a." . $_CB_database->NameQuote('id') . ' = s.' . $_CB_database->NameQuote('thread') . "\n AND a." . $_CB_database->NameQuote('catid') . ' = b.' . $_CB_database->NameQuote('id') . "\n AND s." . $_CB_database->NameQuote('userid') . ' = ' . (int) $user->id . "\n ORDER BY " . $order;
         $_CB_database->setQuery($query, (int) ($pagingParams['ffavs_limitstart'] ? $pagingParams['ffavs_limitstart'] : 0), (int) $postsNumber);
         $favs = $_CB_database->loadObjectList();
     } elseif (class_exists('KunenaForumTopicHelper')) {
         switch ($pagingParams['ffavs_sortby']) {
             case 'subjectASC':
                 $order = 'tt.' . $_CB_database->NameQuote('subject') . ' ASC';
                 break;
             case 'subjectDESC':
                 $order = 'tt.' . $_CB_database->NameQuote('subject') . ' DESC';
                 break;
             case 'categoryASC':
                 $order = 'tt.' . $_CB_database->NameQuote('category_id') . ' ASC';
                 break;
             case 'categoryDESC':
                 $order = 'tt.' . $_CB_database->NameQuote('category_id') . ' DESC';
                 break;
             case 'dateASC':
                 $order = 'tt.' . $_CB_database->NameQuote('first_post_time') . ' ASC';
                 break;
             case 'dateDESC':
             default:
                 $order = 'tt.' . $_CB_database->NameQuote('first_post_time') . ' DESC';
                 break;
         }
         $params = array('user' => (int) $user->id, 'favorited' => true, 'starttime' => -1, 'orderby' => $order);
         $favs = array_pop(KunenaForumTopicHelper::getLatestTopics(false, (int) ($pagingParams['ffavs_limitstart'] ? $pagingParams['ffavs_limitstart'] : 0), (int) $postsNumber, $params));
         if ($favs) {
             foreach ($favs as $k => $fav) {
                 $favs[$k]->set('time', $fav->first_post_time);
                 $favs[$k]->set('catid', $fav->getCategory()->id);
                 $favs[$k]->set('catname', $fav->getCategory()->name);
                 $favs[$k]->set('thread', $fav->id);
             }
         }
     } else {
         $favs = null;
     }
     return $favs ? $favs : null;
 }
예제 #16
0
 /**
  * @param int $limit
  *
  * @return array|KunenaForumTopic[]
  */
 public function loadTopTopics($limit = 0)
 {
     $limit = $limit ? $limit : $this->_config->popsubjectcount;
     if (count($this->topTopics) < $limit) {
         $params = array('orderby' => 'posts DESC');
         list($total, $this->topTopics) = KunenaForumTopicHelper::getLatestTopics(false, 0, $limit, $params);
         $top = reset($this->topTopics);
         if (!$top) {
             return array();
         }
         $top->title = JText::_('COM_KUNENA_LIB_STAT_TOP_TOPICS');
         $top->titleName = JText::_('COM_KUNENA_GEN_SUBJECT');
         $top->titleCount = JText::_('COM_KUNENA_USRL_POSTS');
         foreach ($this->topTopics as &$item) {
             $item = clone $item;
             $item->count = $item->posts;
             $item->link = JHtml::_('kunenaforum.link', $item->getUri(), KunenaHtmlParser::parseText($item->subject));
             $item->percent = round(100 * $item->count / $top->posts);
         }
     }
     return array_slice($this->topTopics, 0, $limit);
 }
예제 #17
0
 /**
  * Method to get all deleted topics.
  *
  * @return	Array
  * @since	1.6
  */
 protected function _getTopicsItems()
 {
     $db = JFactory::getDBO();
     $where = '';
     if ($this->getState('list.search')) {
         $where = '(tt.subject LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ' OR tt.first_post_userid LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ' OR tt.id LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ')';
     }
     $orderby = '';
     $ordering = $this->state->get('list.ordering');
     if (!empty($ordering)) {
         $orderby = $this->state->get('list.ordering') . ' ' . $this->state->get('list.direction');
     } else {
         $orderby = 'tt.id ' . $this->state->get('list.direction');
     }
     $params = array('hold' => '2,3', 'orderby' => $orderby, 'where' => $where);
     $cats = KunenaForumCategoryHelper::getCategories();
     $cats_array = array();
     foreach ($cats as $cat) {
         if ($cat->id) {
             $cats_array[] = $cat->id;
         }
     }
     list($total, $topics) = KunenaForumTopicHelper::getLatestTopics($cats_array, $this->getState('list.start'), $this->getState('list.limit'), $params);
     $this->setState('list.total', $total);
     return $topics;
 }