From f9a390f0d743819f6e6aeca5e705884b278afe50 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Fri, 3 Nov 2023 15:02:44 -0400 Subject: [PATCH] Prepare for contact flags. --- batch/savepapers.php | 2 +- batch/updatecontactdb.php | 2 +- src/assignmentset.php | 2 +- src/author.php | 5 ++++ src/conference.php | 4 +-- src/contact.php | 47 ++++++++++++++++++++-------------- src/contactlist.php | 2 +- src/options/o_contacts.php | 5 ++-- src/pages/p_log.php | 4 +-- src/paperstatus.php | 4 +-- src/userstatus.php | 14 +++++----- test/t_cdb.php | 52 +++++++++++++++++++------------------- test/t_login.php | 6 ++--- test/t_paperstatus.php | 2 +- test/t_permission.php | 6 ++--- 15 files changed, 85 insertions(+), 72 deletions(-) diff --git a/batch/savepapers.php b/batch/savepapers.php index 2b3245e30..a59fc5d97 100644 --- a/batch/savepapers.php +++ b/batch/savepapers.php @@ -253,7 +253,7 @@ function run_one($index, $j) { "lastName" => $this->tf->req["reviewerLast"] ?? "", "email" => $this->tf->req["reviewerEmail"], "affiliation" => $this->tf->req["reviewerAffiliation"] ?? null, - "disablement" => $this->disable_users ? Contact::DISABLEMENT_USER : 0 + "disablement" => $this->disable_users ? Contact::CFLAG_UDISABLED : 0 ])->store(); $this->tf->check_and_save($this->user, $prow, null); } diff --git a/batch/updatecontactdb.php b/batch/updatecontactdb.php index a456b8c1d..5c9a8f30d 100644 --- a/batch/updatecontactdb.php +++ b/batch/updatecontactdb.php @@ -209,7 +209,7 @@ function run_authors() { "firstName" => $au->firstName, "lastName" => $au->lastName, "affiliation" => $au->affiliation, - "disablement" => Contact::DISABLEMENT_PLACEHOLDER + "disablement" => Contact::CFLAG_PLACEHOLDER ])->store(); // NB: Contact::store() creates CONFLICT_AUTHOR records. $u->update_cdb(); diff --git a/src/assignmentset.php b/src/assignmentset.php index aa8c1ba24..716a9493e 100644 --- a/src/assignmentset.php +++ b/src/assignmentset.php @@ -674,7 +674,7 @@ function user_by_email($email, $create = false, $req = null) { $cargs["firstName"] = "Jane Q."; $cargs["lastName"] = "Public"; $cargs["affiliation"] = "Unaffiliated"; - $cargs["disablement"] = Contact::DISABLEMENT_USER; + $cargs["disablement"] = Contact::CFLAG_UDISABLED; } $c = Contact::make_keyed($this->conf, $cargs); } diff --git a/src/author.php b/src/author.php index 2be7f5cc9..f540d575e 100644 --- a/src/author.php +++ b/src/author.php @@ -292,6 +292,11 @@ function is_nonauthor() { return $this->status === self::STATUS_NONAUTHOR; } + /** @return bool */ + function is_placeholder() { + return ($this->disablement & Contact::CFLAG_PLACEHOLDER) !== 0; + } + /** @return int */ function disabled_flags() { return $this->disablement; diff --git a/src/conference.php b/src/conference.php index 5e3f9a04d..9538cc8d8 100644 --- a/src/conference.php +++ b/src/conference.php @@ -1936,7 +1936,7 @@ function site_contact() { * @return int */ function disablement_for($disabled, $roles) { if ($this->disable_non_pc && ($roles & Contact::ROLE_PCLIKE) === 0) { - $disabled |= Contact::DISABLEMENT_ROLE; + $disabled |= Contact::CFLAG_ROLEDISABLED; } return $disabled; } @@ -1971,7 +1971,7 @@ function user_query_fields($slice = Contact::SLICE_MINIMAL, $prefix = "") { /** @param string $prefix * @return string */ function deleted_user_query_fields($prefix = "") { - return "{$prefix}contactId, {$prefix}email, {$prefix}firstName, {$prefix}lastName, {$prefix}affiliation, 0 roles, " . Contact::DISABLEMENT_DELETED . " disabled, 0 primaryContactId, '' contactTags, 0 _slice"; + return "{$prefix}contactId, {$prefix}email, {$prefix}firstName, {$prefix}lastName, {$prefix}affiliation, 0 roles, " . Contact::CFLAG_DELETED . " disabled, 0 primaryContactId, '' contactTags, 0 _slice"; } /** @param int $slice diff --git a/src/contact.php b/src/contact.php index 78e9004db..35f010ec0 100644 --- a/src/contact.php +++ b/src/contact.php @@ -52,7 +52,7 @@ class Contact implements JsonSerializable { /** @var ?string */ public $contactTags; /** @var int */ - public $contactFlags = 0; + public $cflags = 0; /** @var int */ public $_slice = 0; @@ -205,13 +205,22 @@ class Contact implements JsonSerializable { public $myReviewPermissions; public $paperId; + /** @deprecated */ const DISABLEMENT_USER = 1; + /** @deprecated */ const DISABLEMENT_PLACEHOLDER = 2; // NB some code depends on PLACEHOLDER being highest bit in DB const DISABLEMENT_DB = 3; + /** @deprecated */ const DISABLEMENT_ROLE = 4; + /** @deprecated */ const DISABLEMENT_DELETED = 8; + const CFLAG_UDISABLED = 1; + const CFLAG_PLACEHOLDER = 2; + const CFLAG_ROLEDISABLED = 4; + const CFLAG_DELETED = 8; + const PROP_LOCAL = 0x01; const PROP_CDB = 0x02; const PROP_SLICE = 0x04; @@ -282,7 +291,7 @@ static function make_email(Conf $conf, $email) { static function make_placeholder(Conf $conf) { $u = new Contact($conf); $u->contactXid = self::$next_xid--; - $u->disabled = self::DISABLEMENT_PLACEHOLDER; + $u->disabled = self::CFLAG_PLACEHOLDER; $u->set_roles_properties(); return $u; } @@ -294,7 +303,7 @@ static function make_deleted(Conf $conf, $contactId) { $u->contactId = $contactId; $u->contactXid = $contactId > 0 ? $contactId : self::$next_xid--; $u->email = ""; - $u->disablement = self::DISABLEMENT_DELETED; + $u->disablement = self::CFLAG_DELETED; $u->set_roles_properties(); return $u; } @@ -408,7 +417,7 @@ private function set_roles_properties() { $this->isPC = ($this->roles & self::ROLE_PCLIKE) !== 0; $this->privChair = ($this->roles & (self::ROLE_ADMIN | self::ROLE_CHAIR)) !== 0; $this->disablement = $this->conf->disablement_for($this->disabled, $this->roles) - | ($this->disablement & self::DISABLEMENT_DELETED); + | ($this->disablement & self::CFLAG_DELETED); } /** @suppress PhanAccessReadOnlyProperty */ @@ -955,9 +964,9 @@ function update_cdb() { $cdbux->set_prop("passwordUseTime", $this->passwordUseTime); } if ($this->disablement === 0) { - $cdbux->set_prop("disabled", $cdbux->disabled & ~Contact::DISABLEMENT_PLACEHOLDER); + $cdbux->set_prop("disabled", $cdbux->disabled & ~Contact::CFLAG_PLACEHOLDER); } else if (!$cdbur) { - $cdbux->set_prop("disabled", Contact::DISABLEMENT_PLACEHOLDER); + $cdbux->set_prop("disabled", Contact::CFLAG_PLACEHOLDER); } if (!empty($cdbux->_mod_undo)) { assert($cdbux->cdb_confid !== 0); @@ -1000,7 +1009,7 @@ function owns_email($email) { /** @return bool */ function is_disabled() { - return ($this->disablement & ~self::DISABLEMENT_PLACEHOLDER) !== 0; + return ($this->disablement & ~self::CFLAG_PLACEHOLDER) !== 0; } /** @return bool */ @@ -1010,18 +1019,18 @@ function is_dormant() { /** @return bool */ function is_explicitly_disabled() { - return ($this->disablement & self::DISABLEMENT_USER) !== 0; + return ($this->disablement & self::CFLAG_UDISABLED) !== 0; } /** @return bool */ function is_placeholder() { - return ($this->disablement & self::DISABLEMENT_PLACEHOLDER) !== 0; + return ($this->disablement & self::CFLAG_PLACEHOLDER) !== 0; } /** @return bool */ function contactdb_disabled() { $cdbu = $this->cdb_user(); - return $cdbu && ($cdbu->disablement & ~self::DISABLEMENT_PLACEHOLDER) !== 0; + return $cdbu && ($cdbu->disablement & ~self::CFLAG_PLACEHOLDER) !== 0; } /** @return int */ @@ -1760,7 +1769,7 @@ function set_prop($prop, $value, $ifempty = false) { // on `$ifempty`, update only empty properties and placeholder users $old = $this->prop1($prop, $shape); if ($ifempty - && (($this->disabled & self::DISABLEMENT_PLACEHOLDER) === 0 + && (($this->disabled & self::CFLAG_PLACEHOLDER) === 0 || $value === null || $value === "")) { if ($old !== null && $old !== "") { @@ -1846,9 +1855,9 @@ function prop_changed($prop = null) { /** @param bool $always * @return bool */ function activate_placeholder_prop($always) { - if (($this->disabled & self::DISABLEMENT_PLACEHOLDER) !== 0 + if (($this->disabled & self::CFLAG_PLACEHOLDER) !== 0 && ($always || $this->conf->allow_user_activate_other())) { - $this->set_prop("disabled", $this->disabled & ~self::DISABLEMENT_PLACEHOLDER); + $this->set_prop("disabled", $this->disabled & ~self::CFLAG_PLACEHOLDER); return true; } else { return false; @@ -1991,19 +2000,19 @@ function import_prop($src, $ifempty) { if ($src->disablement !== 0 && $this->cdb_confid !== 0 && $this->contactDbId === 0) { - $this->set_prop("disabled", $this->disabled | self::DISABLEMENT_PLACEHOLDER); + $this->set_prop("disabled", $this->disabled | self::CFLAG_PLACEHOLDER); } // source is non-disabled local user: this is not placeholder if ($src->cdb_confid === 0 && $src->disablement === 0 - && ($this->disabled & self::DISABLEMENT_PLACEHOLDER) !== 0) { - $this->set_prop("disabled", $this->disabled & ~self::DISABLEMENT_PLACEHOLDER); + && ($this->disabled & self::CFLAG_PLACEHOLDER) !== 0) { + $this->set_prop("disabled", $this->disabled & ~self::CFLAG_PLACEHOLDER); } // source is globally disabled: this local user is disabled - if (($src->disabled & self::DISABLEMENT_USER) !== 0 + if (($src->disabled & self::CFLAG_UDISABLED) !== 0 && $src->cdb_confid !== 0 && $this->cdb_confid === 0) { - $this->set_prop("disabled", $this->disabled | self::DISABLEMENT_USER); + $this->set_prop("disabled", $this->disabled | self::CFLAG_UDISABLED); } } @@ -2094,7 +2103,7 @@ function store($flags = 0, $actor = null) { } // log creation (except for placeholder accounts) - if ($this->disabled !== self::DISABLEMENT_PLACEHOLDER) { + if ($this->disabled !== self::CFLAG_PLACEHOLDER) { $type = $this->disabled !== 0 ? ", disabled" : ""; $this->conf->log_for($actor && $actor->has_email() ? $actor : $this, $this, "Account created" . $type); } diff --git a/src/contactlist.php b/src/contactlist.php index 4669d029a..2bc39c524 100644 --- a/src/contactlist.php +++ b/src/contactlist.php @@ -1003,7 +1003,7 @@ function _rows() { } else if ($this->_limit_cids !== null) { $mainwhere[] = "contactId" . sql_in_int_list(array_keys($this->_limit_cids)); } - $mainwhere[] = "disabled<" . Contact::DISABLEMENT_PLACEHOLDER; + $mainwhere[] = "disabled<" . Contact::CFLAG_PLACEHOLDER; // make query $result = $this->conf->qe_raw("select * from ContactInfo" . (empty($mainwhere) ? "" : " where " . join(" and ", $mainwhere))); diff --git a/src/options/o_contacts.php b/src/options/o_contacts.php index 198d48e23..b83945c50 100644 --- a/src/options/o_contacts.php +++ b/src/options/o_contacts.php @@ -97,8 +97,7 @@ private function apply_parsed_users(PaperValue $ov, $specau) { if ($j !== false) { if ($specau[$i]->conflictType !== 0) { $curau[$j]->author_index = $specau[$i]->author_index; - $modified = $modified - || ($curau[$j]->disabled_flags() & Contact::DISABLEMENT_PLACEHOLDER) !== 0; + $modified = $modified || $curau[$j]->is_placeholder(); } else { // only remove contacts on exact email match // (removing by a non-primary email has no effect) @@ -280,7 +279,7 @@ function print_web_edit(PaperTable $pt, $ov, $reqov) { Ht::hidden("contacts:{$cidx}:email", $au->email); if (($au->contactId > 0 && ($au->conflictType & CONFLICT_AUTHOR) !== 0 - && ($au->disabled_flags() & Contact::DISABLEMENT_PLACEHOLDER) === 0) + && !$au->is_placeholder()) || ($au->contactId === $pt->user->contactId && $ov->prow->paperId <= 0)) { echo Ht::hidden("contacts:{$cidx}:active", 1), diff --git a/src/pages/p_log.php b/src/pages/p_log.php index 081bd426d..2389ad927 100644 --- a/src/pages/p_log.php +++ b/src/pages/p_log.php @@ -353,7 +353,7 @@ function user_html($user) { if (($pc = $this->conf->pc_member_by_id($user->contactId))) { $user = $pc; } - if ($user->disabled_flags() & Contact::DISABLEMENT_DELETED) { + if ($user->disabled_flags() & Contact::CFLAG_DELETED) { $t = '' . $user->name_h(NAME_E) . ''; } else { $t = $user->name_h(NAME_P); @@ -403,7 +403,7 @@ function users_html($users, $trueContactId) { && (!isset($user->roles) || !($user->roles & Contact::ROLE_PCLIKE))) { $all_pc = false; } - if ($user->disabled_flags() & Contact::DISABLEMENT_DELETED) { + if ($user->disabled_flags() & Contact::CFLAG_DELETED) { if ($user->email) { $t = '' . $user->name_h(NAME_E) . ''; } else { diff --git a/src/paperstatus.php b/src/paperstatus.php index ca3221461..2ed95775e 100644 --- a/src/paperstatus.php +++ b/src/paperstatus.php @@ -754,8 +754,8 @@ private function _make_user($au, $ctype) { } if (!$uu && $ctype >= CONFLICT_AUTHOR) { $j = $au->unparse_nea_json(); - $j["disablement"] = ($this->disable_users ? Contact::DISABLEMENT_USER : 0) - | Contact::DISABLEMENT_PLACEHOLDER; + $j["disablement"] = ($this->disable_users ? Contact::CFLAG_UDISABLED : 0) + | Contact::CFLAG_PLACEHOLDER; $uu = Contact::make_keyed($this->conf, $j)->store(0, $this->user); if ($uu) { $this->_created_contacts[] = $uu; diff --git a/src/userstatus.php b/src/userstatus.php index ebb1f762c..0968966a1 100644 --- a/src/userstatus.php +++ b/src/userstatus.php @@ -892,7 +892,7 @@ function save_user($cj, $old_user = null) { $this->check_invariants($cj); $actor = $this->viewer->is_root_user() ? null : $this->viewer; if (!$old_user) { - $create_cj = array_merge((array) $cj, ["disablement" => Contact::DISABLEMENT_PLACEHOLDER]); + $create_cj = array_merge((array) $cj, ["disablement" => Contact::CFLAG_PLACEHOLDER]); $user = Contact::make_keyed($this->conf, $create_cj)->store(0, $actor); $cj->email = $user->email; // adopt contactdb’s email capitalization } @@ -1015,15 +1015,15 @@ static function save_main(UserStatus $us) { $disablement = $user->disabled_flags() & Contact::DISABLEMENT_DB; if (isset($cj->disabled)) { if ($cj->disabled) { - $disablement |= Contact::DISABLEMENT_USER; + $disablement |= Contact::CFLAG_UDISABLED; } else { - $disablement &= ~Contact::DISABLEMENT_USER; + $disablement &= ~Contact::CFLAG_UDISABLED; } } - if ($disablement === Contact::DISABLEMENT_PLACEHOLDER + if ($disablement === Contact::CFLAG_PLACEHOLDER && ($us->viewer->is_root_user() || $us->conf->allow_user_activate_other())) { - $disablement &= ~Contact::DISABLEMENT_PLACEHOLDER; + $disablement &= ~Contact::CFLAG_PLACEHOLDER; } $user->set_prop("disabled", $disablement); if ($user->prop_changed("disabled") && isset($cj->disabled)) { @@ -1640,7 +1640,7 @@ static function print_main_actions(UserStatus $us) { $us->cs()->add_section_class("form-outline-section")->print_start_section("User administration"); echo '
'; - if ($us->user->disabled_flags() === Contact::DISABLEMENT_PLACEHOLDER) { + if ($us->user->disabled_flags() === Contact::CFLAG_PLACEHOLDER) { $disabled = !$us->conf->allow_user_activate_other(); } else { $disabled = $us->user->disabled_flags() !== 0; @@ -1649,7 +1649,7 @@ static function print_main_actions(UserStatus $us) { if (!$us->is_auth_user()) { echo '
'; - $disablement = $us->user->disabled_flags() & ~Contact::DISABLEMENT_PLACEHOLDER; + $disablement = $us->user->disabled_flags() & ~Contact::CFLAG_PLACEHOLDER; if ($us->user->contactdb_disabled()) { $klass = "flex-grow-1 disabled"; $p = "

