Skip to content

Commit

Permalink
Fix failing test: don't create a cdb user as disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Oct 2, 2023
1 parent 8cc2396 commit 0d7ae53
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Contact implements JsonSerializable {
const PROP_STRINGLIST = 0x100;
const PROP_SIMPLIFY = 0x200;
const PROP_NAME = 0x1000;
const PROP_PASSWORD = 0x2000;
const PROP_NOUPDATECDB = 0x2000;
const PROP_UPDATE = 0x4000;
const PROP_IMPORT = 0x8000;
const PROP_SPECIAL = 0x10000;
Expand All @@ -235,17 +235,17 @@ class Contact implements JsonSerializable {
"affiliation" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_STRING | self::PROP_SIMPLIFY | self::PROP_SLICE | self::PROP_UPDATE | self::PROP_IMPORT,
"phone" => self::PROP_LOCAL | self::PROP_NULL | self::PROP_STRING | self::PROP_SIMPLIFY | self::PROP_UPDATE | self::PROP_IMPORT,
"country" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_NULL | self::PROP_STRING | self::PROP_SIMPLIFY | self::PROP_UPDATE | self::PROP_IMPORT,
"password" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_STRING | self::PROP_PASSWORD,
"passwordTime" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_PASSWORD,
"passwordUseTime" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_PASSWORD,
"password" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_STRING | self::PROP_NOUPDATECDB,
"passwordTime" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_NOUPDATECDB,
"passwordUseTime" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_NOUPDATECDB,
"collaborators" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_NULL | self::PROP_STRING | self::PROP_UPDATE | self::PROP_IMPORT,
"updateTime" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT,
"updateTime" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_NOUPDATECDB,
"lastLogin" => self::PROP_LOCAL | self::PROP_INT,
"defaultWatch" => self::PROP_LOCAL | self::PROP_INT,
"primaryContactId" => self::PROP_LOCAL | self::PROP_INT | self::PROP_SLICE,
"roles" => self::PROP_LOCAL | self::PROP_INT | self::PROP_SLICE | self::PROP_SPECIAL,
"cdbRoles" => self::PROP_LOCAL | self::PROP_INT,
"disabled" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_SLICE,
"disabled" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_INT | self::PROP_SLICE | self::PROP_NOUPDATECDB,
"contactTags" => self::PROP_LOCAL | self::PROP_NULL | self::PROP_STRING | self::PROP_SLICE,
"address" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_DATA | self::PROP_NULL | self::PROP_STRINGLIST | self::PROP_SIMPLIFY | self::PROP_UPDATE,
"city" => self::PROP_LOCAL | self::PROP_CDB | self::PROP_DATA | self::PROP_NULL | self::PROP_STRING | self::PROP_SIMPLIFY | self::PROP_UPDATE,
Expand Down Expand Up @@ -933,10 +933,9 @@ function update_cdb() {
$cdbux = $cdbur ?? Contact::make_cdb_email($this->conf, $this->email);
foreach (self::$props as $prop => $shape) {
if (($shape & self::PROP_CDB) !== 0
&& ($shape & self::PROP_PASSWORD) === 0
&& ($shape & self::PROP_NOUPDATECDB) === 0
&& ($value = $this->prop1($prop, $shape)) !== null
&& $value !== ""
&& $prop !== "updateTime") {
&& $value !== "") {
$cdbux->set_prop($prop, $value, true);
}
}
Expand All @@ -945,6 +944,11 @@ function update_cdb() {
$cdbux->set_prop("passwordTime", $this->passwordTime);
$cdbux->set_prop("passwordUseTime", $this->passwordUseTime);
}
if ($this->disablement === 0) {
$cdbux->set_prop("disabled", $cdbux->disabled & ~Contact::DISABLEMENT_PLACEHOLDER);
} else if (!$cdbur) {
$cdbux->set_prop("disabled", Contact::DISABLEMENT_PLACEHOLDER);
}
if (!empty($cdbux->_mod_undo)) {
assert($cdbux->cdb_confid !== 0);
$cdbux->save_prop();
Expand All @@ -958,12 +962,6 @@ function update_cdb() {
}
}

/** @return int|false
* @deprecated */
function contactdb_update() {
return $this->update_cdb();
}


/** @return bool */
function is_actas_user() {
Expand Down Expand Up @@ -2394,7 +2392,7 @@ function mark_activity() {
&& !$this->is_anonymous_user()) {
$this->activity_at = Conf::$now;
if ($this->contactId) {
$this->conf->ql("update ContactInfo set lastLogin=" . Conf::$now . " where contactId=$this->contactId");
$this->conf->ql("update ContactInfo set lastLogin=" . Conf::$now . " where contactId={$this->contactId}");
}
$this->update_cdb_roles();
}
Expand Down

0 comments on commit 0d7ae53

Please sign in to comment.