Ejemplo n.º 1
0
	public function viewFriends($tpl = null)

	{

		$mainframe	=& JFactory::getApplication();

		$itemId = AwdwallHelperUser::getComItemId();

		$task 			= JRequest::getCmd('task', '');

		$page 			= JRequest::getCmd('awd_page', 0);



		// get configuration from database

		//$config = &JComponentHelper::getParams('com_awdwall');
		$app = JFactory::getApplication('site');
		$config =  & $app->getParams('com_awdwall');
		$displayName 	= $config->get('display_name', 1);
		$postLimit 		= $config->get('nof_post', 15);
		$fields			= $config->get('fieldids', '');
		$privacy 		= $config->get('privacy', 0); 

		$displayPm = $config->get('display_pm', 1);
		
		$display_group = $config->get('display_group', 1);
		
		$display_group_for_moderators = $config->get('display_group_for_moderators', 1);
		
		$moderator_users = $config->get('moderator_users', '');
		
		$moderator_users=explode(',',$moderator_users);

		$user = &JFactory::getUser();		

		// get all msg from databases

		$wallModel = & $this->getModel('wall');
		$this->assignRef('wallModel', $wallModel);
		// build where clause	

		$where = array();

		$where[] = 'connect_from  = ' . (int)$user->id;

		$where = count($where) ? ' WHERE ' . implode( ' AND ', $where ) : '';

		$offset = $page*$postLimit;

		

		//color

		$db		=& JFactory::getDBO();

//		$query = "SELECT params FROM #__components WHERE `name`='Colors' AND `admin_menu_link`='option=com_awdwall&controller=colors'";
		$link='index.php?option=com_awdwall&controller=colors';
		$db->setQuery("SELECT params FROM #__menu WHERE `link`='".$link."'");
		$params = json_decode( $db->loadResult(), true );
		for($i=1; $i<=14; $i++)
		{
			$str_color = 'color'.$i;			
			$color[$i]= $params[$str_color];
		}

		

		$this->assignRef('color', $color);

		

		//$friends = $wallModel->getAllFriends($postLimit, $where, $offset);
		$query 	= 'SELECT * FROM #__awd_connection  inner join #__users ON #__awd_connection.connect_to=#__users.id '				
				.$where . ' '
				.'ORDER BY connection_id DESC ';
				// echo $query ;
		$db->setQuery($query);
		$friends =$db->loadObjectList();
		$nofFriends = $wallModel->countFriends($where);

		require_once (JPATH_COMPONENT . DS . 'libraries' . DS . 'jslib.php');

		$basicInfo 		= JsLib::getUserBasicInfo($user->id, $fields);

		$totalFriends 	= JsLib::countFriends($user->id);

		$friendLimit 	= (int)$config->get('nof_friends', 4);

		if($friendLimit > 6)

			$friendLimit = 6;

		$leftFriends 	= JsLib::getAllFriends($user->id, $friendLimit);

		
		// get 4 first groups to display

		require_once (JPATH_COMPONENT . DS . 'models' . DS . 'group.php');

		$whr = array();

		$whr[] = 'ag.creator = ' . $user->id . ' OR agm.user_id =' . $user->id;
		$whr[] =' status="1"';
		$whr = count($whr) ? ' WHERE ' . implode( ' AND ', $whr ) : '';

		$groups = AwdwallModelGroup::getAllGrps($whr, 4, 0);


		//Total pending friend requests
		$pendingFriends = JsLib::getPendingFriends($user->id);
		
		//Userinfo of login user
		$userinfo = AwdwallHelperUser::getUserInfo($user->id);		
		$this->assignRef('userinfo', $userinfo);  
		
		//Total private message of user
		require_once (JPATH_COMPONENT . DS . 'models' . DS . 'wall.php');
		$modelWall = new AwdwallModelWall();	
		//print_r($modelWall);
		$totalpm = $modelWall->countpm($user->id);
		
		$pendingGroups = JsLib::getPendingGroups($user->id);

		$this->assignRef('pendingGroups', $pendingGroups);
		$this->assignRef('totalpm', $totalpm);
		$this->assignRef('totalmygroup', $totalmygroup);
		$this->assignRef('groups', $groups);

		$this->assignRef('totalFriends', $totalFriends);

		$this->assignRef('leftFriends', $leftFriends);

		$this->assignRef('basicInfo', $basicInfo);

		$this->assignRef('nofFriends', $nofFriends);

		$this->assignRef('friends', $friends);

		$this->assignRef('page', $page);

		$this->assignRef('postLimit', $postLimit);		

		$this->assignRef('privacy', $privacy);
		$this->assignRef('displayName', $displayName);
		$this->assignRef('displayPm', $displayPm);
		$this->assignRef('display_group', $display_group);
		$this->assignRef('display_group_for_moderators', $display_group_for_moderators);
		$this->assignRef('moderator_users', $moderator_users);
		$this->assignRef('pendingFriends', $pendingFriends);

		$display_profile_link = $config->get('display_profile_link', 1);
		$this->assignRef('display_profile_link', $display_profile_link);
		
		
		$wallalbumfile = JPATH_SITE . '/components/com_awdjomalbum/awdjomalbum.php';
		if (file_exists($wallalbumfile)) // if com_awdjomalbum install then only
		{
			$query="Select * from #__awd_jomalbum_userinfo where userid=".$user->id; 
			$db->setQuery($query);
			$rows=$db->loadObjectList();
			$this->assignRef('albumuserinfo', $rows[0]);
		}
		
		parent::display($tpl);

	}
define( 'DS', DIRECTORY_SEPARATOR );
require_once(JPATH_SITE . DS . 'components'.DS.'com_awdwall'. DS . 'helpers' . DS . 'user.php');
require_once(JPATH_SITE . DS . 'components'.DS.'com_awdwall'. DS . 'libraries' . DS . 'jslib.php');
require_once(JPATH_SITE . DS . 'components'.DS.'com_awdwall'. DS . 'models' . DS . 'group.php');
require_once(JPATH_SITE . DS . 'components'.DS.'com_awdwall'. DS . 'models' . DS . 'wall.php');
$config 		= &JComponentHelper::getParams('com_awdwall');
$template 		= $config->get('temp', 'default');
// include the helper file
require_once(dirname(__FILE__).DS.'helper.php');

$user 			= &JFactory::getUser();
if(empty($user->id)) return;
$db		= &JFactory::getDBO();
if($user->id)
{
	$countFriends=JsLib::countFriends($user->id);
	$getPendingFriends=JsLib::getPendingFriends($user->id);
	
	$pendinggroup=JsLib::getPendingGroups($user->id);
	$getMyGrps=count(AwdwallModelGroup::getMyGrps($user->id));
	
	$countwallpost=ModJomwallminiprofileHelper::countwallpost($user->id);
	
	$countalbumphotos=ModJomwallminiprofileHelper::countalbumphotos($user->id);
	$countwallphotos=ModJomwallminiprofileHelper::countwallphotos($user->id);
	$totalphotos=$countalbumphotos+$countwallphotos;
	
	$avatar=AwdwallHelperUser::getBigAvatar51($user->id);
	
	$modelWall = new AwdwallModelWall();	
	$totalpm = $modelWall->countpm($user->id);