Skip to content

Commit

Permalink
Improve edit messages on new submissions.
Browse files Browse the repository at this point in the history
- If deadline has passed, don't show a bogus "Edit Contacts" section.
- If deadline has passed, show a centered error message, no left nav.
  • Loading branch information
kohler committed Sep 16, 2023
1 parent b373805 commit 1325db4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
3 changes: 2 additions & 1 deletion etc/msgs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"{url}\">sign in</a> to access this page"],
["signin_required", "<5>You must <a href=\"{url}\">sign in</a> 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><a href=\"{url}\">Sign in to your HotCRP account</a> to make changes", ["{page}=paper:edit"]],
["signin_required", "<5><a href=\"{url}\">Sign in to your HotCRP account</a> 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"]],
Expand Down
12 changes: 7 additions & 5 deletions src/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
32 changes: 20 additions & 12 deletions src/pages/p_paper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/paperrequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/papertable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2354,10 +2354,10 @@ private function _print_editable_body() {
$overrides = $this->user->add_overrides(Contact::OVERRIDE_EDIT_CONDITIONS);
echo '<div class="pedcard-head"><h2><span class="pedcard-header-name">';
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 '</span></h2></div>';

Expand Down Expand Up @@ -2443,7 +2443,7 @@ function print_paper_info() {
echo '</div><div class="need-clickthrough-show hidden">';
$this->_print_editable_body();
echo '</div></div>';
} else if ($this->editable) {
} else if ($this->editable || $this->prow->paperId <= 0) {
echo '<div id="foldpaper">';
$this->_print_editable_body();
echo '</div>';
Expand All @@ -2452,7 +2452,7 @@ function print_paper_info() {
}
echo '</div>';

if (!$this->editable && $this->mode === "edit") {
if (!$this->editable && $this->mode === "edit" && $this->prow->paperId > 0) {
echo '<div class="pcard papcard">',
'<div class="pedcard-head"><h2><span class="pedcard-header-name">Edit Contacts</span></h2></div>';
$this->_print_edit_messages(false);
Expand Down

0 comments on commit 1325db4

Please sign in to comment.