Esempio n. 1
0
 /**
  * Get Kunena session object
  *
  * Returns the global {@link KunenaSession} object, only creating it if it doesn't already exist.
  *
  * @param array|bool $update	An array containing session options
  * @return KunenaSession
  */
 public static function getSession($update = false)
 {
     if (!is_object(KunenaFactory::$session)) {
         KunenaFactory::$session = KunenaSession::getInstance($update);
     }
     return KunenaFactory::$session;
 }
Esempio n. 2
0
	public static function getInstance( $update=false, $userid = null )
	{
		if (!self::$_instance) {
			$my = JFactory::getUser();
			self::$_instance = new KunenaSession($userid !== null ? $userid : $my->id);
			if ($update) self::$_instance->updateSessionInfo();
		}
		return self::$_instance;
	}
Esempio n. 3
0
 /**
  * @static
  * @access public
  * @return obj CKunenaLatestX resultlist
  */
 static function fetch($type, $incl_cat, $excl_cat, $limit, $timelimit)
 {
     // Verify all query options and get a similar array returned into $options
     $options = self::getVerifiedOptions(array('type' => $type, 'incl_cat' => $incl_cat, 'excl_cat' => $excl_cat, 'limit' => $limit, 'timelimit' => $timelimit));
     // Apply admin restrictions
     foreach ($options['incl_cat'] as $key => $catid) {
         if (in_array($catid, $options['excl_cat'])) {
             // forbidden - remove category
             // note: if only one category was wanted (and now removed), incl_cat is empty and all categories will be selected
             unset($options['incl_cat'][$key]);
         }
     }
     KunenaSession::getInstance(true, 0);
     $model = new CKunenaLatestX('', 0);
     $model->threads_per_page = $options['limit'];
     $model->querytime = CKunenaTimeformat::internalTime() - $options['timelimit'];
     $model->latestcategory = $options['incl_cat'];
     $model->latestcategory_in = 1;
     if (count($options['incl_cat']) == 0) {
         // If incl_cat is empty everything will be included by CKunenalatestX, therefore we need to specific which categories NOT to load
         $model->latestcategory = $options['excl_cat'];
         $model->latestcategory_in = 0;
     }
     switch ($options['type']) {
         case 'topic':
             $model->getLatestTopics();
             $result = $model->threads;
             break;
         case 'recent':
             $model->getLatest();
             $result = $model->lastreply;
             foreach ($result as $message) {
                 $message->subject = $model->threads[$message->thread]->subject;
             }
             break;
         case 'post':
         default:
             $model->getLatestPosts();
             $result = $model->customreply;
     }
     return (array) $result;
 }