From 1325db43720e7511722bd5da98f6cad388b1722b Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Sat, 16 Sep 2023 08:59:34 -0400 Subject: [PATCH] Improve edit messages on new submissions. - If deadline has passed, don't show a bogus "Edit Contacts" section. - If deadline has passed, show a centered error message, no left nav. --- etc/msgs.json | 3 ++- src/contact.php | 12 +++++++----- src/pages/p_paper.php | 32 ++++++++++++++++++++------------ src/paperrequest.php | 8 ++------ src/papertable.php | 8 ++++---- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/etc/msgs.json b/etc/msgs.json index a874f5ddb..c2389ae83 100644 --- a/etc/msgs.json +++ b/etc/msgs.json @@ -138,8 +138,9 @@ ["permission_error", "<0>You aren’t allowed to view the {field} field.", ["{action}=field:view", "!{pid}"]], ["signin_required", "<5>You must sign in to access this page"], + ["signin_required", "<5>You must sign in in order to start a new submission.", ["{action}=paper:start"]], ["signin_required", "<0>You must sign in to access this page", ["!{url}"]], - ["signin_required", "<5>Sign in to your HotCRP account to make changes", ["{page}=paper:edit"]], + ["signin_required", "<5>Sign in to your HotCRP account to make changes", ["{action}=paper:edit"]], ["etime", "<0>Action not available.", "<0>Authors can’t view reviews for submission #{pid} now.", ["{deadline}=au_seerev"]], ["etime", "<0>Action not available.", "<0>The site is not open for reviewing.", ["{deadline}=rev_open"]], diff --git a/src/contact.php b/src/contact.php index ad5a650fe..a91edbe8e 100644 --- a/src/contact.php +++ b/src/contact.php @@ -3171,14 +3171,16 @@ function act_reviewer_sql($table) { /** @param bool $allow_no_email * @return ?PermissionProblem */ function perm_start_paper(PaperInfo $prow, $allow_no_email = false) { - if (!$this->email && !$allow_no_email) { - return new PermissionProblem($this->conf, ["signin" => true]); + if ($this->can_administer($prow)) { + return null; } $sr = $prow->submission_round(); - if ($sr->time_register(true) || $this->can_administer($prow)) { - return null; - } else { + if (!$sr->time_register(true)) { return new PermissionProblem($this->conf, ["deadline" => "sub_reg", "override" => $this->privChair]); + } else if (!$this->email && !$allow_no_email) { + return new PermissionProblem($this->conf, ["signin" => "paper:start"]); + } else { + return null; } } diff --git a/src/pages/p_paper.php b/src/pages/p_paper.php index 64262254b..c70f91fb1 100644 --- a/src/pages/p_paper.php +++ b/src/pages/p_paper.php @@ -34,10 +34,18 @@ function pt() { /** @param bool $error */ function print_header($error) { - PaperTable::print_header($this->pt, $this->qreq, $error); + $pt = $this->prow ? $this->pt() : null; + PaperTable::print_header($pt, $this->qreq, $error); } - function error_exit() { + /** @param ?PermissionProblem $perm */ + function error_exit($perm = null) { + if ($perm) { + $perm->set("listViewable", $this->user->is_author() || $this->user->is_reviewer()); + if (!$perm->secondary || $this->conf->saved_messages_status() < 2) { + $this->conf->error_msg("<5>" . $perm->unparse_html()); + } + } $this->print_header(true); Ht::stash_script("hotcrp.shortcut().add()"); $this->qreq->print_footer(); @@ -53,11 +61,7 @@ function load_prow() { assert(PaperRequest::simple_qreq($this->qreq)); throw $redir; } catch (PermissionProblem $perm) { - $perm->set("listViewable", $this->user->is_author() || $this->user->is_reviewer()); - if (!$perm->secondary || $this->conf->saved_messages_status() < 2) { - $this->conf->error_msg("<5>" . $perm->unparse_html()); - } - $this->error_exit(); + $this->error_exit($perm); } } @@ -489,11 +493,15 @@ static function go(Contact $user, Qrequest $qreq) { $pp = new Paper_Page($user, $qreq); $pp->load_prow(); - // fix user - if ($pp->prow->paperId === 0 - && $user->privChair - && !$pp->prow->submission_round()->time_register(true)) { - $user->add_overrides(Contact::OVERRIDE_CONFLICT); + // new papers: maybe fix user, maybe error exit + if ($pp->prow->paperId === 0) { + if (!$pp->prow->submission_round()->time_register(true) + && $user->privChair) { + $user->add_overrides(Contact::OVERRIDE_CONFLICT); + } + if (($perm = $user->perm_start_paper($pp->prow))) { + $pp->error_exit($perm); + } } // fix request diff --git a/src/paperrequest.php b/src/paperrequest.php index 653648654..59f912a6a 100644 --- a/src/paperrequest.php +++ b/src/paperrequest.php @@ -151,7 +151,7 @@ private function find_pid($conf, $user, $qreq) { private function signin_redirection($qreq, $pid) { $conf = $qreq->conf(); return new PermissionProblem($conf, [ - "signin" => true, + "signin" => $pid ? "paper" : "paper:start", "signinUrl" => $conf->hoturl_raw("signin", ["redirect" => $conf->selfurl($qreq, ["p" => $pid ? : "new"], Conf::HOTURL_SITEREL | Conf::HOTURL_RAW)]), "secondary" => true ]); @@ -213,11 +213,7 @@ function find_paper($qreq) { $user = $qreq->user(); $pid = $this->find_pid($user->conf, $user, $qreq); if ($pid === 0) { - if ($user->has_email()) { - return PaperInfo::make_new($user, $qreq->sclass); - } else { - throw $this->signin_redirection($qreq, 0); - } + return PaperInfo::make_new($user, $qreq->sclass); } else { $options = ["topics" => true, "options" => true]; if ($user->privChair diff --git a/src/papertable.php b/src/papertable.php index 33a3a8b17..f7acce88e 100644 --- a/src/papertable.php +++ b/src/papertable.php @@ -2354,10 +2354,10 @@ private function _print_editable_body() { $overrides = $this->user->add_overrides(Contact::OVERRIDE_EDIT_CONDITIONS); echo '

'; if ($this->prow->paperId) { - echo "Edit Submission"; + echo "Edit submission"; } else { $sr = $this->prow->submission_round(); - echo "New ", $sr->title1, "Submission"; + echo "New ", $sr->title1, "submission"; } echo '

'; @@ -2443,7 +2443,7 @@ function print_paper_info() { echo ''; - } else if ($this->editable) { + } else if ($this->editable || $this->prow->paperId <= 0) { echo '
'; $this->_print_editable_body(); echo '
'; @@ -2452,7 +2452,7 @@ function print_paper_info() { } echo ''; - if (!$this->editable && $this->mode === "edit") { + if (!$this->editable && $this->mode === "edit" && $this->prow->paperId > 0) { echo '
', '

Edit Contacts

'; $this->_print_edit_messages(false);