Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/modules/user/groupusers.php
<?
defined( '_VALID_DA_' ) or die( 'Bu sayfaya dogrudan eriþim yapýlamaz.' );

/*****************************************************************************/
function List_GroupUsers($request){

	global $module;
	global $module_path;

	$content = null;

	$obj_tempdbarray = new CTempDBArray();
	$obj_tempdbengine = new CTempDBEngine();
	
	$obj_tempdb2array = new CTempDBArray();
	$obj_tempdb2engine = new CTempDBEngine();

	//Toplam gosterilecek kayit sayisi
	$record = 20;

	$groupid = $request['group'];
	$desc = $request['desc'];
	$orderby = $request['orderby'];
	//Sayfa Numarasi
	$page = $request['page'];
	if ($page<=0)
		$page = 1;

	$SQL = "SELECT * FROM user_groups ";
	$SQL .= "WHERE group_id='".intval($groupid)."' ";
	$obj_tempdbarray = $obj_tempdbengine->GetRows($SQL);

	$total_record = $obj_tempdbarray->count();
	$max_page = ceil($total_record / $record);

	$content = "<center>";

	if ($total_record>0){

		switch ($orderby){
		default:
				$SQL .= "ORDER BY user_id ";
		break;
		case 'active':
//				$SQL .= "ORDER BY active ";
		break;
		case 'username':
//				$SQL .= "ORDER BY username ";
		break;
		case 'name':
//				$SQL .= "ORDER BY name_surname ";
		break;
		}
		
		$start = ($page-1)*$record;
		$SQL .= "LIMIT $start ,$record";
		
		$obj_tempdbarray = $obj_tempdbengine->GetRows($SQL);
	
		$content .= "
	
		<table width=\"100%\" cellpadding=\"3\" cellspacing=\"3\" border=\"1\">
		<tbody>
			<th><a href=".basename($PHP_SELF)."?f=user&sf=groupusers&group=$groupid&operation=list&orderby=active&desc=".intval($desc).">"._CP_UA_ACTIVE_."</a></th>
			<th><a href=".basename($PHP_SELF)."?f=user&sf=groupusers&group=$groupid&operation=list&orderby=name&desc=".intval($desc).">"._CP_UA_USERNAME_."</a></th>
			<th>"._CP_UA_NAMESURNAME_."</th>
			<th>"._CMN_EDIT_."</th>
			<th>"._CMN_DELETE_."</th>
		</tbody>";
	
		while( $row = $obj_tempdbarray->get() ){
			//print_r($row);
			$usergroupid = $row['user_group_id'];
			$userid = $row['user_id'];
			//$groupid = $row['group_id'];

			$SQL2 = "SELECT * FROM users ";
			$SQL2 .= "WHERE user_id='".intval($userid)."' ";
			$row2 = $obj_tempdb2engine->GetRow($SQL2);
			$active = $row2['active'];
			$name_surname = $row2['name_surname'];
			$username = $row2['username'];
			$email = $row2['email'];

			$content .= "
			<tr>
				<td align=\"center\">";
				if ($active)
					$content .= "<img border=0 src=\"images/icon/check.png\">";
				else
					$content .= "<img border=0 src=\"images/icon/disable.png\">";
				$content .= "
				</td>

				<td align=\"center\"><a href=\"".basename($PHP_SELF)."?f=user&sf=allusers&group=$groupid&operation=edit&user=$userid&orderby=".$orderby."&desc=".intval($desc)."&page=".$page."\">$username</a></td>
				<td align=\"center\">$name_surname</td>
				<td align=\"center\"><a href=".basename($PHP_SELF)."?f=user&sf=allusers&operation=edit&group=$groupid&user=$userid&orderby=".$orderby."&desc=".intval($desc)."&page=".$page."><img border=0 src=\"images/icon/edit.gif\"></a></td>
				<td align=\"center\"><a href=".basename($PHP_SELF)."?f=user&sf=allusers&operation=delete&group=$groupid&user=$userid&orderby=".$orderby."&desc=".intval($desc)."&page=".$page."><img border=0 src=\"images/icon/remove.gif\"></a></td>
			</tr>";
		}
		$content .= "</table><br>";
	
		if ($max_page>1){
			$fpage = 1;
			$lpage = $max_page;
			if ($page>1)
				$ppage = $page-1;
			else
				$ppage = 1;
		
			if ($page>=$max_page)
				$npage = $max_page;
			else
				$npage = $page+1;
		
			//Sayfa gosterimi
			$content .= "
			<a href=".basename($PHP_SELF)."?f=user&sf=groupusers&operation=list&orderby=".$orderby."&desc=".intval($desc)."&page=".$fpage.">
				<img src=\"./images/icon16/left2.png\" width=\"16\" height=\"16\" border=\"0\">
			</a>
		
			<a href=".basename($PHP_SELF)."?f=user&sf=groupusers&operation=list&orderby=".$orderby."&desc=".intval($desc)."&page=".$ppage.">
				<img src=\"./images/icon16/left.png\" width=\"16\" height=\"16\" border=\"0\">
			</a>
		
			<a href=".basename($PHP_SELF)."?f=user&sf=groupusers&operation=list&orderby=".$orderby."&desc=".intval($desc)."&page=".$npage.">
				<img src=\"./images/icon16/right.png\" width=\"16\" height=\"16\" border=\"0\">
			</a>
		
			<a href=".basename($PHP_SELF)."?f=user&sf=groupusers&operation=list&orderby=".$orderby."&desc=".intval($desc)."&page=".$lpage.">
				<img src=\"./images/icon16/right2.png\" width=\"16\" height=\"16\" border=\"0\">
			</a>
		
			<br><br>";
		}
		
		$content .= _CMN_TOTAL_RECORD_.$total_record."<br>";
		$content .= _CMN_PAGE_.$page." / ".$max_page."<br>";
		$content .= "<br>";
	
	}
	else{
		$content .= "
		<div class=note>
			<h3>"._CMN_NOTE_."</h3>
			<p>";
				$content .= _CMN_NO_RECORD_FOUND_;
				$content .= "<br><br>";
				$content .= go_back();
			$content .= "
			</p>
		</div>";
	}

	$content .= "
	<a class=\"inline-button orange\" href=".basename($PHP_SELF)."?f=user&sf=groupusers&operation=list&group=$groupid&orderby=".$orderby."&desc=".intval($desc)."&page=".$page."><em>@</em><span>"._CMN_LIST_."</span></a>

	<a class=\"inline-button orange\" href=".basename($PHP_SELF)."?f=user&sf=allusers&operation=add&group=$groupid&user=$userid><em>@</em><span>"._CMN_ADD_."</span></a>

	</center>
	";

	return $content;
}

//*****************************************************************************
function Group_Users($request){

	global $module;
	global $module_path;

	$obj_tempdbarray = new CTempDBArray();
	$obj_tempdbengine = new CTempDBEngine();

	$operation = $request['operation'];

	switch ($operation){
	default:
	case 'list':
		$content = List_GroupUsers($request);
	break;
	}

	return $content;
}

?>
Return current item: ChiCoMaS - Chilek CMS