Location: PHPKode > projects > ACollab > members/index.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may redistribute it and/or                        */
/* modify it under the terms of the GNU General Public License                          */
/* as published by the Free Software Foundation; either version 2 of the License,       */
/* or (at your option) any later version.                                               */
/*                                                                                      */
/* This program is distributed in the hope that it will be useful, but                  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of                           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                                 */
/* See the GNU General Public License for more details.                                 */
/*                                                                                      */
/* You may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id

define('AC_INCLUDE_PATH', '../include/');

require(AC_INCLUDE_PATH.'vitals.inc.php');
authenticate(USER_CLIENT, USER_GROUP_ADMIN, USER_ADMIN);

$_SECTION[0][0] = _AC('home');
$_SECTION[0][1] = 'home.php';
$_SECTION[1][0] = _AC('members');
$_SECTION[1][1] = 'members/';

require(AC_INCLUDE_PATH.'header.inc.php');

if (isset($_GET['f'])) {
	print_feedback(intval($_GET['f']));
}

if ($_GET['col']) {
	$col = addslashes($_GET['col']);
} else {
	$col = 'login';
}
if ($_GET['col'] == 'privileges') {
	$col = 'G.privileges';
}

if ($_GET['order']) {
	$order = addslashes($_GET['order']);
} else {
	$order = 'asc';
}

$j = intval($_GET['j']);
$d = intval($_GET['d']);

if ($h > 0) {
	$group = get_group($h);
	echo '<h2>'._AC('members_of_group').': '.$group['title'].'</h2>';
}

if ($j > 0) {
	$jurisdiction = get_jurisdiction($j);
	echo '<h2>'._AC('members_of_jurisdiction').': '.$jurisdiction['title'].'</h2>';
}

if ($d > 0) {
	$department = get_department($d);
	echo '<h2>'._AC('members_of_department').': '.$department['title'].'</h2>';
}


${'highlight_'.$col} = ' u';


$_GET['L'] = '';
?>
<table cellspacing="0" cellpadding="2" border="0" bgcolor="white" width="99%" align="center" summary="" class="box2">
<tr>
	<th scope="col" class="box" align="left"><a name="list"></a><small><a href="<?php echo $_SERVER['PHP_SELF'].'?col=login'.SEP.'order=asc'.SEP.'L='.$_GET['L']; ?>#list" class="nav <?php echo $highlight_login; ?>" title="<?php echo _AC('username'); ?>" onfocus="this.className='highlight'" onblur="this.className='nav <?php echo $highlight_login; ?>'"><?php echo _AC('username'); ?></a> <?php
		if (($col == 'login') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=login'.SEP.'order=desc'.SEP.'L='.$_GET['L'].'#list"><img src="images/desc.gif" height="7" width="11" alt="'._AC('username_desc').'" border="0" class="img4" /></a>';
		} else if (($col == 'login') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=login'.SEP.'order=asc'.SEP.'L='.$_GET['L'].'#list"><img src="images/asc.gif" height="7" width="11" alt="'._AC('username_asc').'" border="0"  class="img4"/></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
	?></small></th>

	<th scope="col" class="box" align="left"><small><a href="<?php echo $_SERVER['PHP_SELF'].'?col=first_name'.SEP.'order=asc'.SEP.'L='.$_GET['L']; ?>#list" class="nav <?php echo $highlight_first_name; ?>" title="<?php echo _AC('first_name_asc'); ?>" onfocus="this.className='highlight'" onblur="this.className='nav <?php echo $highlight_first_name; ?>'"><?php echo _AC('first_name'); ?></a> <?php
		if (($col == 'first_name') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=first_name'.SEP.'order=desc'.SEP.'L='.$_GET['L'].'#list"><img src="images/desc.gif" height="7" width="11" alt="'._AC('first_name_desc').'" border="0"  class="img4" /></a>';
		} else if (($col == 'first_name') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=first_name'.SEP.'order=asc'.SEP.'L='.$_GET['L'].'#list"><img src="images/asc.gif" height="7" width="11" alt="'._AC('first_name_asc').'" border="0"  class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
	?></small></th>

	<th scope="col" class="box" align="left"><small><a href="<?php echo $_SERVER['PHP_SELF'].'?col=last_name'.SEP.'order=asc'.SEP.'L='.$_GET['L']; ?>#list" class="nav <?php echo $highlight_last_name; ?>" title="<?php echo _AC('last_name_asc'); ?>" onfocus="this.className='highlight'" onblur="this.className='nav <?php echo $highlight_last_name;?>'"><?php echo _AC('last_name'); ?></a> <?php
		if (($col == 'last_name') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=last_name'.SEP.'order=desc'.SEP.'L='.$_GET['L'].'#list"><img src="images/desc.gif" height="7" width="11" alt="'._AC('last_name_desc').'" border="0"   class="img4" /></a>';
		} else if (($col == 'last_name') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=last_name'.SEP.'order=asc'.SEP.'L='.$_GET['L'].'#list"><img src="images/asc.gif" height="7" width="11" alt="'._AC('last_name_asc').'" border="0"   class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
	?></small></th>

	<th scope="col" class="box" align="left"><small><a href="<?php echo $_SERVER['PHP_SELF'].'?col=G.privileges'.SEP.'order=asc'.SEP.'L='.$_GET['L']; ?>#list" class="nav <?php echo $highlight_last_name; ?>" title="<?php echo _AC('account_type_asc'); ?>" onfocus="this.className='highlight'" onblur="this.className='nav <?php echo $highlight_last_name;?>'"><?php echo _AC('account_type'); ?></a> <?php
		if (($col == 'G.privileges') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=G.privileges'.SEP.'order=desc'.SEP.'L='.$_GET['L'].'#list"><img src="images/desc.gif" height="7" width="11" alt="'._AC('account_type_desc').'" border="0"   class="img4" /></a>';
		} else if (($col == 'G.privileges') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=G.privileges'.SEP.'order=asc'.SEP.'L='.$_GET['L'].'#list"><img src="images/asc.gif" height="7" width="11" alt="'._AC('account_type_asc').'" border="0"   class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
	?></small></th>

	<th scope="col" class="box" align="left"><small>
<?php	
	if ($_GET['online'] == 'online') {		
		echo '<a href="' . $_SERVER['PHP_SELF'] . '?col=' . $col . SEP . 'order=' . $order . SEP . 'L=' . $_GET['L'] . SEP . 'online=offline#list" class="nav ' . $highlight_online . '" title="' . _AC('online') . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav ' . $highlight_online . '\'"> ';

		echo  _AC('online') . '<img src="images/desc.gif" height="7" width="11" alt="'._AC('online').'" border="0" class="img4" /></a>';
	}
	else if ($_GET['online'] == 'offline') {
		echo '<a href="' . $_SERVER['PHP_SELF'] . '?col=' . $col . SEP . 'order=' . $order . SEP . 'L=' . $_GET['L'] . SEP . 'online=online#list" class="nav ' . $highlight_online . '" title="' . _AC('online') . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav ' . $highlight_online . '\'"> ';

		echo _AC('online') .  '<img src="images/asc.gif" height="7" width="11" alt="'._AC('offline').'" border="0" class="img4" /></a>';
	}
	else {
		echo '<a href="' . $_SERVER['PHP_SELF'] . '?col=' . $col . SEP . 'order=' . $order . SEP . 'L=' . $_GET['L'] . SEP . 'online=online#list" class="nav ' . $highlight_online . '" title="' . _AC('online') . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav ' . $highlight_online . '\'"> ';
		
		echo _AC('online') . '</a><img src="images/clr.gif" height="7" width="11" alt="" />';
	}
	echo '</tr>';


$sql	= "SELECT M.member_id, M.login, M.first_name, M.last_name, G.privileges FROM ".MEMBERS_TABLE_PREFIX."members M INNER JOIN ".TABLE_PREFIX."groups_members G USING (member_id) WHERE G.group_id=$_SESSION[group_id] AND G.member_id  ORDER BY $col $order";
$result = mysql_query($sql, $db);

if (($row = mysql_fetch_assoc($result))) {
	do {
	
		$sql2 = "SELECT member_id FROM ".TABLE_PREFIX."users_online WHERE member_id=$row[member_id] AND group_id=$_SESSION[group_id]";
		$result2 = mysql_query($sql2, $db);

		if (mysql_num_rows($result2) == 1) {
			$online_list[$row['member_id']]  = $row;
		}
		else {
			$offline_list[$row['member_id']] = $row;
		}
		$overall_list[$row['member_id']]     = $row;

	} while ($row = mysql_fetch_assoc($result));

	//if online sorted
	if ($_GET['online'] == 'online') {
		if ($online_list) {
			foreach ($online_list as  $mem_id => $properties) {
				$counter++;
				echo '<tr>';
				echo '<td class="row'.(($counter-1)%2).'"><small><b><a href="profile.php?id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . $properties['login'] . '</a></b></small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['first_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['last_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>';
				if ($properties['privileges'] == USER_GROUP_ADMIN) {
					echo _AC('group_admin');
				} else {
					echo _AC('regular');
				}
				echo '</small></td>';
				echo '<td class="row'.(($counter-1)%2).'">';
				echo '<img src="images/forum/happy.gif" alt="'._AC('online').'" title="'._AC('online').'" /> ';
				echo '<small><a href="inbox/send_message.php?reply=1'.SEP.'id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AC('online') . '</a></small></td>';
				echo '</tr>';
			}
		}
		if ($offline_list) {
			foreach ($offline_list as $mem_id => $properties) {
				$counter++;
				echo '<tr>';
				echo '<td class="row'.(($counter-1)%2).'"><small><b><a href="profile.php?id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . $properties['login'] . '</a></b></small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['first_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['last_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>';
				if ($properties['privileges'] == USER_GROUP_ADMIN) {
					echo _AC('group_admin');
				} else {
					echo _AC('regular');
				}
				echo '</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"></td>';
				echo '</tr>';
			}
		}
		echo '</table>';
		echo '<p><small>'._AC('use_col_headings').'</small></p>';
	}

	//if offline sorted
	else if ($_GET['online'] == 'offline') {
		if ($offline_list) {
			foreach ($offline_list as $mem_id => $properties) {
				$counter++;
				echo '<tr>';
				echo '<td class="row'.(($counter-1)%2).'"><small><b><a href="profile.php?id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . $properties['login'] . '</a></b></small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['first_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['last_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>';
				if ($properties['privileges'] == USER_GROUP_ADMIN) {
					echo _AC('group_admin');
				} else {
					echo _AC('regular');
				}
				echo '</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"></td>';
				echo '</tr>';
			}
		}

		if ($online_list) {
			foreach ($online_list as  $mem_id => $properties) {
				$counter++;
				echo '<tr>';
				echo '<td class="row'.(($counter-1)%2).'"><small><b><a href="profile.php?id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . $properties['login'] . '</a></b></small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['first_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['last_name'].'&nbsp;</small></td>';
				echo '<td class="row'.(($counter-1)%2).'"><small>';
				if ($properties['privileges'] == USER_GROUP_ADMIN) {
					echo _AC('group_admin');
				} else {
					echo _AC('regular');
				}
				echo '</small></td>';
				echo '<td class="row'.(($counter-1)%2).'">';
				echo '<img src="images/forum/happy.gif" alt="'._AC('online').'" title="'._AC('online').'" /> ';
				echo '<small><a href="inbox/send_message.php?reply=1'.SEP.'id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AC('online') . '</a></small></td>';
				echo '</tr>';
			}
		}
		echo '</table>';
		echo '<p><small>'._AC('use_col_headings').'</small></p>';
	}

	//if just over all list
	else {
		foreach ($overall_list as  $mem_id => $properties) {
			$counter++;
			echo '<tr>';
			echo '<td class="row'.(($counter-1)%2).'"><small><b><a href="profile.php?id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . $properties['login'] . '</a></b></small></td>';
			echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['first_name'].'&nbsp;</small></td>';
			echo '<td class="row'.(($counter-1)%2).'"><small>'.$properties['last_name'].'&nbsp;</small></td>';
			echo '<td class="row'.(($counter-1)%2).'"><small>';
			if ($properties['privileges'] == USER_GROUP_ADMIN) {
				echo _AC('group_admin');
			} else {
				echo _AC('regular');
			}
			echo '</small></td>';
			echo '<td class="row'.(($counter-1)%2).'">';
			if ($online_list[$mem_id]) {
				echo '<img src="images/forum/happy.gif" alt="'._AC('online').'" title="'._AC('online').'" /> ';
				
				echo '<small><a href="inbox/send_message.php?reply=1'.SEP.'id=' . $properties['member_id'] . '" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AC('online') . '</a></small>';

			}
			echo '</td></tr>';
		}
		echo '</table>';
		echo '<p><small>'._AC('use_col_headings').'</small></p>';
	}
}
else {
	echo '</table>';
	echo _AC('no_members_found');
}
	
	require(AC_INCLUDE_PATH.'footer.inc.php');
?>
Return current item: ACollab