From 71af9fb39f46d6239ecce6104f429ffdb0d7ddc4 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Mon, 26 Aug 2024 18:03:26 -0400 Subject: [PATCH] User API and initial user input on paper table use CDB-populated data. Important if user doesn't have account yet. --- src/api/api_user.php | 2 +- src/contact.php | 9 +++++++++ src/options/o_authors.php | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/api_user.php b/src/api/api_user.php index dac8cdfbb..4639c09a5 100644 --- a/src/api/api_user.php +++ b/src/api/api_user.php @@ -29,7 +29,7 @@ static function user(Contact $user, Qrequest $qreq, ?PaperInfo $prow) { $found = null; if (strcasecmp($user->email, $email) >= 0 && strcasecmp($user->email, "{$email}~") < 0) { - $found = $user; + $found = $user->populated_user(); } if (($user->can_view_pc() || $broad_lookup) diff --git a/src/contact.php b/src/contact.php index 4543fd123..33b556d40 100644 --- a/src/contact.php +++ b/src/contact.php @@ -1019,6 +1019,15 @@ function update_cdb() { } } + /** @return Contact */ + function populated_user() { + if ($this->contactId <= 0 && $this->has_email()) { + return $this->cdb_user() ?? $this; + } else { + return $this; + } + } + /** @return bool */ function is_actas_user() { diff --git a/src/options/o_authors.php b/src/options/o_authors.php index 628bd6783..bedc952aa 100644 --- a/src/options/o_authors.php +++ b/src/options/o_authors.php @@ -259,8 +259,8 @@ private function echo_editable_authors_line($pt, $n, $au, $reqau, $shownum) { if ($n === 1 && !$au && !$pt->user->can_administer($pt->prow) - && (!$reqau || $reqau->nea_equals($pt->user))) { - $reqau = new Author($pt->user); + && (!$reqau || $reqau->nea_equals($pt->user->populated_user()))) { + $reqau = new Author($pt->user->populated_user()); $ignore_diff = true; }