This account is disabled on all sites.

"; diff --git a/test/t_cdb.php b/test/t_cdb.php index 9d531a9ec..e962ce9f8 100644 --- a/test/t_cdb.php +++ b/test/t_cdb.php @@ -455,14 +455,14 @@ function test_email_authored_papers() { xassert(!!$u); xassert_eqq($u->firstName, "Cengiz"); xassert_eqq($u->lastName, "Alaettinoğlu"); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $ldb_cid = $u->contactId; $u = $this->conf->cdb_user_by_email("cengiz@isi.edu"); xassert(!!$u); xassert_eqq($u->firstName, "Cengiz"); xassert_eqq($u->lastName, "Alaettinoğlu"); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $cdb_cid = $u->contactId; // remove localdb user and cdb user's roles @@ -550,11 +550,11 @@ function test_cdb_roles_1() { function test_cdb_roles_2() { // authorship is encoded in placeholder $acct = $this->conf->fresh_user_by_email("pavlin@isi.edu"); - xassert_eqq($acct->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($acct->disabled_flags(), Contact::CFLAG_PLACEHOLDER); xassert($acct->is_author()); xassert_eqq($acct->cdb_roles(), Contact::ROLE_AUTHOR); $acct = $this->conf->fresh_cdb_user_by_email("pavlin@isi.edu"); - xassert_eqq($acct->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($acct->disabled_flags(), Contact::CFLAG_PLACEHOLDER); xassert_eqq($acct->roles, Contact::ROLE_AUTHOR); // saving without disablement wakes up cdb @@ -568,7 +568,7 @@ function test_cdb_roles_3() { // saving a user with a role does both role and authorship $email = "lam@cs.utexas.edu"; $acct = $this->conf->fresh_user_by_email($email); - xassert_eqq($acct->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($acct->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $acct = $this->us1->save_user((object) ["email" => $email, "roles" => "sysadmin"]); xassert(!!$acct); @@ -586,34 +586,34 @@ function test_placeholder() { Contact::make_keyed($this->conf, [ "email" => "scapegoat@harvard.edu", "firstName" => "Shane", - "disablement" => Contact::DISABLEMENT_PLACEHOLDER + "disablement" => Contact::CFLAG_PLACEHOLDER ])->store(); $u = $this->conf->checked_user_by_email("scapegoat@harvard.edu"); xassert_eqq($u->firstName, "Shane"); xassert_eqq($u->lastName, ""); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $cdb_u = $u->cdb_user(); xassert_eqq($cdb_u->firstName, "Shane"); xassert_eqq($cdb_u->lastName, ""); - xassert_eqq($cdb_u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($cdb_u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); // creating another placeholder will override properties Contact::make_keyed($this->conf, [ "email" => "scapegoat@harvard.edu", "firstName" => "Shapely", "lastName" => "Montréal", - "disablement" => Contact::DISABLEMENT_PLACEHOLDER + "disablement" => Contact::CFLAG_PLACEHOLDER ])->store(); $u = $this->conf->checked_user_by_email("scapegoat@harvard.edu"); xassert_eqq($u->firstName, "Shapely"); xassert_eqq($u->lastName, "Montréal"); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $cdb_u = $u->cdb_user(); xassert_eqq($cdb_u->firstName, "Shapely"); xassert_eqq($cdb_u->lastName, "Montréal"); - xassert_eqq($cdb_u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($cdb_u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); xassert_eqq($cdb_u->prop("password"), " unset"); // enable user @@ -637,7 +637,7 @@ function test_placeholder() { "email" => "scapegoat@harvard.edu", "firstName" => "Stickly", "lastName" => "Milquetoast", - "disablement" => Contact::DISABLEMENT_PLACEHOLDER + "disablement" => Contact::CFLAG_PLACEHOLDER ])->store(); $u = $this->conf->checked_user_by_email("scapegoat@harvard.edu"); @@ -679,7 +679,7 @@ function test_updatecontactdb_authors() { $u = $this->conf->fresh_user_by_email("nonsense@_.com"); xassert(!!$u); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); xassert_eqq($u->email, "NONSENSE@_.com"); xassert_eqq($u->firstName, "Nonsense"); xassert_eqq($u->lastName, "Person"); @@ -691,12 +691,12 @@ function test_updatecontactdb_authors() { $u = $this->conf->fresh_cdb_user_by_email("nonsense@_.com"); xassert(!!$u); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); xassert_eqq($u->email, "NONSENSE@_.com"); xassert_eqq($u->firstName, "Nonsense"); xassert_eqq($u->lastName, "Person"); xassert_eqq($u->affiliation, "Nonsense University"); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); } /** @suppress PhanAccessReadOnlyProperty */ @@ -815,11 +815,11 @@ function test_cdb_new_locally_disabled_user() { xassert_gt($pid, 0); $u = $this->conf->fresh_cdb_user_by_email("belling@_.com"); - xassert_eqq($u->disabled_flags() & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_ROLE); + xassert_eqq($u->disabled_flags() & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_ROLEDISABLED); $d = Dbl::fetch_ivalue($this->conf->dblink, "select disabled from ContactInfo where email='belling@_.com'") ?? -1; - xassert_eqq($d & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_USER); + xassert_eqq($d & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_UDISABLED); $d = Dbl::fetch_ivalue($this->conf->contactdb(), "select disabled from ContactInfo where email='belling@_.com'") ?? -1; - xassert_eqq($d & ~Contact::DISABLEMENT_PLACEHOLDER, 0); + xassert_eqq($d & ~Contact::CFLAG_PLACEHOLDER, 0); $u = $this->conf->fresh_cdb_user_by_email("kitcat@_.com"); xassert(!$u); @@ -829,25 +829,25 @@ function test_cdb_new_locally_disabled_user() { "lastName" => "Cat", "email" => "kitcat@_.com", "affiliation" => "Fart University", - "disablement" => Contact::DISABLEMENT_USER + "disablement" => Contact::CFLAG_UDISABLED ])->store(); - xassert_eqq($u->disabled_flags() & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_USER | Contact::DISABLEMENT_ROLE); + xassert_eqq($u->disabled_flags() & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_UDISABLED | Contact::CFLAG_ROLEDISABLED); $uu = $u->cdb_user(); - xassert_eqq($uu->disabled_flags() & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_ROLE); + xassert_eqq($uu->disabled_flags() & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_ROLEDISABLED); $d = Dbl::fetch_ivalue($this->conf->dblink, "select disabled from ContactInfo where email='kitcat@_.com'") ?? -1; - xassert_eqq($d & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_USER); + xassert_eqq($d & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_UDISABLED); $d = Dbl::fetch_ivalue($this->conf->contactdb(), "select disabled from ContactInfo where email='kitcat@_.com'") ?? -1; - xassert_eqq($d & ~Contact::DISABLEMENT_PLACEHOLDER, 0); + xassert_eqq($d & ~Contact::CFLAG_PLACEHOLDER, 0); Dbl::qe($this->conf->dblink, "insert into ContactInfo set firstName='Martha', lastName='Tanner', email='marthatanner@_.com', affiliation='University of Connecticut', password='', disabled=1"); Dbl::qe($this->conf->contactdb(), "insert into ContactInfo set firstName='Martha', lastName='Tanner', email='marthatanner@_.com', affiliation='University of Connecticut', password=' unset', disabled=2"); $u = $this->conf->fresh_user_by_email("marthatanner@_.com"); - xassert_eqq($u->disabled_flags() & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_ROLE | Contact::DISABLEMENT_USER); + xassert_eqq($u->disabled_flags() & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_ROLEDISABLED | Contact::CFLAG_UDISABLED); $u->update_cdb(); $uu = $this->conf->fresh_cdb_user_by_email("marthatanner@_.com"); - xassert_eqq($uu->disabled_flags() & ~Contact::DISABLEMENT_PLACEHOLDER, Contact::DISABLEMENT_ROLE); + xassert_eqq($uu->disabled_flags() & ~Contact::CFLAG_PLACEHOLDER, Contact::CFLAG_ROLEDISABLED); $d = Dbl::fetch_ivalue($this->conf->contactdb(), "select disabled from ContactInfo where email='marthatanner@_.com'") ?? -1; - xassert_eqq($d & ~Contact::DISABLEMENT_PLACEHOLDER, 0); + xassert_eqq($d & ~Contact::CFLAG_PLACEHOLDER, 0); $this->conf->set_opt("disableNonPC", null); $this->conf->refresh_options(); diff --git a/test/t_login.php b/test/t_login.php index bb84963c8..b6a86e358 100644 --- a/test/t_login.php +++ b/test/t_login.php @@ -101,7 +101,7 @@ function test_login_placeholder() { $email = "scapegoat2@baa.com"; Contact::make_keyed($this->conf, [ "email" => $email, - "disablement" => Contact::DISABLEMENT_PLACEHOLDER + "disablement" => Contact::CFLAG_PLACEHOLDER ])->store(); $this->conf->invalidate_caches(["users" => true, "cdb" => true]); @@ -123,11 +123,11 @@ function test_login_placeholder() { // but user is still a placeholder $u = $this->conf->checked_user_by_email($email); xassert(!!$u); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); if ($this->cdb) { $u = $this->conf->checked_cdb_user_by_email($email); xassert(!!$u); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); } $this->conf->invalidate_caches(["users" => true, "cdb" => true]); diff --git a/test/t_paperstatus.php b/test/t_paperstatus.php index b7a1d2222..d7a2662da 100644 --- a/test/t_paperstatus.php +++ b/test/t_paperstatus.php @@ -631,7 +631,7 @@ function test_save_new_authors() { $attenu = $this->conf->user_by_email("atten@_.com"); xassert_eqq($nprow1->conflict_type($attenu), CONFLICT_AUTHOR); xassert_eqq($attenu->roles & Contact::ROLE_DBMASK, 0); - xassert_eqq($attenu->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($attenu->disabled_flags(), Contact::CFLAG_PLACEHOLDER); xassert($nprow1->timeSubmitted > 0); xassert($nprow1->timeWithdrawn <= 0); xassert(!$nprow1->option(1)); diff --git a/test/t_permission.php b/test/t_permission.php index 98c41406e..4c0b18f22 100644 --- a/test/t_permission.php +++ b/test/t_permission.php @@ -1609,7 +1609,7 @@ function test_make_anonymous_user_nologin() { xassert(!maybe_user("anonymous10")); $u = Contact::make_keyed($this->conf, [ "email" => "anonymous10", - "disablement" => Contact::DISABLEMENT_USER + "disablement" => Contact::CFLAG_UDISABLED ])->store(Contact::SAVE_ANY_EMAIL); xassert($u->contactId > 0); xassert_eqq($this->conf->fetch_value("select password from ContactInfo where email='anonymous10'"), " nologin"); @@ -1637,7 +1637,7 @@ function test_user_registration() { // registering email of an author grants author privilege $u = maybe_user("thalerd@eecs.umich.edu"); xassert(!!$u); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $u = Contact::make_email($this->conf, "thalerd@eecs.umich.edu")->store(); assert($u !== null); xassert($u->contactId > 0); @@ -1651,7 +1651,7 @@ function test_user_registration() { // registration-time name overrides author name $u = maybe_user("schwartz@ctr.columbia.edu"); xassert(!!$u); - xassert_eqq($u->disabled_flags(), Contact::DISABLEMENT_PLACEHOLDER); + xassert_eqq($u->disabled_flags(), Contact::CFLAG_PLACEHOLDER); $u = Contact::make_keyed($this->conf, ["email" => "schwartz@ctr.columbia.edu", "first" => "cengiz!", "last" => "SCHwarTZ", "affiliation" => "Coyumbia"])->store(); assert($u !== null); xassert($u->contactId > 0);