View file PF.Base/module/friend/include/component/block/profile/small.class.php

File size: 1.77Kb
<?php
/**
 * [PHPFOX_HEADER]
 */

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

/**
 * 
 * 
 * @copyright		[PHPFOX_COPYRIGHT]
 * @author  		Raymond Benc
 * @package  		Module_Friend
 * @version 		$Id: small.class.php 2760 2011-07-27 13:39:18Z Raymond_Benc $
 */
class Friend_Component_Block_Profile_Small extends Phpfox_Component
{
	/**
	 * Controller
	 */
	public function process()
	{				
		$aUser = (PHPFOX_IS_AJAX ? User_Service_User::instance()->get(Phpfox::getUserId(), true)  : $this->getParam('aUser'));

		if (!User_Service_Privacy_Privacy::instance()->hasAccess($aUser['user_id'], 'friend.view_friend'))
		{
			return false;
		}

		$iTotal = (int) Phpfox::getComponentSetting($aUser['user_id'], 'friend.friend_display_limit_profile', Phpfox::getParam('friend.friend_display_limit'));
		
		$aRows = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . $aUser['user_id'], 'friend.is_top_friend DESC, friend.ordering ASC, RAND()', 0, $iTotal, false);
		
		$iCount = count($aRows);
		
		if (!$iCount)
		{
			return false;
		}
		$sFriendsLink = User_Service_User::instance()->getLink($aUser['user_id'], $aUser['user_name'], 'friend');
		$this->template()->assign(array(
				'aFriends' => $aRows,
				'sFriendsLink' => $sFriendsLink,
				'sBlockJsId' => 'profile_friend',
				'aFriendLists' => Friend_Service_List_List::instance()->getListForProfile($aUser['user_id']),
				'aSubject' => $aUser,
                'bShowFriendInfo' => true
			)
		);

		return null;
	}
	
	/**
	 * Garbage collector. Is executed after this class has completed
	 * its job and the template has also been displayed.
	 */
	public function clean()
	{
		(($sPlugin = Phpfox_Plugin::get('friend.component_block_profile_small_clean')) ? eval($sPlugin) : false);
	}
	
	public function widget()
	{
		return true;
	}
}