static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); // only remove general digest setting if there are no other users with the same e-mail $email = $user->attribute('email'); $usersWithEmailCount = eZPersistentObject::count(eZUser::definition(), array('email' => $email)); if ($usersWithEmailCount == 1) { eZGeneralDigestUserSettings::removeByAddress($email); } eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); eZGeneralDigestUserSettings::removeByUserId($userID); eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
/** * Activate user with user or deactivate and create new eZUserAccountKey with user hash * depending on $enableUser being true or not. * * @param int $userID * @param string $userHash * @param bool $enableUser * * @return array An array with operation status, always true if userID is ok */ public static function activation($userID, $userHash, $enableUser = false) { $user = eZUser::fetch($userID); $userSetting = eZUserSetting::fetch($userID); if ($user && $userSetting) { $userChange = $userSetting->attribute('is_enabled') != $enableUser; if ($enableUser) { $userSetting->setAttribute('is_enabled', 1); $userSetting->store(); eZUserAccountKey::removeByUserID($userID); } else { $userSetting->setAttribute('is_enabled', 0); $userSetting->store(); $accountKey = eZUserAccountKey::createNew($userID, $userHash, time()); $accountKey->store(); } if ($userChange) { if (!$enableUser) { eZUser::removeSessionData($userID); } eZContentCacheManager::clearContentCacheIfNeeded($userID); } return array('status' => true); } else { eZDebug::writeError("Failed to activate user {$userID} (could not fetch)", __METHOD__); return array('status' => false); } }