Skip to content
Snippets Groups Projects
group-users.php 2.51 KiB
Newer Older
Nigel Kukard's avatar
Nigel Kukard committed
# Radius Group User List
# Copyright (C) 2007-2009, AllWorldIT
# 
# This program is free software; you can 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 should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");



$db = connect_db();



printHeader(array(
		"Tabs" => array(
			"Back to groups" => "group-main.php"
		),
));


# Check a policy group was selected
if (isset($_POST['group_id'])) {

?>
	<p class="pageheader">Group Members</p>
Robert Anderson's avatar
Robert Anderson committed

<?php
Robert Anderson's avatar
Robert Anderson committed
	# Get group name
	$group_stmt = $db->prepare("SELECT Name FROM ${DB_TABLE_PREFIX}groups WHERE ID = ?");
	$group_stmt->execute(array($_POST['group_id']));
	$row = $group_stmt->fetchObject();
	$group_stmt->closeCursor();
Robert Anderson's avatar
Robert Anderson committed
	<table class="results" style="width: 75%;">
		<tr class="resultstitle">
			<td class="textcenter">ID</td>
			<td class="textcenter">Member</td>
			<td class="textcenter">Disabled</td>
		</tr>
Robert Anderson's avatar
Robert Anderson committed
		# Get list of members belonging to this group
		$stmt = $db->prepare("SELECT UserID FROM ${DB_TABLE_PREFIX}users_to_groups WHERE GroupID = ?");
		$stmtResult = $stmt->execute(array($_REQUEST['group_id']));
Robert Anderson's avatar
Robert Anderson committed
		# Loop with rows
		while ($row = $stmt->fetchObject()) {
Robert Anderson's avatar
Robert Anderson committed
			$sql = "SELECT ID, Username, Disabled FROM ${DB_TABLE_PREFIX}users WHERE ID = ".$db->quote($row->userid);
			$res = $db->query($sql);
Robert Anderson's avatar
Robert Anderson committed
			# List users
			while ($row = $res->fetchObject()) {
Robert Anderson's avatar
Robert Anderson committed
				<tr class="resultsitem">
					<td><?php echo $row->id; ?></td>
					<td><?php echo $row->username; ?></td>
					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no'; ?></td>
				</tr>
Robert Anderson's avatar
Robert Anderson committed
			$res->closeCursor();
		}
Robert Anderson's avatar
Robert Anderson committed
		# Did we get any results?
		if ($stmt->rowCount() == 0) {
Robert Anderson's avatar
Robert Anderson committed
			<p />
			<tr>
				<td colspan="3" class="textcenter">Group has no users</td>
			</tr>
<?php
Robert Anderson's avatar
Robert Anderson committed
		}
		$stmt->closeCursor();
Robert Anderson's avatar
Robert Anderson committed
	</table>
	<div class="warning">Invalid invocation</div>

Robert Anderson's avatar
Robert Anderson committed
<?php
Robert Anderson's avatar
Robert Anderson committed
}
printFooter();


# vim: ts=4
?>