Author: jfthomps
Date: Tue Aug 30 18:54:36 2016
New Revision: 1758441
URL: http://svn.apache.org/viewvc?rev=1758441&view=rev
Log:
VCL-986 - make add, edit, and delete on Manage Groups stay on the page
groups.php:
-modified viewGroups: removed text when $mode = submitDeleteGroup that says
group successfully deleted; changed continuation creation from
confirmDeleteGroup to AJconfirmDeleteGroup; changed user and resource stores to
be of type ItemFileWriteStore; added comparatorMap to definition of
usergroupstore; added dijit.Dialog for deleting groups
-modified checkForGroupUsage: added call to wordwrap to wrap $msg at 75
characters using <br> before returning it
-changed confirmDeleteGroup to AJconfirmDeleteGroup
-modified AJconfirmDeleteGroup: send response in JSON format instead of
printing it directly; removed form elements
-changed submitDeleteGroup to AJsubmitDeleteGroup
-modified AJsubmitDeleteGroup: send response in JSON format instead of calling
viewGroups
states.php:
-added AJconfirmDeleteGroup and AJsubmitDeleteGroup to $noHTMLwrappers
-changed confirmDeleteGroup to AJconfirmDeleteGroup
-changed submitDeleteGroup to AJsubmitDeleteGroup
utils.php: modified getDojoHTML: added dijit.Dialog to viewGroups mode
groups.js:
-modified confirmDeleteUserGroup: changed to make an AJAX call instead of
changing window.location.href
-added confirmDeleteGroupCB
-added clearHideConfirmDelete
-added submitDeleteGroup
-added submitDeleteGroupCB
-modified confirmDeleteResourceGroup: changed to make an AJAX call instead of
changing window.location.href
vcl.css: added #confdelcontent th
Modified:
vcl/trunk/web/.ht-inc/groups.php
vcl/trunk/web/.ht-inc/states.php
vcl/trunk/web/.ht-inc/utils.php
vcl/trunk/web/css/vcl.css
vcl/trunk/web/js/groups.js
Modified: vcl/trunk/web/.ht-inc/groups.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/groups.php?rev=1758441&r1=1758440&r2=1758441&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/groups.php (original)
+++ vcl/trunk/web/.ht-inc/groups.php Tue Aug 30 18:54:36 2016
@@ -54,10 +54,6 @@ function viewGroups() {
print "<font color=\"#008000\">User group successfully
added";
print "</font><br><br>\n";
}
- elseif($mode == "submitDeleteGroup") {
- print "<font color=\"#008000\">User group successfully
deleted";
- print "</font><br><br>\n";
- }
elseif($mode == "submitEditGroup") {
print "<font color=\"#008000\">User group successfully
updated";
print "</font><br><br>\n";
@@ -81,11 +77,12 @@ function viewGroups() {
# hidden elements
$cont = addContinuationsEntry('editGroup', $cdata);
print "<input type=\"hidden\" id=\"editgroupcont\" value=\"$cont\">\n";
- $cont = addContinuationsEntry('confirmDeleteGroup', $cdata);
+ $cont = addContinuationsEntry('AJconfirmDeleteGroup', $cdata);
print "<input type=\"hidden\" id=\"deletegroupcont\"
value=\"$cont\">\n";
$cont = addContinuationsEntry('jsonUserGroupStore');
- print "<div dojoType=\"dojo.data.ItemFileReadStore\" url=\"" . BASEURL;
- print SCRIPT . "?continuation=$cont\" jsid=\"usergroupstore\"></div>\n";
+ print "<div dojoType=\"dojo.data.ItemFileWriteStore\" url=\"" . BASEURL;
+ print SCRIPT . "?continuation=$cont\" jsid=\"usergroupstore\" ";
+ print "comparatorMap=\"\{\}\"></div>\n";
print "<div dojoType=\"dojo.data.ItemFileWriteStore\"\n";
print "data=\"{'identifier':'id', 'label':'name', 'items':[]}\" \n";
print "jsid=\"affiliationstore\"></div>\n";
@@ -171,10 +168,6 @@ function viewGroups() {
print "<font color=\"#008000\">Resource group
successfully added";
print "</font><br><br>\n";
}
- elseif($mode == "submitDeleteGroup") {
- print "<font color=\"#008000\">Resource group
successfully deleted";
- print "</font><br><br>\n";
- }
elseif($mode == "submitEditGroup") {
print "<font color=\"#008000\">Resource group
successfully updated";
print "</font><br><br>\n";
@@ -212,12 +205,12 @@ function viewGroups() {
# hidden elements
$cont = addContinuationsEntry('editGroup', $cdata);
print "<input type=\"hidden\" id=\"editresgroupcont\"
value=\"$cont\">\n";
- $cont = addContinuationsEntry('confirmDeleteGroup', $cdata);
+ $cont = addContinuationsEntry('AJconfirmDeleteGroup', $cdata);
print "<input type=\"hidden\" id=\"deleteresgroupcont\"
value=\"$cont\">\n";
$jscont = addContinuationsEntry('jsonGetGroupInfo');
print "<input type=\"hidden\" id=\"jsongroupinfocont\"
value=\"$jscont\">\n";
$cont = addContinuationsEntry('jsonResourceGroupStore');
- print "<div dojoType=\"dojo.data.ItemFileReadStore\" url=\"" . BASEURL;
+ print "<div dojoType=\"dojo.data.ItemFileWriteStore\" url=\"" . BASEURL;
print SCRIPT . "?continuation=$cont\"
jsid=\"resourcegroupstore\"></div>\n";
print "<div dojoType=\"dojo.data.ItemFileWriteStore\"\n";
print "data=\"{'identifier':'id', 'label':'name', 'items':[]}\" \n";
@@ -283,6 +276,15 @@ function viewGroups() {
print "</thead>\n";
print "</table>\n";
print "</div>\n";
+
+ print "<div id=\"confirmDeleteDialog\" dojoType=\"dijit.Dialog\">\n";
+ print "<h2 id=\"confirmDeleteHeading\"></h2>\n";
+ print "<div id=\"confirmDeleteQuestion\"></div><br>\n";
+ print "<div id=\"confdelcontent\"></div><br>\n";
+ print dijitButton('deleteBtn', i("Delete Group"),
"submitDeleteGroup();");
+ print dijitButton('', i("Cancel"), "clearHideConfirmDelete();");
+ print "<input type=hidden id=\"submitdeletecont\">\n";
+ print "</div>\n";
}
////////////////////////////////////////////////////////////////////////////////
@@ -1336,6 +1338,7 @@ function checkForGroupUsage($groupid, $t
$msg = "$name is currently in use in the following
ways. It "
. "cannot be deleted until it is no longer in
use.<br><br>\n"
. implode("<br>\n", $msgs);
+ $msg = wordwrap($msg, 75, "<br>");
return 1;
}
return 0;
@@ -1369,6 +1372,7 @@ function checkForGroupUsage($groupid, $t
$msg = "$name is currently in use in the following ways. It "
. "cannot be deleted until it is no longer in
use.<br><br>\n"
. implode("<br>\n", $msgs);
+ $msg = wordwrap($msg, 75, "<br>");
return 1;
}
return 0;
@@ -1561,14 +1565,14 @@ function submitAddGroup() {
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn confirmDeleteGroup()
+/// \fn AJconfirmDeleteGroup()
///
-/// \brief prints a form to confirm the deletion of an group
+/// \brief generates and sends content prompting user to confirm deletion of
+/// group
///
////////////////////////////////////////////////////////////////////////////////
-function confirmDeleteGroup() {
+function AJconfirmDeleteGroup() {
global $user;
- $groupid = getContinuationVar("groupid");
$type = getContinuationVar("type");
$usergroups = getUserGroups();
@@ -1576,8 +1580,10 @@ function confirmDeleteGroup() {
$groupid = processInputVar('groupid', ARG_NUMERIC);
if($type == 'user') {
if(! array_key_exists($groupid, $usergroups)) {
- print "<h2>Delete User Group</h2>\n";
- print "The selected user group does not exist.\n";
+ $rt = array('status' => 'nogroup',
+ 'title' => _('Delete User Group Error'),
+ 'msg' => _('The selected user group was not
found.'));
+ sendJSON($rt);
return;
}
if($usergroups[$groupid]['ownerid'] != $user['id']) {
@@ -1586,14 +1592,18 @@ function confirmDeleteGroup() {
if(! checkUserHasPerm('Manage Federated User
Groups (global)') &&
(! checkUserHasPerm('Manage Federated User
Groups (affiliation only)') ||
$usergroups[$groupid]['groupaffiliationid']
!= $user['affiliationid'])) {
- print "<h2>Delete User Group</h2>\n";
- print "You do not have access to delete
the selected user group.\n";
+ $rt = array('status' => 'noaccess',
+ 'title' => _('Delete User
Group Error'),
+ 'msg' => _('You do not have
access to delete the selected user group.'));
+ sendJSON($rt);
return;
}
}
else {
- print "<h2>Delete User Group</h2>\n";
- print "You do not have access to delete the
selected user group.\n";
+ $rt = array('status' => 'noaccess',
+ 'title' => _('Delete User Group
Error'),
+ 'msg' => _('You do not have access
to delete the selected user group.'));
+ sendJSON($rt);
return;
}
}
@@ -1603,8 +1613,10 @@ function confirmDeleteGroup() {
($checkname == 'Specify End Time' ||
$checkname == 'Allow No User Check' ||
$checkname == 'Default for Editable by')) {
- print "<h2>Delete User Group</h2>\n";
- print "{$usergroups[$groupid]['name']} is a system
group that cannot be deleted";
+ $rt = array('status' => 'noaccess',
+ 'title' => _('Delete User Group Error'),
+ 'msg' => sprintf(_('%s is a system group
that cannot be deleted'), "<strong>{$usergroups[$groupid]['name']}</strong>"));
+ sendJSON($rt);
return;
}
}
@@ -1619,8 +1631,10 @@ function confirmDeleteGroup() {
}
}
if($noaccess) {
- print "<h2>Delete Resource Group</h2>\n";
- print "You do not have access to delete the selected
resource group.\n";
+ $rt = array('status' => 'noaccess',
+ 'title' => _('Delete Resource Group Error'),
+ 'msg' => _('You do not have access to
delete the selected resource group.'));
+ sendJSON($rt);
return;
}
}
@@ -1628,96 +1642,84 @@ function confirmDeleteGroup() {
$resourcegroups = getResourceGroups();
if($type == "user") {
- $title = "Delete User Group";
- $usemsg = "This group is currently in use. You cannot delete
it until "
- . "it is no longer being used.";
- $question = "Delete the following user group?";
+ $title = _("Delete User Group");
+ $usemsg = wordwrap(_("This group is currently in use. You
cannot delete it until it is no longer being used."), 75, "<br>");
+ $question = _("Delete the following user group?");
$name = $usergroups[$groupid]["name"];
$target = "";
}
else {
- $title = "Delete Resource Group";
- $usemsg = "This group is currently assigned to at least one
node in the "
- . "privilege tree. You cannot delete it until it is no
longer "
- . "in use.";
- $question = "Delete the following resource group?";
+ $title = _("Delete Resource Group");
+ $usemsg = wordwrap(_("This group is currently assigned to at
least one node in the privilege tree. You cannot delete it until it is no
longer in use."), 75, "<br>");
+ $question = _("Delete the following resource group?");
list($resourcetype, $name) =
explode('/', $resourcegroups[$groupid]["name"]);
$target = "#resources";
}
if(checkForGroupUsage($groupid, $type, $usemsg)) {
- print "<H2 align=center>$title</H2>\n";
- print $usemsg;
+ $rt = array('status' => 'inuse',
+ 'title' => $title,
+ 'msg' => $usemsg);
+ sendJSON($rt);
return;
}
- print "<DIV align=center>\n";
- print "<H2>$title</H2>\n";
- print "$question<br><br>\n";
- print "<TABLE>\n";
+ $cdata = array('type' => $type,
+ 'groupid' => $groupid);
+
+ $cont = addContinuationsEntry('AJsubmitDeleteGroup', $cdata, 3600, 1,
0);
+
+ $rt = array('status' => 'success',
+ 'title' => $title,
+ 'question' => $question,
+ 'cont' => $cont);
+
+ $h = "<TABLE>";
if($type == "resource") {
- print " <TR>\n";
- print " <TH align=right>Type:</TH>\n";
- print " <TD>$resourcetype</TD>\n";
- print " </TR>\n";
- }
- print " <TR>\n";
- print " <TH align=right>Name:</TH>\n";
- print " <TD>$name</TD>\n";
- print " </TR>\n";
+ $h .= "<TR>";
+ $h .= "<TH align=right>" . _("Type:") . "</TH>";
+ $h .= "<TD>" . _($resourcetype) . "</TD>";
+ $h .= "</TR>";
+ }
+ $h .= "<TR>";
+ $h .= "<TH align=right>" . _("Name:") . "</TH>";
+ $h .= "<TD>$name</TD>";
+ $h .= "</TR>";
if($type == "resource") {
- print " <TR>\n";
- print " <TH align=right>Owning User Group:</TH>\n";
- print " <TD>" . $resourcegroups[$groupid]["owner"] .
"</TD>\n";
- print " </TR>\n";
+ $h .= "<TR>";
+ $h .= "<TH align=right>" . _("Owning User Group:") . "</TH>";
+ $h .= "<TD>" . $resourcegroups[$groupid]["owner"] . "</TD>";
+ $h .= "</TR>";
}
elseif($usergroups[$groupid]['courseroll'] == 1 ||
$usergroups[$groupid]['custom'] == 0) {
- print "<TR>\n";
- print " <TH align=right>Type:</TH>\n";
+ $h .= "<TR>";
+ $h .= " <TH align=right>" . _("Type:") . "</TH>";
if($usergroups[$groupid]['courseroll'] == 1)
- print " <TD>Course Roll</TD>\n";
+ $h .= " <TD>" . _("Course Roll") . "</TD>";
elseif($usergroups[$groupid]['custom'] == 0)
- print " <TD>Federated</TD>\n";
- print "</TR>\n";
- print "<TR>\n";
- print " <TD colspan=2><br><strong>Note</strong>: This type of
group is ";
- print "created from external sources<br>and could be recreated
from ";
- print "those sources at any time.<br><br></TD>\n";
- print "</TR>\n";
- }
- print "</TABLE>\n";
- print "<TABLE>\n";
- print " <TR valign=top>\n";
- print " <TD>\n";
- print " <FORM action=\"" . BASEURL . SCRIPT . "$target\"
method=post>\n";
- $cdata = array('groupid' => $groupid,
- 'type' => $type);
- $cont = addContinuationsEntry('submitDeleteGroup', $cdata);
- print " <INPUT type=hidden name=continuation value=\"$cont\">\n";
- print " <INPUT type=submit value=Submit>\n";
- print " </FORM>\n";
- print " </TD>\n";
- print " <TD>\n";
- print " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
- print " <INPUT type=hidden name=mode value=viewGroups>\n";
- print " <INPUT type=submit value=Cancel>\n";
- print " </FORM>\n";
- print " </TD>\n";
- print " </TR>\n";
- print "</TABLE>\n";
- print "</DIV>\n";
+ $h .= " <TD>" . _("Federated") . "</TD>";
+ $h .= "</TR>";
+ $h .= "<TR>";
+ $h .= " <TD colspan=2><br><strong>" . _("Note") . "</strong>:";
+ $h .= wordwrap(_("This type of group is created from external
sources and could be recreated from those sources at any time."), 75, "<br>");
+ $h .= "</TD>";
+ $h .= "</TR>";
+ }
+ $h .= "</TABLE>";
+ $rt['content'] = $h;
+ sendJSON($rt);
}
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn submitDeleteGroup()
+/// \fn AJsubmitDeleteGroup()
///
-/// \brief deletes an group from the database and notifies the user
+/// \brief deletes a group from the database and notifies the user
///
////////////////////////////////////////////////////////////////////////////////
-function submitDeleteGroup() {
+function AJsubmitDeleteGroup() {
$groupid = getContinuationVar("groupid");
$type = getContinuationVar("type");
if($type == "user") {
@@ -1733,7 +1735,10 @@ function submitDeleteGroup() {
. "WHERE id = $groupid";
doQuery($query, 315);
clearPrivCache();
- viewGroups();
+ $data = array('status' => 'success',
+ 'type' => $type,
+ 'id' => $groupid);
+ sendJSON($data);
}
////////////////////////////////////////////////////////////////////////////////
Modified: vcl/trunk/web/.ht-inc/states.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/states.php?rev=1758441&r1=1758440&r2=1758441&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/states.php (original)
+++ vcl/trunk/web/.ht-inc/states.php Tue Aug 30 18:54:36 2016
@@ -219,6 +219,8 @@ $noHTMLwrappers = array('sendRDPfile',
'AJdeleteMessages',
'AJvalidateMessagesPoll',
'AJsetTZoffset',
+ 'AJconfirmDeleteGroup',
+ 'AJsubmitDeleteGroup',
);
# main
@@ -344,8 +346,8 @@ $actions['mode']['submitEditGroup'] = "s
$actions['mode']['confirmAddGroup'] = "confirmEditOrAddGroup";
$actions['args']['confirmAddGroup'] = 1;
$actions['mode']['submitAddGroup'] = "submitAddGroup";
-$actions['mode']['confirmDeleteGroup'] = "confirmDeleteGroup";
-$actions['mode']['submitDeleteGroup'] = "submitDeleteGroup";
+$actions['mode']['AJconfirmDeleteGroup'] = "AJconfirmDeleteGroup";
+$actions['mode']['AJsubmitDeleteGroup'] = "AJsubmitDeleteGroup";
$actions['mode']['addGroupUser'] = "addGroupUser";
$actions['mode']['deleteGroupUser'] = "deleteGroupUser";
$actions['mode']['jsonGetGroupInfo'] = "jsonGetGroupInfo";
@@ -358,8 +360,8 @@ $actions['pages']['confirmEditGroup'] =
$actions['pages']['submitEditGroup'] = "manageGroups";
$actions['pages']['confirmAddGroup'] = "manageGroups";
$actions['pages']['submitAddGroup'] = "manageGroups";
-$actions['pages']['confirmDeleteGroup'] = "manageGroups";
-$actions['pages']['submitDeleteGroup'] = "manageGroups";
+$actions['pages']['AJconfirmDeleteGroup'] = "manageGroups";
+$actions['pages']['AJsubmitDeleteGroup'] = "manageGroups";
$actions['pages']['addGroupUser'] = "manageGroups";
$actions['pages']['deleteGroupUser'] = "manageGroups";
$actions['pages']['jsonGetGroupInfo'] = "manageGroups";
Modified: vcl/trunk/web/.ht-inc/utils.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1758441&r1=1758440&r2=1758441&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Tue Aug 30 18:54:36 2016
@@ -12959,6 +12959,7 @@ function getDojoHTML($refresh) {
'dijit.form.TextBox',
'dojox.grid.DataGrid',
'dijit.TitlePane',
+ 'dijit.Dialog',
'dijit.Tooltip');
break;
case 'viewResources':
Modified: vcl/trunk/web/css/vcl.css
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/css/vcl.css?rev=1758441&r1=1758440&r2=1758441&view=diff
==============================================================================
--- vcl/trunk/web/css/vcl.css (original)
+++ vcl/trunk/web/css/vcl.css Tue Aug 30 18:54:36 2016
@@ -635,3 +635,8 @@ body {
.disabledlabel {
color: #888888;
}
+
+#confdelcontent th {
+ text-align: right;
+ padding-right: 0.5em;
+}
Modified: vcl/trunk/web/js/groups.js
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/js/groups.js?rev=1758441&r1=1758440&r2=1758441&view=diff
==============================================================================
--- vcl/trunk/web/js/groups.js (original)
+++ vcl/trunk/web/js/groups.js Tue Aug 30 18:54:36 2016
@@ -90,9 +90,61 @@ function fmtUserGroupDeleteBtn(groupid,
}
function confirmDeleteUserGroup(groupid) {
- // call url with continuation, groupid
- var cont = dojo.byId('deletegroupcont').value;
- window.location.href = 'index.php?continuation=' + cont + '&groupid=' +
groupid;
+ var data = {continuation: dojo.byId('deletegroupcont').value,
+ groupid: groupid};
+ RPCwrapper(data, confirmDeleteGroupCB, 1);
+}
+
+function confirmDeleteGroupCB(data, ioArgs) {
+ if(data.items.status == 'nogroup' ||
+ data.items.status == 'noaccess' ||
+ data.items.status == 'inuse') {
+ dojo.byId('confirmDeleteHeading').innerHTML = data.items.title;
+ dojo.byId('confirmDeleteQuestion').innerHTML = '';
+ dojo.byId('confdelcontent').innerHTML = data.items.msg;
+ hideDijitButton('deleteBtn');
+ }
+ else {
+ showDijitButton('deleteBtn');
+ dojo.byId('confirmDeleteHeading').innerHTML = data.items.title;
+ dojo.byId('confirmDeleteQuestion').innerHTML =
data.items.question;
+ dojo.byId('confdelcontent').innerHTML = data.items.content;
+ dojo.byId('submitdeletecont').value = data.items.cont;
+ }
+ dijit.byId('confirmDeleteDialog').show();
+}
+
+function clearHideConfirmDelete() {
+ dijit.byId('confirmDeleteDialog').hide();
+ dojo.removeClass('deleteBtn', 'hidden');
+ dojo.byId('confirmDeleteHeading').innerHTML = '';
+ dojo.byId('confirmDeleteQuestion').innerHTML = '';
+ dojo.byId('confdelcontent').innerHTML = '';
+}
+
+function submitDeleteGroup() {
+ var data = {continuation: dojo.byId('submitdeletecont').value};
+ RPCwrapper(data, submitDeleteGroupCB, 1);
+}
+
+function submitDeleteGroupCB(data, ioArgs) {
+ clearHideConfirmDelete();
+ if(data.items.type == 'user') {
+ usergroupstore.fetchItemByIdentity({
+ 'identity': data.items.id,
+ 'onItem': function(item) {
+ usergroupstore.deleteItem(item);
+ }
+ });
+ }
+ else {
+ resourcegroupstore.fetchItemByIdentity({
+ 'identity': data.items.id,
+ 'onItem': function(item) {
+ resourcegroupstore.deleteItem(item);
+ }
+ });
+ }
}
function fmtUserGroupEditBtn(groupid, rowIndex) {
@@ -237,9 +289,9 @@ function fmtResourceGroupDeleteBtn(group
}
function confirmDeleteResourceGroup(groupid) {
- // call url with continuation, groupid
- var cont = dojo.byId('deleteresgroupcont').value;
- window.location.href = 'index.php?continuation=' + cont + '&groupid=' +
groupid;
+ var data = {continuation: dojo.byId('deleteresgroupcont').value,
+ groupid: groupid};
+ RPCwrapper(data, confirmDeleteGroupCB, 1);
}
function fmtResourceGroupEditBtn(groupid, rowIndex) {