diff --git a/batch/saveusers.php b/batch/saveusers.php index 73a0bd6812..ebd3d01076 100644 --- a/batch/saveusers.php +++ b/batch/saveusers.php @@ -95,10 +95,10 @@ private function parse_csvp(CsvParser $csv) { while (($line = $csv->next_row())) { $this->ustatus->set_user(Contact::make($this->conf)); $this->ustatus->clear_messages(); + $this->ustatus->start_update((object) ["id" => null]); $this->ustatus->csvreq = $line; - $this->ustatus->jval = (object) ["id" => null]; $this->ustatus->parse_csv_group(""); - if (($acct = $this->ustatus->save_user($this->ustatus->jval))) { + if (($acct = $this->ustatus->save_update())) { if ($this->quiet) { // print nothing } else if (empty($this->ustatus->diffs)) { diff --git a/etc/profilegroups.json b/etc/profilegroups.json index f021b6fea2..0f1351e9a0 100644 --- a/etc/profilegroups.json +++ b/etc/profilegroups.json @@ -49,7 +49,7 @@ "save_members": true, "inputs": false }, { "name": "security/reauthenticate", - "order": 1, "alias": "__reauthenticate" }, + "order": 999999, "alias": "__reauthenticate" }, { "name": "security/newpassword", "order": 100, "title": "Change password", "print_function": "*Security_UserInfo::print_new_password", @@ -72,7 +72,7 @@ "request_function": "*Developer_UserInfo::request", "save_members": true }, { "name": "developer/reauthenticate", - "order": 1, "alias": "__reauthenticate" }, + "order": 999999, "alias": "__reauthenticate" }, { "name": "developer/tokens", "title": "API tokens", "order": 10, "print_function": "*Developer_UserInfo::print_bearer_tokens", "inputs": false }, diff --git a/src/conference.php b/src/conference.php index c287de1c7e..207ba2fbc3 100644 --- a/src/conference.php +++ b/src/conference.php @@ -3257,7 +3257,8 @@ function unparse_time_iso8601($timestamp) { * @param int $now * @return string */ function unparse_time_relative($timestamp, $now = 0, $format = 0) { - $d = abs($timestamp - ($now ? : Conf::$now)); + $now = $now ? : Conf::$now; + $d = abs($timestamp - $now); if ($d >= 5227200) { if (!($format & 1)) { return ($format & 8 ? "on " : "") . $this->_date_unparse($timestamp, "obscure"); @@ -3291,7 +3292,7 @@ function unparse_time_relative($timestamp, $now = 0, $format = 0) { if ($format & 2) { return $d; } else { - return $timestamp < ($now ? : Conf::$now) ? $d . " ago" : "in " . $d; + return $timestamp < $now ? $d . " ago" : "in " . $d; } } diff --git a/src/pages/p_profile.php b/src/pages/p_profile.php index 03ef3d3359..9e734abcc8 100644 --- a/src/pages/p_profile.php +++ b/src/pages/p_profile.php @@ -224,7 +224,7 @@ private function save_user($ustatus, $acct) { } // save account - return $ustatus->save_user($ustatus->jval, $acct); + return $ustatus->save_update($acct); } @@ -312,7 +312,7 @@ private function save_bulk($text, $filename) { while (($line = $csv->next_row())) { $ustatus->set_user(Contact::make_placeholder($this->conf)); $ustatus->clear_messages(); - $ustatus->jval = (object) ["id" => null]; + $ustatus->start_update((object) ["id" => null]); $ustatus->csvreq = $line; $ustatus->parse_csv_group(""); $ustatus->notify = friendly_boolean($line["notify"]) ?? true; @@ -367,7 +367,7 @@ private function handle_save() { // prepare UserStatus $this->ustatus->set_user($this->user); - $this->ustatus->jval = (object) ["id" => $this->user->has_account_here() ? $this->user->contactId : "new"]; + $this->ustatus->start_update((object) ["id" => $this->user->has_account_here() ? $this->user->contactId : "new"]); $this->ustatus->no_deprivilege_self = true; if ($this->page_type !== 0) { $this->ustatus->update_profile_if_empty = true; diff --git a/src/userinfo/u_security.php b/src/userinfo/u_security.php index 10e808b85e..1328e100ab 100644 --- a/src/userinfo/u_security.php +++ b/src/userinfo/u_security.php @@ -66,7 +66,7 @@ static function print_reauthenticate(UserStatus $us) { } $us->cs()->add_section_class("form-outline-section tag-yellow w-text") ->print_start_section("Confirm account", "reauth"); - echo '

You must confirm your signin credentials before changing sensitive security settings.

'; + echo '

Please re-enter your signin credentials to change sensitive security settings.

'; $original_ignore_msgs = $us->swap_ignore_messages(false); $us->swap_ignore_messages($original_ignore_msgs); echo '
', @@ -75,7 +75,7 @@ static function print_reauthenticate(UserStatus $us) { '', $us->feedback_html_at("reauth:password"), Ht::entry("reauth:email", $us->viewer->email, ["autocomplete" => "username", "class" => "hidden ignore-diff", "readonly" => true]), - Ht::password("reauth:password", "", ["size" => 52, "autocomplete" => "current-password", "class" => "ignore-diff", "id" => "reauth:password", "autofocus" => true]), + Ht::password("reauth:password", "", ["size" => 52, "autocomplete" => "current-password", "class" => "ignore-diff", "id" => "reauth:password"]), '
', '
', Ht::submit("reauth", "Confirm account", ["class" => "btn-success mt-0"]), diff --git a/src/userstatus.php b/src/userstatus.php index 9fb8018b52..2e1b1bf2a4 100644 --- a/src/userstatus.php +++ b/src/userstatus.php @@ -444,19 +444,18 @@ static function unparse_json_main(UserStatus $us) { } function user_json() { - if ($this->user) { - $this->jval = (object) []; - if ($this->user->contactId > 0) { - $this->jval->id = $this->user->contactId; - } - $cs = $this->cs(); - foreach ($cs->members("", "unparse_json_function") as $gj) { - $cs->call_function($gj, $gj->unparse_json_function, $gj); - } - return $this->jval; - } else { + if (!$this->user) { return null; } + $this->jval = (object) []; + if ($this->user->contactId > 0) { + $this->jval->id = $this->user->contactId; + } + $cs = $this->cs(); + foreach ($cs->members("", "unparse_json_function") as $gj) { + $cs->call_function($gj, $gj->unparse_json_function, $gj); + } + return $this->jval; } @@ -893,14 +892,31 @@ static function crosscheck_main(UserStatus $us) { } + /** @param object $cj */ + function start_update($cj) { + assert(is_object($cj)); + $this->jval = $cj; + $this->diffs = []; + $this->created = $this->notified = false; + } + /** @param object $cj * @param ?Contact $old_user * @return ?Contact */ function save_user($cj, $old_user = null) { assert(is_object($cj)); - assert(!$old_user || (!$this->no_create && !$this->no_modify)); + $this->jval = $cj; $this->diffs = []; $this->created = $this->notified = false; + $this->save_update($old_user); + } + + /** @param ?Contact $old_user + * @return ?Contact */ + function save_update($cj, $old_user = null) { + assert(is_object($this->jval)); + assert(!$old_user || (!$this->no_create && !$this->no_modify)); + $cj = $this->jval; // normalize name, including email self::normalize_name($cj); diff --git a/stylesheets/style.css b/stylesheets/style.css index 7c40cc2c35..72ae3eb565 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1468,9 +1468,19 @@ button:hover, button:focus, button:active, button:focus-within, border-color: #005f00; background-image: linear-gradient(#00a200, #007f00); } +.btn-danger { + color: #cc0000; +} +.btn-danger:hover, .btn-danger:active { + border: 1px solid #b00000; + background: #ff0000; + background-image: linear-gradient(#ee0000, #cc0000); + color: white; +} .differs .btn-default, .differs .btn-primary, -.btn-highlight { +.btn-highlight, +.btn-highlight.btn-danger { border-color: #cc0000; background: #ff0000; background-image: linear-gradient(#ff4040, #ff0000); @@ -1482,15 +1492,6 @@ button:hover, button:focus, button:active, button:focus-within, border: 1px solid #b00000; background-image: linear-gradient(#ee0000, #cc0000); } -.btn-danger { - color: #cc0000; -} -.btn-danger:hover, .btn-danger:active { - border: 1px solid #b00000; - background: #ff0000; - background-image: linear-gradient(#ee0000, #cc0000); - color: white; -} a.btn-default, a.btn-primary, a.btn-success, a.btn-highlight, a.btn-default:hover, a.btn-primary:hover, a.btn-success:hover, a.btn-highlight:hover, a.btn-danger:hover, a.btn-danger:active { @@ -1690,6 +1691,10 @@ button > .licon, .btn > .licon { position: absolute; left: 100%; } +.checkmark-before::before { + content: "\2713"; + padding-right: 0.25em; +} .is-mf.mf-success::after { content: "\2713"; color: #00bb00;