diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index 4e3d585026..1cf37ff8ed 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -199,6 +199,7 @@ define('LOG_MESSAGE_DATA', 'message_data'); define('LOG_MESSAGE_DELETE', 'msg_deleted'); define('LOG_USER_DELETE', 'user_deleted'); +define('LOG_USER_PREDELETE', 'user_predeleted'); define('LOG_USER_CREATE', 'user_created'); define('LOG_USER_UPDATE', 'user_updated'); define('LOG_USER_PASSWORD_UPDATE', 'user_password_updated'); @@ -1620,7 +1621,7 @@ function api_get_user_info_from_entity( $result['phone'] = $user->getPhone(); $result['address'] = $user->getAddress(); $result['official_code'] = $user->getOfficialCode(); - $result['active'] = $user->getActive(); + $result['active'] = $user->isActive(); $result['auth_source'] = $user->getAuthSource(); $result['language'] = $user->getLocale(); $result['creator_id'] = $user->getCreatorId(); diff --git a/public/main/inc/lib/message.lib.php b/public/main/inc/lib/message.lib.php index 87f2216fc6..4e57341d54 100644 --- a/public/main/inc/lib/message.lib.php +++ b/public/main/inc/lib/message.lib.php @@ -158,7 +158,7 @@ class MessageManager } // Disabling messages for inactive users. - if (!$userRecipient->getActive()) { + if (!$userRecipient->isActive()) { return false; } diff --git a/public/main/inc/lib/usermanager.lib.php b/public/main/inc/lib/usermanager.lib.php index 44dafa062c..2c4ee28eeb 100644 --- a/public/main/inc/lib/usermanager.lib.php +++ b/public/main/inc/lib/usermanager.lib.php @@ -1047,7 +1047,7 @@ class UserManager } $change_active = 0; - $isUserActive = $user->getActive(); + $isUserActive = $user->isActive(); if ($isUserActive != $active) { $change_active = 1; } diff --git a/public/main/inc/lib/webservices/Rest.php b/public/main/inc/lib/webservices/Rest.php index a680589183..9abb6bc4d7 100644 --- a/public/main/inc/lib/webservices/Rest.php +++ b/public/main/inc/lib/webservices/Rest.php @@ -1903,7 +1903,17 @@ class Rest extends WebService // see UserManager::update_user() usermanager.lib.php:1205 if ($user->getActive() != $value) { $user->setActive($value); - Event::addEvent($value ? LOG_USER_ENABLE : LOG_USER_DISABLE, LOG_USER_ID, $userId); + switch ($value) { + case 1: + Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $userId); + break; + case 0: + Event::addEvent(LOG_USER_DISABLE, LOG_USER_ID, $userId); + break; + case -1: + Event::addEvent(LOG_USER_PREDELETE, LOG_USER_ID, $userId); + break; + } } break; case 'openid': diff --git a/public/main/webservices/cm_webservice.php b/public/main/webservices/cm_webservice.php index b627cb2e26..e76e284710 100644 --- a/public/main/webservices/cm_webservice.php +++ b/public/main/webservices/cm_webservice.php @@ -135,7 +135,7 @@ class WSCM // Check the user's password if ($passwordEncoded == $uData->getPassword() && (trim($login) == $uData->getUsername())) { // Check if the account is active (not locked) - if ($uData->getActive()) { + if ($uData->isActive()) { // Check if the expiration date has not been reached $now = new DateTime(); if ($uData->getExpirationDate() > $now || !$uData->getExpirationDate()) { diff --git a/src/CoreBundle/Entity/User.php b/src/CoreBundle/Entity/User.php index 6c4bbddac4..52502a3eb0 100644 --- a/src/CoreBundle/Entity/User.php +++ b/src/CoreBundle/Entity/User.php @@ -935,9 +935,18 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso return $this; }*/ + + /** + * Get a bool on whether the user is active or not. Active can be "-1" which means pre-deleted, and is returned as false (not active) + * @return bool True if active = 1, false in any other case (0 = inactive, -1 = predeleted) + */ public function getIsActive(): bool { - return $this->active; + if ($this->active == 1) { + return true; + } else { + return false; + } } public function isEnabled(): bool diff --git a/src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php b/src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php index aee7975969..d7d214152f 100644 --- a/src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php +++ b/src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php @@ -76,7 +76,7 @@ class AnonymousUserSubscriber implements EventSubscriberInterface 'official_code' => $user->getOfficialCode(), 'picture_uri' => $user->getPictureUri(), 'status' => $user->getStatus(), - 'active' => $user->getActive(), + 'active' => $user->isActive(), 'auth_source' => $user->getAuthSource(), 'theme' => $user->getTheme(), 'language' => $user->getLocale(),