[dev] updates to user module to include warning when deleting user

Ilya mail@krel.org
Thu, 5 Sep 2002 01:29:01 -0400


---------------------- multipart/mixed attachment
Chuck, these diffs are updates for admin/user, now when you try to delete a
user,
it gives you a page with warning that deleting a user, will possibly cause
removal of mail data (for cyrsql at least, it would depend on driver). If you
can put a better wording I wont object ;)

I didnt make it a pop-up window, as I know you try to stear away from pop-ups.
It appears the same way the update does, two buttons - Continue and Cancel
Cancel just brings back to default view.

---------------------- multipart/mixed attachment
--- list.inc.orig	Thu Sep  5 00:01:30 2002
+++ list.inc	Thu Sep  5 00:01:47 2002
@@ -9,7 +9,7 @@
 <tr class="item<?php echo $_i++%2 ?>">
     <td align="left"><?php echo $user ?></td>
 <?php if ($remove): ?>
-    <td width="1%"><?php echo Horde::link(Horde::applicationUrl('admin/user.php?form=remove&user_name=' . $user), _("Delete")) . _("Delete") ?></a></td>
+    <td width="1%"><?php echo Horde::link(Horde::applicationUrl('admin/user.php?form=remove_f&user_name=' . $user), _("Delete")) . _("Delete") ?></a></td>
 <?php endif; ?>
 <?php if ($update_t): ?>
     <td width="1%"><?php echo Horde::link(Horde::applicationUrl('admin/user.php?form=update_f&user_name=' . $user . '&do_update=1'), _("Update")) .  _("Update") ?></a></td>

---------------------- multipart/mixed attachment
<script language="JavaScript" type="text/javascript">
<!--
function validate_remove()
{
    if (document.removeuser.user_name.value == "") {
        document.removeuser.user_name.focus();
        alert('<?php echo _("You must specify the username to remove.") ?>');
        return false;
    }

    return true;
}

function cancel_remove()
{
    return false;
}


//-->
</script>

<form name="removeuser" method="post">
<input type="hidden" name="form" value="remove">

<table border="0" cellspacing="0" cellpadding="2">
<tr>
    <td align="left" class="header">
        <b><?php echo _("Remove user: ".$user_name) ?></b>
    </td>
</tr>
<tr>
<td>
<b><?php echo _("You are about to remove user and possibly mail for this user.") ?></b>
<br>
<b><?php echo _("This operation cannot be undone.") ?></b>
<br>
<b><?php echo _("Press REMOVE to continue or Cancel to cancel.") ?></b>
</td>
<tr>
  <td class="smallheader" align="right">
    <input type="submit" class="button" name="submit" onclick="return validate_remove();" value="<?php echo _("Remove user") ?>" />
    <input type="submit" class="button" name="submit" onclick="return validate_remove();" value="<?php echo _("Cancel") ?>" />
  </td>
</table>
</form>

<br />

---------------------- multipart/mixed attachment
--- user.php.orig	Thu Sep  5 00:45:11 2002
+++ user.php	Thu Sep  5 01:18:49 2002
@@ -49,7 +49,7 @@
     $f_user_name = Horde::getFormData('user_name');
     if (empty($f_user_name)) {
         $notification->push(_("You must specify a username to remove."), 'horde.message');
-    } else {
+    } elseif ( $submit !== "Cancel") {
         if (PEAR::isError($auth->removeUser($f_user_name))) {
             $notification->push(sprintf(_("There was a problem removing '%s' from the system."), $f_user_name), 'horde.error');
         } else {
@@ -63,6 +63,11 @@
     $update_form = 1;
     break;
 
+case 'remove_f':
+    $f_user_name = Horde::getFormData('user_name');
+    $remove_form = 1;
+    break;
+
 case 'update':
     $user_name_1 = Horde::getPost('user_name');
     $user_name_2 = Horde::getPost('user_name2');
@@ -100,11 +105,13 @@
 require HORDE_TEMPLATES . '/admin/common-header.inc';
 $notification->notify();
 
-// Add or update users.
-if ($auth->hasCapability('add') && !isset($update_form)) {
+// Add , update  or delete users.
+if ($auth->hasCapability('add') && !isset($update_form) && !isset($remove_form)) {
     include HORDE_TEMPLATES . '/admin/user/add.inc';
 } elseif ($auth->hasCapability('add') && isset($update_form) && $auth->hasCapability('update')){
     include HORDE_TEMPLATES . '/admin/user/update.inc';
+} elseif ($auth->hasCapability('add') && isset($remove_form) && $auth->hasCapability('remove')){
+    include HORDE_TEMPLATES . '/admin/user/remove.inc';
 } else {
     include HORDE_TEMPLATES . '/admin/user/noadd.inc';
 }

---------------------- multipart/mixed attachment--