Вход Регистрация
Файл: upload/module/user/include/service/featured/featured.class.php
Строк: 67
<?php
/**
 * [PHPFOX_HEADER]
 */

defined('PHPFOX') or exit('NO DICE!');

/**
 * 
 * 
 * @copyright        [PHPFOX_COPYRIGHT]
 * @author          Miguel Espinoza
 * @package          Module_User
 * @version         $Id: featured.class.php 1496 2010-03-05 17:15:05Z Raymond_Benc $
 */
class User_Service_Featured_Featured extends Phpfox_Service
{    
    
    public function 
__construct()
    {
        
$this->_sTable = Phpfox::getT('user_featured');
    }

    
/**
     * Gets the featured members according to Phpfox::getParam('user.how_many_featured_members').
     * Uses cache to save a query (stores a cache if none found)
     * @return array( array of users, int total featured users )
     */
    
public function get()
    {
        
$iTotal = Phpfox::getParam('user.how_many_featured_members');
        
// the random will be done with php logic
        
$sCacheId = $this->cache()->set('featured_users');
        if (!(
$aUsers = $this->cache()->get($sCacheId)))
        {
            
$aUsers = $this->database()->select(Phpfox::getUserField() . ', uf.ordering')
            ->
from(Phpfox::getT('user'), 'u')
            ->
join($this->_sTable, 'uf', 'uf.user_id = u.user_id')
            ->
order('ordering DESC')
            ->
execute('getSlaveRows');
            
$this->cache()->save($sCacheId, $aUsers);
        }

        if (!
is_array($aUsers)) return array(false, 0);        
        
$aOut = array();
        if (
Phpfox::getParam('user.randomize_featured_members'))        
            
shuffle($aUsers);            
        
        
$iCount = count($aUsers); // using count instead of $this->database()->limit to measure the real value
        
for ($i = 0; $i <= $iTotal; $i++)
        {
            if (!isset(
$aUsers[$iCount -$i])) continue; // availability check
            
$aOut[] = $aUsers[$iCount - $i];
        }
        
        return array(
$aOut, count($aUsers));
    }    
    
    
/**
     * If a call is made to an unknown method attempt to connect
     * it to a specific plug-in with the same name thus allowing 
     * plug-in developers the ability to extend classes.
     *
     * @param string $sMethod is the name of the method
     * @param array $aArguments is the array of arguments of being passed
     */
    
public function __call($sMethod, $aArguments)
    {
        
/**
         * Check if such a plug-in exists and if it does call it.
         */
        
if ($sPlugin = Phpfox_Plugin::get('user.service_featured__call'))
        {
            return eval(
$sPlugin);
        }
            
        
/**
         * No method or plug-in found we must throw a error.
         */
        
Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);
    }    
}

?>
Онлайн: 3
Реклама