When a user account is modified, the 'My Account' link should contain the new username, otherwise clicking it directly after editing a username will result in a 404.
Signed-off-by: Marcel Korpel <marcel.kor...@gmail.com> --- web/html/account.php | 12 +++++++++--- web/html/register.php | 8 +++----- web/lib/acctfuncs.inc.php | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/web/html/account.php b/web/html/account.php index 8545478..675e880 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -21,14 +21,20 @@ if (in_array($action, $need_userinfo)) { if ($action == "AccountInfo") { html_header(__('Account') . ' ' . $row['Username']); -} else { +} elseif ($action == "DisplayAccount" || $action == "DeleteAccount") { html_header(__('Accounts')); } +// don't show header in case of UpdateAccount yet, as the username might be +// changed and then the 'My Account' link has to contain the new username, +// too # Main page processing here # -echo "<div class=\"box\">\n"; -echo " <h2>".__("Accounts")."</h2>\n"; +if ($action != "UpdateAccount") { + // only show header when not processing a form + echo "<div class=\"box\">\n"; + echo " <h2>".__("Accounts")."</h2>\n"; +} if (isset($_COOKIE["AURSID"])) { if ($action == "SearchAccounts") { diff --git a/web/html/register.php b/web/html/register.php index cb3e8dd..746974c 100644 --- a/web/html/register.php +++ b/web/html/register.php @@ -13,11 +13,6 @@ if (isset($_COOKIE["AURSID"])) { exit(); } -html_header(__('Register')); - -echo '<div class="box">'; -echo '<h2>' . __('Register') . '</h2>'; - if (in_request("Action") == "NewAccount") { process_account_form("new", "NewAccount", in_request("U"), 1, 0, in_request("E"), '', '', in_request("R"), @@ -25,6 +20,9 @@ if (in_request("Action") == "NewAccount") { in_request("PK")); } else { + html_header(__('Register')); + echo '<div class="box">'; + echo '<h2>' . __('Register') . '</h2>'; print '<p>' . __("Use this form to create an account.") . '</p>'; display_account_form("NewAccount", "", "", "", "", "", "", "", $LANG); } diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index ad907df..e2ea547 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -89,6 +89,25 @@ function display_account_form($A,$U="",$T="",$S="",$E="",$P="",$C="",$R="", } /** + * Display header and open div of account page + * + * @param string $TYPE Either "edit" for editing or "new" for registering an account + * + * @return void + */ +function display_account_resultpage_header($TYPE) { + if ($TYPE == "edit") { + html_header(__('Accounts')); + echo '<div class="box">'; + echo '<h2>' . __('Accounts') . '</h2>'; + } else { + html_header(__('Register')); + echo '<div class="box">'; + echo '<h2>' . __('Register') . '</h2>'; + } +} + +/** * Process information given to new/edit account form * * @global array $SUPPORTED_LANGS Languages that are supported by the AUR @@ -268,6 +287,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$P="",$C="", } if ($error) { + display_account_resultpage_header($TYPE); print "<ul class='errorlist'><li>".$error."</li></ul>\n"; display_account_form($A, $U, $T, $S, $E, "", "", $R, $L, $I, $K, $PK, $J, $UID, $N); @@ -298,6 +318,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$P="",$C="", $q.= "VALUES (1, 0, 0, $U, $E, $P, $salt, $R, $L, "; $q.= "$I, $K)"; $result = $dbh->exec($q); + display_account_resultpage_header($TYPE); if (!$result) { print __("Error trying to create account, %s%s%s.", "<strong>", htmlspecialchars($U,ENT_QUOTES), "</strong>"); @@ -370,6 +391,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$P="",$C="", $q.= ", InactivityTS = " . $inactivity_ts; $q.= " WHERE ID = ".intval($UID); $result = $dbh->exec($q); + display_account_resultpage_header($TYPE); $ssh_key_result = account_set_ssh_keys($UID, $ssh_keys, $ssh_fingerprints); -- 2.4.5