Skip to content

Commit

Permalink
User API and initial user input on paper table use CDB-populated data.
Browse files Browse the repository at this point in the history
Important if user doesn't have account yet.
  • Loading branch information
kohler committed Aug 26, 2024
1 parent 6cd253a commit 71af9fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api/api_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/options/o_authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 71af9fb

Please sign in to comment.