Example #1
0
	public function getLastestCategories() {
		if ( $this->items === false ) {
			$this->items = array();
			$user = KunenaFactory::getUser();
			list($total,$categories) = KunenaForumCategoryHelper::getLatestSubscriptions($user->userid);
			$this->items = $categories;
		}
		return $this->items;
	}
Example #2
0
 /**
  * Prepare category subscriptions display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $me = KunenaUserHelper::getMyself();
     if (!$me->exists()) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
     }
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = 20;
     }
     $limitstart = $this->input->getInt('limitstart', 0);
     if ($limitstart < 0) {
         $limitstart = 0;
     }
     list($total, $this->categories) = KunenaForumCategoryHelper::getLatestSubscriptions($me->userid);
     $topicIds = array();
     $userIds = array();
     $postIds = array();
     foreach ($this->categories as $category) {
         // Get list of topics.
         if ($category->last_topic_id) {
             $topicIds[$category->last_topic_id] = $category->last_topic_id;
         }
     }
     // Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
     $topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
     // Pre-fetch users (and get last post ids for moderators).
     foreach ($topics as $topic) {
         $userIds[$topic->last_post_userid] = $topic->last_post_userid;
         $postIds[$topic->id] = $topic->last_post_id;
     }
     KunenaUserHelper::loadUsers($userIds);
     KunenaForumMessageHelper::getMessages($postIds);
     // Pre-fetch user related stuff.
     if ($me->exists() && !$me->isBanned()) {
         // Load new topic counts.
         KunenaForumCategoryHelper::getNewTopics(array_keys($this->categories));
     }
     $this->actions = $this->getActions();
     $this->pagination = new JPagination($total, $limitstart, $limit);
     $this->headerText = JText::_('COM_KUNENA_CATEGORY_SUBSCRIPTIONS');
 }
Example #3
0
 /**
  * Un-subscribe from a category
  *
  * @param  string|int   $catid   Forum Category id
  * @param  UserTable    $user    Viewed at User
  * @param  PluginTable  $plugin  Current Plugin
  * @return boolean               Result
  */
 public static function unSubscribeCategory($catid, $user, $plugin)
 {
     if (!class_exists('KunenaForumCategoryHelper')) {
         return false;
     }
     if ($catid == 'all') {
         $categories = KunenaForumCategoryHelper::getLatestSubscriptions((int) $user->id, 0, 0);
         $ids = array_keys(array_pop($categories));
     } else {
         $ids = array((int) $catid);
     }
     if (!$ids || !KunenaForumCategoryHelper::subscribe($ids, 0, (int) $user->id)) {
         return false;
     }
     return true;
 }
Example #4
0
	/**
	 * Un-subscribe from a category
	 *
	 * @param  string|int   $catid   Forum Category id
	 * @param  UserTable    $user    Viewed at User
	 * @param  PluginTable  $plugin  Current Plugin
	 * @return boolean               Result
	 */
	static public function unSubscribeCategory( $catid, $user, /** @noinspection PhpUnusedParameterInspection */ $plugin )
	{
		if ( ! class_exists( 'KunenaForumCategoryHelper' ) ) {
			return false;
		}

		if ( $catid == 'all' ) {
			$categories	=	KunenaForumCategoryHelper::getLatestSubscriptions( (int) $user->id, 0, 0 );
			$ids		=	array_keys( array_pop( $categories ) );
		} else {
			$ids		=	array( (int) $catid );
		}

		if ( ( ! $ids ) || ( ! KunenaForumCategoryHelper::subscribe( $ids, 0, (int) $user->id ) ) ) {
			return false;
		}

		return true;
	}