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; }
$passwordLength = $ini->variable("UserSettings", "GeneratePasswordLength"); $password = eZUser::createPassword($passwordLength); $passwordConfirm = $password; if ($module->hasActionParameter("Email") && eZMail::validate($module->actionParameter("Email"))) { $email = $module->actionParameter("Email"); if (trim($email) != "") { $users = eZPersistentObject::fetchObjectList(eZUser::definition(), null, array('email' => $email), null, null, true); } if (!empty($users)) { $user = $users[0]; $time = time(); $hashKey = md5($time . ":" . mt_rand()); $db = eZDB::instance(); $db->begin(); // Remove previous generated hash keys for same user eZForgotPassword::removeByUserID($user->id()); $forgotPasswdObj = eZForgotPassword::createNew($user->id(), $hashKey, $time); $forgotPasswdObj->store(); $userToSendEmail = $user; require_once "kernel/common/template.php"; $receiver = $email; $mail = new eZMail(); if (!$mail->validate($receiver)) { } $tpl = templateInit(); $tpl->setVariable('user', $userToSendEmail); $tpl->setVariable('object', $userToSendEmail->attribute('contentobject')); $tpl->setVariable('password', $password); $tpl->setVariable('link', true); $tpl->setVariable('hash_key', $hashKey); $tpl->setVariable('hash_key_lifetime', date("d/m/Y H:i", time() + $forgotPasswdHashLifeTime));