Exemplo n.º 1
0
 /**
  * Prepare topic list for moderators.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $this->me = KunenaUserHelper::getMyself();
     $access = KunenaAccess::getInstance();
     $this->moreUri = null;
     $params = $this->app->getParams('com_kunena');
     $start = $this->input->getInt('limitstart', 0);
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = $this->config->threads_per_page;
     }
     // Get configuration from menu item.
     $categoryIds = $params->get('topics_categories', array());
     $reverse = !$params->get('topics_catselection', 1);
     // Make sure that category list is an array.
     if (!is_array($categoryIds)) {
         $categoryIds = explode(',', $categoryIds);
     }
     if (!$reverse && empty($categoryIds) || in_array(0, $categoryIds)) {
         $categoryIds = false;
     }
     $categories = KunenaForumCategoryHelper::getCategories($categoryIds, $reverse);
     $finder = new KunenaForumTopicFinder();
     $finder->filterByCategories($categories)->filterAnsweredBy(array_keys($access->getModerators() + $access->getAdmins()), true)->filterByMoved(false)->where('locked', '=', 0);
     $this->pagination = new KunenaPagination($finder->count(), $start, $limit);
     if ($this->moreUri) {
         $this->pagination->setUri($this->moreUri);
     }
     $this->topics = $finder->order('last_post_time', -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
     if ($this->topics) {
         $this->prepareTopics();
     }
     $actions = array('delete', 'approve', 'undelete', 'move', 'permdelete');
     $this->actions = $this->getTopicActions($this->topics, $actions);
     // TODO <-
     $this->headerText = JText::_('Topics Needing Attention');
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
	/**
	 * Prepare user's topic list.
	 *
	 * @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=user&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));
		}

		$user = KunenaUserHelper::get($this->state->get('user'));

		// Get categories for the filter.
		$categoryIds = $this->state->get('list.categories');
		$reverse = !$this->state->get('list.categories.in');
		$authorise = 'read';
		$order = 'last_post_time';

		$finder = new KunenaForumTopicFinder;
		$finder
			->filterByMoved(false)
			->filterByHold(array(0))
			->filterByTime($time);

		switch ($this->state->get('list.mode'))
		{
			case 'posted' :
				$finder
					->filterByUser($user, 'posted')
					->order('last_post_id', -1, 'ut');
				break;

			case 'started' :
				$finder->filterByUser($user, 'owner');
				break;

			case 'favorites' :
				$finder->filterByUser($user, 'favorited');
				break;

			case 'subscriptions' :
				$finder->filterByUser($user, 'subscribed');
				break;

			default :
				$finder
					->filterByUser($user, 'involved')
					->order('favorite', -1, 'ut');
				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->topics = $finder
			->order($order, -1)
			->start($this->pagination->limitstart)
			->limit($this->pagination->limit)
			->find();

		if ($this->topics)
		{
			$this->prepareTopics();
		}

		$actions = array('delete', 'approve', 'undelete', 'move', 'permdelete');

		switch ($this->state->get('list.mode'))
		{
			case 'posted' :
				$this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_USERS_MODE_POSTED');
				break;
			case 'started' :
				$this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_USERS_MODE_STARTED');
				break;
			case 'favorites' :
				$this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_USERS_MODE_FAVORITES');
				$actions = array('unfavorite');
				break;
			case 'subscriptions' :
				$this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_USERS_MODE_SUBSCRIPTIONS');
				$actions = array('unsubscribe');
				break;
			case 'plugin' :
				$this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_USERS_MODE_PLUGIN_' . strtoupper($this->state->get('list.modetype')));
				break;
			default :
				$this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_USERS_MODE_DEFAULT');
		}

		$this->actions = $this->getTopicActions($this->topics, $actions);
	}
Exemplo n.º 4
0
 /**
  * Prepare recent topics list.
  *
  * @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);
     $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);
     }
     // Get categories for the filter.
     $categoryIds = $this->state->get('list.categories');
     $reverse = !$this->state->get('list.categories.in');
     $authorise = 'read';
     $order = 'last_post_time';
     $finder = new KunenaForumTopicFinder();
     $finder->filterByMoved(false);
     switch ($this->state->get('list.mode')) {
         case 'topics':
             $order = 'first_post_time';
             $finder->filterByHold(array(0))->filterByTime($time, null, false);
             break;
         case 'sticky':
             $finder->filterByHold(array(0))->where('a.ordering', '>', 0)->filterByTime($time);
             break;
         case 'locked':
             $finder->filterByHold(array(0))->where('a.locked', '>', 0)->filterByTime($time);
             break;
         case 'noreplies':
             $finder->filterByHold(array(0))->where('a.posts', '=', 1)->filterByTime($time);
             break;
         case 'unapproved':
             $authorise = 'topic.approve';
             $finder->filterByHold(array(1))->filterByTime($time);
             break;
         case 'deleted':
             $authorise = 'topic.undelete';
             $finder->filterByHold(array(2, 3))->filterByTime($time);
             break;
         case 'replies':
         default:
             $finder->filterByHold(array(0))->filterByTime($time);
             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->topics = $finder->order($order, -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
     if ($this->topics) {
         $this->prepareTopics();
     }
     $actions = array('delete', 'approve', 'undelete', 'move', 'permdelete');
     switch ($this->state->get('list.mode')) {
         case 'topics':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_TOPICS');
             break;
         case 'sticky':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_STICKY');
             break;
         case 'locked':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_LOCKED');
             break;
         case 'noreplies':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_NOREPLIES');
             break;
         case 'unapproved':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_UNAPPROVED');
             break;
         case 'deleted':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_DELETED');
             break;
         case 'replies':
         default:
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_DEFAULT_MODE_DEFAULT');
     }
     $this->actions = $this->getTopicActions($this->topics, $actions);
 }