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

List realm members and remove member from realm

Fixed space between realm buttons
parent 3bbd26a1
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@
include_once("include/ajax/functions/AdminRealms.php");
include_once("include/ajax/functions/AdminRealmAttributes.php");
include_once("include/ajax/functions/AdminRealmMembers.php");
include_once("include/ajax/functions/AdminClients.php");
include_once("include/ajax/functions/AdminClientAttributes.php");
......@@ -518,6 +519,32 @@
break;
# AdminRealmMembers.js functions
case "getAdminRealmMembers":
$res = getAdminRealmMembers($soapParams);
$rawData = $res[0]; $numResults = $res[1];
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Name','string');
$res->parseArray($rawData);
$res->setDatasetSize($numResults);
echo json_encode($res->export());
break;
case "removeAdminRealmMember":
$res = removeAdminRealmMember($soapParams);
if (isset($res)) {
ajaxException($res);
}
break;
# AdminUserLogs.js functions
case "getAdminUserLogs":
......
<?php
include_once("include/db.php");
# Remove realm member
function removeAdminRealmMember($params) {
$res = DBDo("DELETE FROM clients_to_realms WHERE ID = ?",array($params[0]));
# Return result
if (is_bool($res)) {
return $res;
}
return NULL;
}
# Return list of members
function getAdminRealmMembers($params) {
# Filters and sorts are the same here
$filtersorts = array(
'ID' => 'clients_to_realms.ID',
'Name' => 'realm_attributes.Name'
);
# Fetch members
$res = DBSelectSearch("
SELECT
clients_to_realms.ID, clients.Name
FROM
clients_to_realms, clients
WHERE
clients.ID = clients_to_realms.ClientID
AND
clients_to_realms.RealmID = ".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 (!isset($sth)) {
return $res;
}
# Loop through rows
$resultArray = array();
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);
}
# vim: ts=4
......@@ -104,8 +104,11 @@
<script type="text/javascript" src="js/app/windows/AdminUserAttributes.js"></script>
<script type="text/javascript" src="js/app/windows/AdminUserGroups.js"></script>
<script type="text/javascript" src="js/app/windows/AdminUserTopups.js"></script>
<script type="text/javascript" src="js/app/windows/AdminRealms.js"></script>
<script type="text/javascript" src="js/app/windows/AdminRealmAttributes.js"></script>
<script type="text/javascript" src="js/app/windows/AdminRealmMembers.js"></script>
<script type="text/javascript" src="js/app/windows/AdminClients.js"></script>
<script type="text/javascript" src="js/app/windows/AdminClientAttributes.js"></script>
<script type="text/javascript" src="js/app/windows/AdminClientRealms.js"></script>
......
/*
Admin Realm Members
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.
*/
function showAdminRealmMembersWindow(realmID) {
var AdminRealmMembersWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Members",
iconCls: 'silk-server',
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Remove',
tooltip:'Remove member',
iconCls:'silk-server_delete',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmMembersWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmMemberRemoveWindow(AdminRealmMembersWindow,selectedItem.data.ID);
} else {
AdminRealmMembersWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No member selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmMembersWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Name",
sortable: true,
dataIndex: 'Name'
}
]),
autoExpandColumn: 'Name'
},
// Store config
{
baseParams: {
ID: realmID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmMembers',
SOAPFunction: 'getAdminRealmMembers',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Name'}
]
}
);
AdminRealmMembersWindow.show();
}
// Display remove form
function showAdminRealmMemberRemoveWindow(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 member?",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.YESNO,
modal: false,
fn: function(buttonId,text) {
// Check if user clicked on 'yes' button
if (buttonId == 'yes') {
// Do ajax request
uxAjaxRequest(parent,{
params: {
ID: id,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'AdminRealmMembers',
SOAPFunction: 'removeAdminRealmMember',
SOAPParams: 'ID'
}
});
// Unmask if user answered no
} else {
parent.getEl().unmask();
}
}
});
}
// vim: ts=4
......@@ -72,6 +72,7 @@ function showAdminRealmWindow() {
}
}
},
'-',
{
text:'Remove',
tooltip:'Remove realm',
......@@ -113,6 +114,34 @@ function showAdminRealmWindow() {
} else {
AdminRealmWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
msg: "No realm selected",
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.CANCEL,
modal: false,
fn: function() {
AdminRealmWindow.getEl().unmask();
}
});
}
}
},
'-',
{
text:'Members',
tooltip:'Realm members',
iconCls:'silk-server',
handler: function() {
var selectedItem = Ext.getCmp(AdminRealmWindow.gridPanelID).getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showAdminRealmMembersWindow(selectedItem.data.ID);
} else {
AdminRealmWindow.getEl().mask();
// Display error
Ext.Msg.show({
title: "Nothing selected",
......
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