/** * Will check if UserID provided in credentials is valid * @see ezcAuthenticationFilter::run() */ public function run($credentials) { $status = self::STATUS_INVALID_USER; $count = eZPersistentObject::count(eZUser::definition(), array('contentobject_id' => (int) $credentials->id)); if ($count > 0) { $status = self::STATUS_OK; } return $status; }
/** * @param eZTags $tags * * @return eZUser[] */ public static function fetchUserList(eZTags $tags) { $tagIds = $tags->attribute('tag_ids'); $roles = array(); if (is_array($tagIds) && !empty($tagIds)) { $roles = eZPersistentObject::fetchObjectList(ITNewsletterNotificationRule::definition(), array('user_id'), array('tag_id' => array($tagIds)), null, null, false); } $userIds = array(); foreach ($roles as $role) { $userIds[] = $role['user_id']; } $userIds = array_unique($userIds); $users = array(); if (!empty($userIds)) { $users = eZPersistentObject::fetchObjectList(eZUser::definition(), null, array('contentobject_id' => array($userIds))); } foreach ($users as $index => $user) { if (!$user->attribute('is_enabled')) { unset($users[$index]); } } return $users; }
if ( $module->isCurrentAction( "Generate" ) ) { $ini = eZINI::instance(); $passwordLength = $ini->variable( "UserSettings", "GeneratePasswordLength" ); $password = eZUser::createPassword( $passwordLength ); $passwordConfirm = $password; // $http->setSessionVariable( "GeneratedPassword", $password ); if ( $module->hasActionParameter( "Email" ) ) { $email = $module->actionParameter( "Email" ); if ( trim( $email ) != "" ) { $users = eZPersistentObject::fetchObjectList( eZUser::definition(), null, array( 'email' => $email ), null, null, true ); } if ( isset($users) && count($users) > 0 ) { $user = $users[0]; $time = time(); $userID = $user->id(); $hashKey = md5( $userID . ':' . $time . ':' . mt_rand() ); // Create forgot password object if ( eZOperationHandler::operationIsAvailable( 'user_forgotpassword' ) )
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; }
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; }
} } else { if (strlen($hashKey) > 4) { $tpl->setVariable('wrong_key', true); } } if ($module->isCurrentAction("Generate")) { $ini = eZINI::instance(); $passwordLength = $ini->variable("UserSettings", "GeneratePasswordLength"); $password = eZUser::createPassword($passwordLength); $passwordConfirm = $password; // $http->setSessionVariable( "GeneratedPassword", $password ); if ($module->hasActionParameter("Email")) { $email = $module->actionParameter("Email"); if (trim($email) != "") { $users = eZPersistentObject::fetchObjectList(eZUser::definition(), null, array('email' => $email), null, null, true); } if (isset($users) && count($users) > 0) { $user = $users[0]; $time = time(); $userID = $user->id(); $hashKey = md5($userID . ':' . microtime() . ':' . (function_exists("openssl_random_pseudo_bytes") ? openssl_random_pseudo_bytes(32) : mt_rand())); // Create forgot password object if (eZOperationHandler::operationIsAvailable('user_forgotpassword')) { $operationResult = eZOperationHandler::execute('user', 'forgotpassword', array('user_id' => $userID, 'password_hash' => $hashKey, 'time' => $time)); } else { eZUserOperationCollection::forgotpassword($userID, $hashKey, $time); } $userToSendEmail = $user; $receiver = $email; $mail = new eZMail();