From 79c3f79e73e7d0da9f8dab0444085779735383c2 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 25 Sep 2009 23:23:10 +0000 Subject: [PATCH] - Update the user activate/deactivate form --- user_activate.php | 125 ++++++++++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 49 deletions(-) diff --git a/user_activate.php b/user_activate.php index ae7a2a2b..af878a14 100644 --- a/user_activate.php +++ b/user_activate.php @@ -32,9 +32,24 @@ exit; } +/* Sort out who we're editting */ +if($_POST['users_id']) + $eid = intval($_POST['users_id']); /* From a save form */ +else if(array_key_exists('embed_edit_id', $_SESSION)) + $eid = $_SESSION['embed_edit_id']; /* From the embedded editor */ +else + $eid = $_SESSION['users_id']; /* Regular entry */ + +if($eid != $_SESSION['users_id']) { + /* Not editing ourself, we had better be + * a committee member */ + user_auth_required('committee','admin'); +} + $u = user_load($eid); + /* Validate the type */ - if($_POST['action'] != '') { - $action_type = $_POST['action_type']; + if($_GET['action'] != '') { + $action_type = $_GET['type']; if(!in_array($action_type, $user_types)) { echo "ERROR: not an allowed type."; exit; @@ -42,15 +57,8 @@ $action_what = $user_what[$action_type]; } - if($_SESSION['embed'] == true) - $eid = $_SESSION['embed_edit_id']; - else - $eid = $_SESSION['users_id']; - - $u = user_load($eid); - - switch($_POST['action']) { - case 'delete': +switch($_GET['action']) { +case 'delete': //okay here we go, lets get rid of them completely, since this is what theyve asked for message_push(happy(i18n("Account successfully deleted. Goodbye"))); user_delete($u); @@ -60,26 +68,26 @@ header('location: user_login.php?action=logout'); exit; - case 'remove': +case 'remove': /* Like delete, only we're only deleting a role, not the whole account */ - message_push(happy(i18n("$action_what role successfully removed."))); + happy_("$action_what role successfully removed."); + echo error(i18n("Permanently Removed")); user_delete($u, $action_type); - break; + exit; case 'activate': $u["{$action_type}_active"] = 'yes'; user_save($u); - message_push(happy(i18n("$action_what role for %1 successfully activated",array($config['FAIRYEAR'])))); - break; + happy_("$action_what role for %1 successfully activated",array($config['FAIRYEAR'])); + echo happy(i18n("Active")); + exit; case 'deactivate': $u["{$action_type}_active"] = 'no'; user_save($u); - message_push(happy(i18n("$action_what role for %1 successfully deactivated",array($config['FAIRYEAR'])))); - break; - - default: - break; + happy_("$action_what role for %1 successfully deactivated",array($config['FAIRYEAR'])); + echo error(i18n("Deactivated")); + exit; } $u = user_load($u['id']); @@ -97,10 +105,41 @@ ); } - $action_url = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : $_SERVER['PHP_SELF']; +?> + +
+ + +'.i18n("Role: {$user_what[$t]}").''; + echo "
"; if($u["{$t}_active"] == 'yes') { echo happy(i18n('Active')); $a = 'disabled="disabled"'; @@ -110,34 +149,22 @@ $a = ''; $d = 'disabled="disabled"'; } +?> +
- echo '
'; - echo ""; - echo "\n"; - echo "\n"; - echo ""; - echo ""; +
+ onclick="activate('');return false;" type="submit" value=""> + + onclick="deactivate('');return false;" type="submit" value=""> + + onclick="remove('');return false;" type="submit" value=""> - echo ''; - - echo "
"; - echo "\n"; - echo "\n"; - echo ""; - echo "
"; - - echo '
'; - - echo "
"; - echo "\n"; - echo "\n"; - echo ""; - echo "
"; - - echo '
'; - echo '
'; - echo '
'; +
+
+
+"; echo ''; - echo "
"; - echo "\n"; + echo ""; + echo ""; echo ""; echo "
";