Skip to content
Snippets Groups Projects
Commit 3c524d66 authored by Robert Anderson's avatar Robert Anderson
Browse files

List user's groups

Unlink user from group
parent 609aa9b6
No related branches found
No related tags found
No related merge requests found
......@@ -151,6 +151,15 @@
switch ($function) {
# AdminUserGroups.js functions
case "removeAdminUserGroup":
$res = removeAdminUserGroup($soapParams);
if (isset($res)) {
ajaxException($res);
}
break;
case "getAdminUserGroups":
$res = getAdminUserGroups($soapParams);
......@@ -164,6 +173,7 @@
$res->setDatasetSize($numResults);
echo json_encode($res->export());
break;
# AdminUserAttributes.js functions
......
......@@ -3,45 +3,58 @@
include_once("include/db.php");
# Return list of attributes
function getAdminUserGroups($params) {
# Unlink user from group
function removeAdminUserGroup($params) {
global $db;
$i = 0;
$res = DBDo("DELETE FROM users_to_groups WHERE ID = ?",array($params[0]));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Return list of groups
function getAdminUserGroups($params) {
global $db;
# Filters and sorts are the same here
$filtersorts = array(
'ID' => 'users_to_groups.GroupID',
'ID' => 'users_to_groups.ID',
'Name' => 'groups.Name'
);
$resultArray = array();
$res = DBDo("SELECT GroupID FROM users_to_groups WHERE UserID = ?",$params[0]);
if ($res !== FALSE) {
while ($row = $res->fetchObject()) {
$i++;
$item = array();
$item['ID'] = $row->groupid;
$res2 = DBDo("SELECT Name FROM groups WHERE ID = ?",$item['ID']);
if ($res !== FALSE) {
$row = $res->fetchObject();
$item['Name'] = $row->name;
if (isset($item['Name'])) {
array_push($resultArray,$item);
}
}
}
}
$res = DBSelectSearch("
SELECT
users_to_groups.ID, groups.Name
FROM
users_to_groups, groups
WHERE
groups.ID = users_to_groups.GroupID
AND users_to_groups.UserID = ".DBQuote($params[0])."
",$params[1],$filtersorts,$filtersorts);
$sth = $res[0]; $numResults = $res[1];
# If STH is blank, return the error back to whoever requested the data
if ($res == FALSE) {
if (!isset($sth)) {
return $res;
}
return array($resultArray,$i);
$resultArray = array();
# loop through rows
while ($row = $sth->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Name'] = $row->name;
# push this row onto array
array_push($resultArray,$item);
}
return array($resultArray,$numResults);
}
?>
......@@ -176,14 +176,14 @@ function showAdminGroupAddEditWindow(id) {
// Display edit/add form
function showAdminGroupRemoveWindow(parent,id) {
function showAdminUserGroupRemoveWindow(parent,id) {
// Mask parent window
parent.getEl().mask();
// Display remove confirm window
Ext.Msg.show({
title: "Confirm removal",
msg: "Are you very sure you wish to remove this group?",
msg: "Are you very sure you wish to unlink this group?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
......@@ -198,8 +198,8 @@ function showAdminGroupRemoveWindow(parent,id) {
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminGroups',
SOAPFunction: 'removeAdminGroup',
SOAPModule: 'AdminUserGroups',
SOAPFunction: 'removeAdminUserGroup',
SOAPParams: 'ID'
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment