From 98402844e6f80290b67aa2b5d5923435f334e5b6 Mon Sep 17 00:00:00 2001 From: Stephen Beaver Date: Wed, 2 Sep 2015 10:36:36 -0400 Subject: Fixed #5028 Restored correct delcert action --- src/usr/local/www/system_certmanager.php | 88 +++++++++++++++++++++----------- src/usr/local/www/system_usermanager.php | 53 +++++++++++-------- 2 files changed, 90 insertions(+), 51 deletions(-) (limited to 'src/usr') diff --git a/src/usr/local/www/system_certmanager.php b/src/usr/local/www/system_certmanager.php index f9f2702..6ee5fbb 100644 --- a/src/usr/local/www/system_certmanager.php +++ b/src/usr/local/www/system_certmanager.php @@ -1,32 +1,59 @@ addClass('toggle-existing collapse'); $existCerts = array(); -foreach ($config['cert'] as $cert) -{ - if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) - continue; + +foreach ($config['cert'] as $cert) { + if(is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA! + if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) + continue; + } $ca = lookup_ca($cert['caref']); if ($ca) @@ -979,6 +1008,7 @@ foreach ($config['cert'] as $cert) $existCerts[ $cert['refid'] ] = $cert['descr']; } + $section->addInput(new Form_Select( 'certref', 'Existing Certificates', diff --git a/src/usr/local/www/system_usermanager.php b/src/usr/local/www/system_usermanager.php index f6e8596..4493ff2 100644 --- a/src/usr/local/www/system_usermanager.php +++ b/src/usr/local/www/system_usermanager.php @@ -153,6 +153,21 @@ if (isset($_POST['dellall_x'])) { } } +if ($_POST['act'] == "delcert") { + + if (!$a_user[$id]) { + pfSenseHeader("system_usermanager.php"); + exit; + } + + $certdeleted = lookup_cert($a_user[$id]['cert'][$_POST['certid']]); + $certdeleted = $certdeleted['descr']; + unset($a_user[$id]['cert'][$_POST['certid']]); + write_config(); + $_POST['act'] = "edit"; + $savemsg = gettext("Certificate") . " {$certdeleted} " . gettext("association removed.") . "
"; +} + if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; @@ -259,15 +274,8 @@ if ($_POST['save']) { if ($a_user[$id] && !empty($_POST['privid'])) { foreach ($_POST['privid'] as $i) unset($a_user[$id]['priv'][$i]); - local_user_set($a_user[$id]); - write_config(); - } - - // This used to be a separate act=delcert - if ($a_user[$id] && !empty($_POST['certid'])) { - foreach ($_POST['certid'] as $i) - unset($a_user[$id]['cert'][$i]); + local_user_set($a_user[$id]); write_config(); } @@ -392,12 +400,7 @@ function build_priv_table() { return($privhtml); } -/* -'; " title="" /> -*/ + function build_cert_table() { global $a_user, $id; @@ -407,7 +410,7 @@ function build_cert_table() { $certhtml .= ''; $certhtml .= '' . gettext('Name') . ''; $certhtml .= '' . gettext('CA') . ''; - $certhtml .= ''; + $certhtml .= ''; $certhtml .= ''; $certhtml .= ''; $certhtml .= ''; @@ -424,10 +427,8 @@ function build_cert_table() { $certhtml .= '' . htmlspecialchars($cert['descr']) . $revokedstr . ''; $certhtml .= '' . htmlspecialchars($ca['descr']) . ''; $certhtml .= ''; - $certhtml .= 'Delete'; + $certhtml .= 'Delete'; $certhtml .= ''; $certhtml .= ''; $i++; @@ -451,8 +452,9 @@ include("head.inc"); if ($input_errors) print_input_errors($input_errors); + if ($savemsg) - print_info_box($savemsg); + print_info_box($savemsg, 'success'); $tab_array = array(); $tab_array[] = array(gettext("Users"), true, "system_usermanager.php"); @@ -531,7 +533,6 @@ $form = new Form; if ($act == "new" || $act == "edit" || $input_errors): - $form->addGlobal(new Form_Input( 'act', null, @@ -876,7 +877,6 @@ events.push(function(){ $("#movetodisabled").prop('type','button'); $("#movetoenabled").prop('type','button'); - // On click . . $("#movetodisabled").click(function() { moveOptions($('[name="groups[]"] option'), $('[name="sysgroups[]"]')); @@ -894,6 +894,15 @@ events.push(function(){ hideInput('authorizedkeys', !this.checked); }); + $('[id^=delcert]').click(function(event) { + if(confirm(event.target.title)) { + $('#certid').val(event.target.id.match(/\d+$/)[0]); + $('#userid').val(''); + $('#act').val('delcert'); + $('form').submit(); + } + }); + // On page load . . hideClass('cert-options', true); hideInput('authorizedkeys', true); -- cgit v1.1