Skip to content

Commit

Permalink
Don't allow starting a paper with invalid submission class.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Sep 16, 2023
1 parent 6d005a5 commit 89d891f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/paperrequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ function find_paper($qreq) {
$user = $qreq->user();
$pid = $this->find_pid($user->conf, $user, $qreq);
if ($pid === 0) {
if (isset($qreq->sclass)
&& !$user->conf->submission_round_by_tag($qreq->sclass)) {
throw new PermissionProblem($user->conf, ["invalidSclass" => $qreq->sclass]);
}
return PaperInfo::make_new($user, $qreq->sclass);
} else {
$options = ["topics" => true, "options" => true];
Expand Down
16 changes: 8 additions & 8 deletions src/paperstatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private function _normalize($ipj) {
foreach (["submitted", "draft", "withdrawn", "final_submitted"] as $k) {
$v = $istatus->$k ?? null;
if ($v !== null && !is_bool($v)) {
$this->syntax_error_at("status.{$k}");
$this->syntax_error_at("status:{$k}");
$v = null;
}
$xstatus->$k = $v;
Expand All @@ -322,29 +322,29 @@ private function _normalize($ipj) {
if (is_numeric($v)) {
$v = (float) $v;
if ($v < 0) {
$this->error_at("status.{$k}", "<0>Negative date");
$this->error_at("status:{$k}", "<0>Negative date");
$v = null;
}
} else if (is_string($v)) {
$v = $this->conf->parse_time($v, Conf::$now);
if ($v === false || $v < 0) {
$this->error_at("status.{$k}", "<0>Parse error in date");
$this->error_at("status:{$k}", "<0>Parse error in date");
$v = null;
} else {
$v = (float) $v;
}
} else if ($v === false) {
$v = 0.0;
} else if ($v !== null) {
$this->syntax_error_at("status.{$k}");
$this->syntax_error_at("status:{$k}");
}
$xstatus->$k = $v;
}
$v = $istatus->withdraw_reason ?? null;
if (is_string($v)) {
$xstatus->withdraw_reason = $v;
} else if ($v !== null) {
$this->syntax_error_at("status.withdraw_reason");
$this->syntax_error_at("status:withdraw_reason");
}
if (in_array($istatusstr, ["submitted", "accepted", "accept", "deskrejected", "desk_reject", "deskreject", "rejected", "reject"])) {
$xstatus->submitted = $xstatus->submitted ?? true;
Expand All @@ -362,7 +362,7 @@ private function _normalize($ipj) {
$xstatus->draft = $xstatus->draft ?? !$xstatus->submitted;
$xstatus->withdrawn = $xstatus->withdrawn ?? $this->prow->timeWithdrawn > 0;
if ($xstatus->submitted !== !$xstatus->draft) {
$this->error_at("status.draft", "<0>Draft status conflicts with submitted status");
$this->error_at("status:draft", "<0>Draft status conflicts with submitted status");
}
$xpj->status = $xstatus;

Expand Down Expand Up @@ -607,7 +607,7 @@ private function _prepare_status($pj) {
$whynot = $this->user->perm_revive_paper($this->prow);
}
if ($whynot) {
$whynot->append_to($this, "status.withdrawn", 2);
$whynot->append_to($this, "status:withdrawn", 2);
$pj_withdrawn = $old_withdrawn;
}
}
Expand All @@ -630,7 +630,7 @@ private function _prepare_status($pj) {
$whynot = $this->user->perm_finalize_paper($this->prow);
}
if ($whynot) {
$whynot->append_to($this, "status.submitted", 3);
$whynot->append_to($this, "status:submitted", 3);
$pj_submitted = $old_submitted;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/permissionproblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ function unparse($format = 0) {
$idname = $id === "paper" ? "submission" : $id;
$ms[] = $this->conf->_("<0>Missing {$idname} ID.");
}
if (isset($this->_a["invalidSclass"])) {
$ms[] = $this->conf->_("<0>Unknown submission class ‘{}’.", $this->_a["invalidSclass"]);
}
if ($this->_a["noPaper"] ?? false) {
$ms[] = $this->conf->_("<0>Submission #{} does not exist.", $paperId);
}
Expand Down

0 comments on commit 89d891f

Please sign in to comment.