Skip to content

Commit 0db81ed

Browse files
caseysoftwareclaude
andcommitted
Restore the "delete User" action on the user view page
The "delete User" crumb links to javascript:delIt(), but the function and form it relied on were removed in ff632a3. On the User Log tab the click did nothing (delIt undefined). On the Permissions and Roles tabs it called those tabs' own delIt(id) with no id, asking to delete a permission or role instead of the user. - view.php defines delIt() and a frmDelete form (only when the user can be deleted) that posts del=1 to do_user_aed, which already handles deletion. The confirmation names the user and is JSON-encoded for JavaScript. - The tab functions are renamed delPerm() and delRole() so they no longer clash with the crumb. Refs #385 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016CP89WVmGZ1VVCCZMS6ntN
1 parent ac63e72 commit 0db81ed

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎modules/users/view.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,22 @@ function popChgPwd() {
7474
window.open( './index.php?m=public&a=chpwd&dialog=1&user_id=<?php echo $user->user_id; ?>', 'chpwd', 'top=250,left=250,width=350, height=220, scrollbars=no' );
7575
}
7676
<?php } ?>
77+
<?php if ($canDelete) { ?>
78+
// Called by the "delete User" crumb (w2p_Theme_TitleBlock::addCrumbDelete).
79+
function delIt() {
80+
if (confirm(<?php echo json_encode($AppUI->_('doDelete', UI_OUTPUT_RAW) . ' ' . $AppUI->_('User', UI_OUTPUT_RAW) . ' ' . $user->user_username . '?', JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>)) {
81+
document.frmDelete.submit();
82+
}
83+
}
84+
<?php } ?>
7785
</script>
86+
<?php if ($canDelete) { ?>
87+
<form name="frmDelete" action="./index.php?m=users" method="post" accept-charset="utf-8">
88+
<input type="hidden" name="dosql" value="do_user_aed" />
89+
<input type="hidden" name="del" value="1" />
90+
<input type="hidden" name="user_id" value="<?php echo (int) $user->user_id; ?>" />
91+
</form>
92+
<?php } ?>
7893
<?php
7994
$utypes = w2PgetSysVal('UserType');
8095

‎modules/users/vw_usr_perms.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function clearIt(){
8787
f.permission_grant_on.selectedIndex = 0;
8888
}
8989

90-
function delIt(id) {
90+
function delPerm(id) {
9191
if (confirm( 'Are you sure you want to delete this permission?' )) {
9292
var f = document.frmPerms;
9393
f.del.value = 1;
@@ -213,7 +213,7 @@ function setPermItem( key, val ) {
213213
$buf .= '<td nowrap="nowrap">';
214214
$canDelete = (canEdit('users') && $_canEdit);
215215
if ($canDelete) {
216-
$buf .= "<a href=\"javascript:delIt({$acl});\" title=\"" . $AppUI->_('delete') . "\">" . w2PshowImage('icons/stock_delete-16.png', 16, 16, '') . "</a>";
216+
$buf .= "<a href=\"javascript:delPerm({$acl});\" title=\"" . $AppUI->_('delete') . "\">" . w2PshowImage('icons/stock_delete-16.png', 16, 16, '') . "</a>";
217217
}
218218
$buf .= '</td>';
219219

‎modules/users/vw_usr_roles.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// else users would be able to arbitrarily run 'bad' functions
3333
if ($canEdit) {
3434
?>
35-
function delIt(id) {
35+
function delRole(id) {
3636
if (confirm( 'Are you sure you want to delete this role?' )) {
3737
var f = document.frmRoles;
3838
f.del.value = 1;
@@ -62,7 +62,7 @@ function clearIt(){
6262
$buf = "<td>" . $row['name'] . "</td>";
6363
$buf .= '<td nowrap>';
6464
if ($canEdit) {
65-
$buf .= "<a href=\"javascript:delIt({$row['id']});\" title=\"" . $AppUI->_('delete') . "\">" . w2PshowImage('icons/stock_delete-16.png', 16, 16, '') . '</a>';
65+
$buf .= "<a href=\"javascript:delRole({$row['id']});\" title=\"" . $AppUI->_('delete') . "\">" . w2PshowImage('icons/stock_delete-16.png', 16, 16, '') . '</a>';
6666
}
6767
$buf .= '</td>';
6868

0 commit comments

Comments
 (0)