Skip to content
Permalink
Browse files

Begin cleaning up edit-message/paper-save flow.

  • Loading branch information...
kohler committed Oct 14, 2019
1 parent 9883153 commit f3af83bcca2e3fd67e04107b8e841a2e094d9c64
Showing with 447 additions and 183 deletions.
  1. +2 −1 etc/intrinsicoptions.json
  2. +1 −0 lib/messageset.php
  3. +11 −3 paper.php
  4. +109 −0 src/intrinsicvalue.php
  5. +8 −6 src/paperinfo.php
  6. +297 −87 src/paperoption.php
  7. +9 −70 src/paperstatus.php
  8. +9 −16 src/papertable.php
  9. +1 −0 src/tarball.sh
@@ -1,7 +1,8 @@
[
{
"name": "title", "json_key": "title", "id": -1000,
"form_position": 1, "display_space": 1, "type": "intrinsic"
"form_position": 1, "display_space": 1, "type": "intrinsic",
"required": true
},
{
"name": "submission_version", "id": -1008,
@@ -3,6 +3,7 @@
// Copyright (c) 2006-2019 Eddie Kohler; see LICENSE.
class MessageSet {
public $user;
public $ignore_msgs = false;
public $ignore_duplicates = false;
private $allow_error;
@@ -367,6 +367,8 @@ function update_paper(Qrequest $qreq, $action) {
$whyNot = update_paper($Qreq, $action);
if ($whyNot === true) {
$Conf->self_redirect($Qreq, ["p" => $prow->paperId, "m" => "edit"]);
} else {
// $Conf->self_redirect($Qreq, ["p" => $prow ? $prow->paperId : "new", "m" => "edit"]);
}
// If we get here, we failed to update.
@@ -453,14 +455,20 @@ function update_paper(Qrequest $qreq, $action) {
$paperTable->initialize($editable, $editable && $useRequest);
if (($ps || $prow) && $paperTable->mode === "edit") {
$old_overrides = $Me->add_overrides(Contact::OVERRIDE_CONFLICT);
if ($ps) {
$ps->ignore_duplicates = true;
} else {
$ps = new PaperStatus($Conf, $Me);
}
$ps->paper_json($prow, ["msgs" => true, "editable" => true]);
$Me->set_overrides($old_overrides);
if ($prow) {
$old_overrides = $Me->add_overrides(Contact::OVERRIDE_CONFLICT);
foreach ($Conf->paper_opts->form_field_list($prow) as $o) {
if ($Me->can_edit_option($prow, $o)) {
$o->value_messages($prow->force_option($o), $ps);
}
}
$Me->set_overrides($old_overrides);
}
$paperTable->set_edit_status($ps);
}
@@ -0,0 +1,109 @@
<?php
// intrinsicvalue.php -- HotCRP helper class for paper options
// Copyright (c) 2006-2019 Eddie Kohler; see LICENSE.
class IntrinsicValue {
static function assign_intrinsic(PaperValue $ov) {
if ($ov->id === DTYPE_SUBMISSION) {
$ov->set_value_data([$ov->prow->paperStorageId], [null]);
} else if ($ov->id === DTYPE_FINAL) {
$ov->set_value_data([$ov->prow->finalPaperStorageId], [null]);
} else if ($ov->id === PaperOption::ANONYMITYID) {
if ($ov->prow->blind) {
$ov->set_value_data([1], [null]);
} else {
$ov->set_value_data([], []);
}
} else {
$ov->set_value_data([], []);
}
$ov->anno["intrinsic"] = true;
}
static function value_messages($o, PaperValue $ov, MessageSet $ms) {
if (($o->id === PaperOption::TITLEID
|| ($o->id === PaperOption::ABSTRACTID && !$o->conf->opt("noAbstract")))
&& !$o->value_present($ov)) {
$ms->error_at($o->field_key(), "Entry required.");
}
if ($o->id === DTYPE_SUBMISSION
&& !$o->conf->opt("noPapers")
&& !$o->value_present($ov)) {
$ms->warning_at($o->field_key(), $o->conf->_("Entry required to complete submission."));
}
if ($o->id === PaperOption::AUTHORSID) {
assert(isset($ov->anno["intrinsic"]));
$msg1 = $msg2 = false;
foreach ($ov->prow->author_list() as $n => $au) {
if (strpos($au->email, "@") === false
&& strpos($au->affiliation, "@") !== false) {
$msg1 = true;
$ms->warning_at("author" . ($n + 1), null);
} else if ($au->firstName === "" && $au->lastName === ""
&& $au->email === "" && $au->affiliation !== "") {
$msg2 = true;
$ms->warning_at("author" . ($n + 1), null);
}
}
$max_authors = $o->conf->opt("maxAuthors");
if (!$ov->prow->author_list()) {
$ms->error_at("authors", "Entry required.");
$ms->error_at("author1", false);
}
if ($max_authors > 0
&& count($ov->prow->author_list()) > $max_authors) {
$ms->error_at("authors", $o->conf->_("Each submission can have at most %d authors.", $max_authors));
}
if ($msg1) {
$ms->warning_at("authors", "You may have entered an email address in the wrong place. The first author field is for email, the second for name, and the third for affiliation.");
}
if ($msg2) {
$ms->warning_at("authors", "Please enter a name and optional email address for every author.");
}
}
if ($o->id === PaperOption::COLLABORATORSID
&& $o->conf->setting("sub_collab")
&& !$o->value_present($ov)
&& ($ov->prow->outcome <= 0 || ($ms->user && !$ms->user->can_view_decision($ov->prow)))) {
$ms->warning_at("collaborators", $o->conf->_("Enter the authors’ external conflicts of interest. If none of the authors have external conflicts, enter “None”."));
}
if ($o->id === PaperOption::PCCONFID
&& ($ov->prow->outcome <= 0 || ($ms->user && !$ms->user->can_view_decision($ov->prow)))) {
assert(isset($ov->anno["intrinsic"]));
$pcs = [];
foreach ($o->conf->full_pc_members() as $p) {
if (!$ov->prow->has_conflict($p)
&& $ov->prow->potential_conflict($p)) {
$n = Text::name_html($p);
$pcs[] = Ht::link($n, "#pcc{$p->contactId}", ["class" => "uu"]);
}
}
if (!empty($pcs)) {
$ms->warning_at("pcconf", $o->conf->_("You may have missed conflicts of interest with %s. Please verify that all conflicts are correctly marked.", commajoin($pcs, "and")) . $o->conf->_(" Hover over “possible conflict” labels for more information."));
}
}
}
static function echo_web_edit($o, PaperTable $pt, $ov, $reqov) {
if ($o->id === PaperOption::TITLEID) {
$o->echo_web_edit_text($pt, $ov, $reqov, ["no_format_description" => true]);
} else if ($o->id === PaperOption::ABSTRACTID) {
if ((int) $o->conf->opt("noAbstract") !== 1) {
$o->echo_web_edit_text($pt, $ov, $reqov);
}
} else if ($o->id === PaperOption::AUTHORSID) {
$pt->echo_editable_authors($o);
} else if ($o->id === PaperOption::ANONYMITYID) {
$pt->echo_editable_anonymity($o);
} else if ($o->id === PaperOption::CONTACTSID) {
$pt->echo_editable_contact_author($o);
} else if ($o->id === PaperOption::TOPICSID) {
$pt->echo_editable_topics($o);
} else if ($o->id === PaperOption::PCCONFID) {
$pt->echo_editable_pc_conflicts($o);
} else if ($o->id === PaperOption::COLLABORATORSID) {
if ($o->conf->setting("sub_collab")
&& ($pt->editable !== "f" || $pt->user->can_administer($pt->prow))) {
$o->echo_web_edit_text($pt, $ov, $reqov, ["no_format_description" => true, "no_spellcheck" => true]);
}
}
}
}
@@ -1182,13 +1182,15 @@ function option($o) {
}
function force_option($o) {
$id = is_object($o) ? $o->id : $o;
if (($ov = get($this->options(), $id))) {
return $ov;
} else if (($opt = $this->conf->paper_opts->get($id))) {
return new PaperValue($this, $opt);
if (is_object($o)) {
$ov = get($this->options(), $o->id);
return $ov ? : new PaperValue($this, $o);
} else {
return null;
$ov = get($this->options(), $o);
if (!$ov && ($o = $this->conf->paper_opts->get($o))) {
$ov = new PaperValue($this, $o);
}
return $ov;
}
}

0 comments on commit f3af83b

Please sign in to comment.
You can’t perform that action at this time.