diff --git a/src/pages/p_paper.php b/src/pages/p_paper.php index dcef7149fe..64262254bf 100644 --- a/src/pages/p_paper.php +++ b/src/pages/p_paper.php @@ -490,10 +490,6 @@ static function go(Contact $user, Qrequest $qreq) { $pp->load_prow(); // fix user - if ($qreq->is_post() && $qreq->valid_token()) { - $user->ensure_account_here(); - // XXX escape unless update && can_start_paper??? - } if ($pp->prow->paperId === 0 && $user->privChair && !$pp->prow->submission_round()->time_register(true)) { diff --git a/src/paperstatus.php b/src/paperstatus.php index 3ba9e8dea0..0c4ff85626 100644 --- a/src/paperstatus.php +++ b/src/paperstatus.php @@ -752,7 +752,14 @@ function clear_conflict_values($bit) { * @return ?Contact */ private function _make_user($au, $ctype) { $uu = $this->conf->user_by_email($au->email, USER_SLICE); - if (!$uu && $ctype >= CONFLICT_AUTHOR) { + if (!$uu + && $ctype >= CONFLICT_AUTHOR + && strcasecmp($au->email, $this->user->email) === 0) { + $this->user->ensure_account_here(); + $uu = $this->conf->user_by_email($au->email, USER_SLICE); + } + if (!$uu + && $ctype >= CONFLICT_AUTHOR) { $j = $au->unparse_nea_json(); $j["disablement"] = ($this->disable_users ? Contact::DISABLEMENT_USER : 0) | Contact::DISABLEMENT_PLACEHOLDER; @@ -829,6 +836,11 @@ private function has_conflict_diff() { } private function _check_contacts_last($pj) { + // if creating a paper, user has account here + if ($this->user->has_email()) { + $this->user->ensure_account_here(); + } + // if creating a paper, user becomes contact; // if user removes self from author list, user becomes contact if ($this->user->contactId > 0) { diff --git a/test/t_cdb.php b/test/t_cdb.php index 466352ef49..9047a57e39 100644 --- a/test/t_cdb.php +++ b/test/t_cdb.php @@ -698,4 +698,52 @@ function test_updatecontactdb_authors() { xassert_eqq($u->affiliation, "Nonsense University"); xassert_eqq($u->disablement, Contact::DISABLEMENT_PLACEHOLDER); } + + function test_cdb_user_new_paper() { + $u = $this->conf->fresh_cdb_user_by_email("newuser@_.com"); + xassert(!$u); + + $result = Dbl::qe($this->conf->contactdb(), "insert into ContactInfo set firstName='Te', lastName='Thamrongrattanarit', email='newuser@_.com', affiliation='Brandeis University', collaborators='Computational Linguistics Magazine', password=' $$2y$10$/URgqlFgQHpfE6mg4NzJhOZbg9Cc2cng58pA4cikzRD9F0qIuygnm'"); + $u = $this->conf->fresh_cdb_user_by_email("newuser@_.com"); + xassert(!!$u); + xassert(!$this->conf->fresh_user_by_email("newuser@_.com")); + + $so = $this->conf->setting("sub_open"); + $ss = $this->conf->setting("sub_sub"); + $this->conf->save_setting("sub_open", 1); + $this->conf->save_refresh_setting("sub_sub", Conf::$now + 10); + $mu = Contact::$main_user; + Contact::$main_user = $u; + xassert(!$u->has_account_here()); + + $p = PaperInfo::make_new($u, null); + $ps = new PaperStatus($u); + $pid = $ps->save_paper_web(new Qrequest("POST", [ + "title" => "A Systematic Study of Neural Discourse Models for Implicit Discourse Relation", + "has_authors" => 1, + "authors:1:name" => "Attapol T. Rutherford", + "authors:1:affiliation" => "Yelp", + "authors:1:email" => "newuser@_.com", + "authors:2:name" => "Vera Demberg", + "authors:2:affiliation" => "Saarland University", + "authors:2:email" => "vera@coli.uni-saarland.de", + "authors:3:name" => "Nianwen Xue", + "authors:3:affiliation" => "Brandeis University", + "authors:3:email" => "xuen@brandeis.edu", + "abstract" => "Inferring implicit discourse relations in natural language text is the most difficult subtask in discourse parsing. Many neural network models have been proposed to tackle this problem." + ]), $p, "update"); + xassert_gt($pid, 0); + xassert($u->has_account_here()); + + $p1 = $this->conf->checked_paper_by_id($pid); + xassert($p1->has_author($u)); + $u1 = $this->conf->fresh_user_by_email("newuser@_.com"); + xassert(!$u1->is_dormant()); + xassert_eqq($p1->conflict_type($u1), CONFLICT_CONTACTAUTHOR | CONFLICT_AUTHOR); + xassert(!empty($p1->conflict_type_list())); + + $this->conf->save_setting("sub_open", $so); + $this->conf->save_refresh_setting("sub_sub", $ss); + Contact::$main_user = $mu; + } }