Exemple #1
0
	function getList(&$params)
	{ 
 	 
		$db			=& JFactory::getDBO();
		$user		=& JFactory::getUser();
		$userId		= (int) $user->get('id');
		$Itemid		=JomWallGroupsHelper::getComItemId();
		$count		= (int) $params->get('count', 5);
		$ordering		= trim( $params->get('ordering1') );
		$topgroup=$params->get('topgroup', '');
	  $groupModel = new AwdwallModelGroup();
	 	if(!empty($user->id))
		{
			$uid=$user->id;
			$sql="Select * from #__awd_groups ";
			if($topgroup)
			{
				$sql=$sql." where id!=".$topgroup." ";
			}			
				if($ordering==0)
				{
				$order=" Order by id desc";
				
				} else {
				
				$order=" Order by rand()";
				
				}
			 $sql.=$order;
			 $db->setQuery($sql);
			 $grows = $db->loadObjectList();
			
			 $ids=array();
				foreach($grows as $row)
				{
					if($row->privacy==1)
					{
						$ids[]=$row->id;		
					}
					else
					{
					
						$sql="select group_id from #__awd_groups_members where user_id=".$uid." and status=1 and group_id=".$row->id;
						 
						$db->setQuery($sql);
						$gid = $db->loadResult();
						if(!empty($gid))
						{
							$ids[]=$row->id;
							 
						}
					}
				}
			
			 if(count($ids>0))
			 {
			 	$gids=implode(",",$ids);
				if($ordering==0)
				{
				$order=" Order by id desc";
				
				} else {
				
				$order=" Order by rand()";
				
				}
	 			$sql="Select * from #__awd_groups where id in (".$gids.") ".$order;
				 $db->setQuery($sql, 0, $count);
				 $rows = $db->loadObjectList();

			 }
			
		}
		else
		{
			$sql="Select * from #__awd_groups where privacy=1 ";
			if($topgroup)
			{
				$sql=$sql." and id!=".$topgroup." ";
			}			
			if($ordering==0)
			{
				$order=" Order by id desc";
			
			} else {
			
			$order=" Order by rand()";
			
			}
			 $sql.=$order;
			 $db->setQuery($sql, 0, $count);
			 $rows = $db->loadObjectList();
		}
		 
		
		$i		= 0;
		$lists	= array();
		if($rows)
		{
			foreach ( $rows as $row )
			{
				$nofPosts = $groupModel->countPostGrp($row->id);
				$nofMembers = $groupModel->countMemGrp($row->id) + 1;
				$lists[$i]->thumb = AwdwallHelperUser::getBigGrpImg133($row->image,$row->id); 
				$lists[$i]->title = $row->title;
				$lists[$i]->id = $row->id;
				$lists[$i]->descr= $row->description;
				$lists[$i]->nofPosts= $nofPosts;
				$lists[$i]->nofMembers= $nofMembers;
				$lists[$i]->created_date= $row->created_date;
				$lists[$i]->link= 'index.php?option=com_awdwall&task=viewgroup&groupid='.$row->id.'&Itemid='.$Itemid;
				$lists[$i]->memberlink= 'index.php?option=com_awdwall&task=grpmembers&groupid='.$row->id.'&Itemid='.$Itemid;
					$i++;
			}
		}
		
		return $lists;
	}
Exemple #2
0
<?php // no direct access
defined('_JEXEC') or die('Restricted access');  
$db			=& JFactory::getDBO();
$Itemid		= JomWallGroupsHelper::getComItemId();
$topgroup=$params->get('topgroup', '');
if($topgroup)
{

}
else
{
$topgroup=$list[0]->id;
}
?>
<link rel="stylesheet" href="<?php echo JURI::base();?>modules/mod_jomwallgroups/css/style.css"  type="text/css" />

<div id="awdWallGroup">
<?php
if($topgroup)
{
			 $sql="select * from #__awd_groups where id=".$topgroup." limit 1";
			 $db->setQuery($sql);
			 $topgrouprows = $db->loadObjectList();
				$grouplink= 'index.php?option=com_awdwall&task=viewgroup&groupid='.$topgroup.'&Itemid='.$Itemid;
				$groupmemberlink= 'index.php?option=com_awdwall&task=grpmembers&groupid='.$topgroup.'&Itemid='.$Itemid;
				$grpthumb=AwdwallHelperUser::getBigGrpImg133($topgrouprows[0]->image,$topgroup);
				
			  $groupModel = new AwdwallModelGroup();
				$nofPosts = $groupModel->countPostGrp($topgroup);
				$nofMembers = $groupModel->countMemGrp($topgroup) + 1;
?>