- Update the user activate/deactivate form

This commit is contained in:
dave 2009-09-25 23:23:10 +00:00
parent 40abe88ae4
commit 79c3f79e73

View File

@ -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,14 +57,7 @@
$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']) {
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")));
@ -62,24 +70,24 @@
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'];
?>
<script type="text/javascript">
function activate(type)
{
$("#status_"+type).load("<?=$config['SFIABDIRECTORY']?>/user_activate.php?action=activate&type="+type,$('#activate_form').serializeArray());
$("#activate_"+type).attr('disabled', 'disabled');
$("#deactivate_"+type).removeAttr('disabled');
$("#remove_"+type).removeAttr('disabled');
}
function deactivate(type)
{
$("#status_"+type).load("<?=$config['SFIABDIRECTORY']?>/user_activate.php?action=deactivate&type="+type,$('#activate_form').serializeArray());
$("#activate_"+type).removeAttr('disabled');
$("#deactivate_"+type).attr('disabled', 'disabled');
$("#remove_"+type).attr('disabled', 'disabled');
}
function remove(type)
{
var con = confirmClick("<?=i18n("Are you sure you want to remove this role from your account?\\nThis action cannot be undone.")?>");
if(con == true) {
$("#status_"+type).load("<?=$config['SFIABDIRECTORY']?>/user_activate.php?action=remove&type="+type,$('#activate_form').serializeArray());
$("#activate_"+type).attr('disabled', 'disabled');
$("#deactivate_"+type).attr('disabled', 'disabled');
$("#remove_"+type).attr('disabled', 'disabled');
}
}
</script>
<form id="activate_form">
<input type="hidden" name="users_id" value="<?=$u['id']?>" />
<?
foreach($u['types'] as $t) {
echo '<h3>'.i18n("Role: {$user_what[$t]}").'</h3>';
echo "<div id=\"status_$t\">";
if($u["{$t}_active"] == 'yes') {
echo happy(i18n('Active'));
$a = 'disabled="disabled"';
@ -110,34 +149,22 @@
$a = '';
$d = 'disabled="disabled"';
}
?>
</div>
echo '<table><tr><td>';
echo "<form method=\"post\" action=\"$action_url\">";
echo "<input type=\"hidden\" name=\"action\" value=\"activate\">\n";
echo "<input type=\"hidden\" name=\"action_type\" value=\"$t\">\n";
echo "<input style=\"width: 200px;\" $a type=\"submit\" value=\"".i18n("Activate Role")."\">";
echo "</form>";
<table><tr><td>
<input style="width: 200px;" id="activate_<?=$t?>" <?=$a?> onclick="activate('<?=$t?>');return false;" type="submit" value="<?=i18n("Activate Role")?>">
</td><td>
<input style="width: 200px;" id="deactivate_<?=$t?>"<?=$d?> onclick="deactivate('<?=$t?>');return false;" type="submit" value="<?=i18n("Deactivate Role")?>">
</td><td>
<input style="width: 200px;" id="remove_<?=$t?>"<?=$d?> onclick="remove('<?=$t?>');return false;" type="submit" value="<?=i18n("Remove Role")?>">
echo '</td><td>';
echo "<form method=\"post\" action=\"$action_url\">";
echo "<input type=\"hidden\" name=\"action\" value=\"deactivate\">\n";
echo "<input type=\"hidden\" name=\"action_type\" value=\"$t\">\n";
echo "<input style=\"width: 200px;\" $d type=\"submit\" value=\"".i18n("Deactivate Role")."\">";
echo "</form>";
echo '</td><td>';
echo "<form method=\"post\" action=\"$action_url\">";
echo "<input type=\"hidden\" name=\"action\" value=\"remove\">\n";
echo "<input type=\"hidden\" name=\"action_type\" value=\"$t\">\n";
echo "<input style=\"width: 200px;\" $d onclick=\"return confirmClick('".i18n("Are you sure you want to remove this role from your account?\\nThis action cannot be undone.")."')\" type=\"submit\" value=\"".i18n("Remove Role")."\">";
echo "</form>";
echo '</td></tr></table>';
echo '<br />';
echo '<hr />';
</td></tr></table>
<br />
<hr />
<?
}
echo "</form>";
echo '<ul>';
echo '<li>'.i18n("An <b>Active Role</b> indicates you would like to participate in the %1 %2 as that role (Judge, Volunteer, etc.)",array($config['FAIRYEAR'],$config['fairname']));
@ -146,8 +173,8 @@
echo '</li><li>'.i18n("The <b>Delete Entire Account</b> button below completely deletes your entire account. You will not receive any future email for any roles. It completely removes you from the system. This action cannot be undone.");
echo '</ul>';
echo "<form method=\"post\" action=\"$action_url\">";
echo "<input type=\"hidden\" name=\"action\" value=\"delete\">\n";
echo "<form method=\"post\" action=\"{$config['SFIABDIRECTORY']}/user_activate.php?action=delete\">";
echo "<input type=\"hidden\" name=\"users_id\" value=\"{$u['id']}\" />";
echo "<input style=\"width: 300px;\" onclick=\"return confirmClick('".i18n("Are you sure you want to completely delete your account?\\nDoing so will remove you from our mailing list for future years and you will never hear from us again.\\nThis action cannot be undone.")."')\" type=\"submit\" value=\"".i18n("Delete Entire Account")."\">";
echo "</form>";