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

List location members, remove a user from a location

parent 9704b082
No related branches found
No related tags found
No related merge requests found
<?php
include_once("include/db.php");
# Remove group attribute
function removeWiSPLocationMember($params) {
global $db;
var_dump($params);
$res = DBDo("UPDATE wisp_userdata SET LocationID = NULL WHERE UserID = ?",array($params[0]));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Return list of attributes
function getWiSPLocationMembers($params) {
global $db;
# Filters and sorts are the same here
$filtersorts = array(
'ID' => 'users.ID',
'Username' => 'users.Username'
);
$res = DBSelectSearch("
SELECT
users.ID, users.Username
FROM
wisp_userdata, users
WHERE
wisp_userdata.LocationID = ".DBQuote($params[0])."
AND
users.ID = wisp_userdata.UserID
",$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;
}
$resultArray = array();
# loop through rows
while ($row = $sth->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Username'] = $row->username;
# push this row onto array
array_push($resultArray,$item);
}
return array($resultArray,$numResults);
}
?>
...@@ -74,8 +74,12 @@ ...@@ -74,8 +74,12 @@
<script type="text/javascript" src="js/app/windows/WiSPUserTopups.js"></script> <script type="text/javascript" src="js/app/windows/WiSPUserTopups.js"></script>
<script type="text/javascript" src="js/app/windows/WiSPLocations.js"></script> <script type="text/javascript" src="js/app/windows/WiSPLocations.js"></script>
<script type="text/javascript" src="js/app/windows/WiSPLocationMembers.js"></script>
<script type="text/javascript" src="js/app/windows/WiSPResellers.js"></script> <script type="text/javascript" src="js/app/windows/WiSPResellers.js"></script>
<script type="text/javascript" src="js/app/windows/AdminRealms.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/AdminUsers.js"></script> <script type="text/javascript" src="js/app/windows/AdminUsers.js"></script>
<script type="text/javascript" src="js/app/windows/AdminUserLogs.js"></script> <script type="text/javascript" src="js/app/windows/AdminUserLogs.js"></script>
......
function showWiSPLocationMembersWindow(locationID) {
var WiSPLocationMembersWindow = new Ext.ux.GenericGridWindow(
// Window config
{
title: "Members",
width: 600,
height: 335,
minWidth: 600,
minHeight: 335,
},
// Grid config
{
// Inline toolbars
tbar: [
{
text:'Remove',
tooltip:'Remove member',
iconCls:'remove',
handler: function() {
var selectedItem = WiSPLocationMembersWindow.getComponent('gridpanel').getSelectionModel().getSelected();
// Check if we have selected item
if (selectedItem) {
// If so display window
showWiSPLocationMemberRemoveWindow(WiSPLocationMembersWindow,selectedItem.data.ID);
} else {
WiSPLocationMembersWindow.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() {
WiSPLocationMembersWindow.getEl().unmask();
}
});
}
}
}
],
// Column model
colModel: new Ext.grid.ColumnModel([
{
id: 'ID',
header: "ID",
sortable: true,
dataIndex: 'ID'
},
{
header: "Username",
sortable: true,
dataIndex: 'Username'
}
]),
autoExpandColumn: 'Username'
},
// Store config
{
baseParams: {
ID: locationID,
SOAPUsername: globalConfig.soap.username,
SOAPPassword: globalConfig.soap.password,
SOAPAuthType: globalConfig.soap.authtype,
SOAPModule: 'WiSPLocationMembers',
SOAPFunction: 'getWiSPLocationMembers',
SOAPParams: 'ID,__search'
}
},
// Filter config
{
filters: [
{type: 'numeric', dataIndex: 'ID'},
{type: 'string', dataIndex: 'Username'}
]
}
);
WiSPLocationMembersWindow.show();
}
// Display remove form
function showWiSPLocationMemberRemoveWindow(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: 'WiSPLocationMembers',
SOAPFunction: 'removeWiSPLocationMember',
SOAPParams: 'ID'
}
});
// Unmask if user answered no
} else {
parent.getEl().unmask();
}
}
});
}
...@@ -91,7 +91,7 @@ function showWiSPLocationWindow() { ...@@ -91,7 +91,7 @@ function showWiSPLocationWindow() {
// Check if we have selected item // Check if we have selected item
if (selectedItem) { if (selectedItem) {
// If so display window // If so display window
showWiSPLocationMembersWindow(WiSPLocationWindow,selectedItem.data.ID); showWiSPLocationMembersWindow(selectedItem.data.ID);
} else { } else {
WiSPLocationWindow.getEl().mask(); WiSPLocationWindow.getEl().mask();
......
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