Skip to content
Snippets Groups Projects
AdminGroupMembers.php 1.26 KiB
Newer Older
<?php

include_once("include/db.php");

# Remove group member
function removeAdminGroupMember($params) {

	$res = DBDo("DELETE FROM users_to_groups WHERE ID = ?",array($params[0]));

	# Return result
	if (is_bool($res)) {
# Return list of members
function getAdminGroupMembers($params) {

	# Filters and sorts are the same here
	$filtersorts = array(
		'ID' => 'users_to_groups.ID',
		'Username' => 'group_attributes.Username',
		'Disabled' => 'group_attributes.Disabled'
	);

Robert Anderson's avatar
Robert Anderson committed
	# Fetch members
	$res = DBSelectSearch("
			SELECT 
				users_to_groups.ID, users.Username, users.Disabled 
				users_to_groups, users
				users.ID = users_to_groups.UserID
			AND
				users_to_groups.GroupID = ".DBQuote($params[0])."
		",$params[1],$filtersorts,$filtersorts);

	$sth = $res[0]; $numResults = $res[1];
Robert Anderson's avatar
Robert Anderson committed

	# If STH is blank, return the error back to whoever requested the data
	if (!isset($sth)) {
		return $res;
	}


Robert Anderson's avatar
Robert Anderson committed
	# Loop through rows
	$resultArray = array();
	while ($row = $sth->fetchObject()) {
		$item = array();

		$item['ID'] = $row->id;
		$item['Username'] = $row->username;
		$item['Disabled'] = $row->disabled;

Robert Anderson's avatar
Robert Anderson committed
		# Push this row onto array
		array_push($resultArray,$item);
	}

	return array($resultArray,$numResults);
}

Robert Anderson's avatar
Robert Anderson committed
# vim: ts=4