Created
March 24, 2016 12:17
-
-
Save cezar62882/bfbd817be5ffa477ccf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function deleteExpiredPasswords() { | |
$user_ids = $this->getUserIdsWithAlreadyExpiredPassword(); | |
if (!$user_ids) { | |
return []; | |
} | |
// Выставляем флаг сброса пароля админом | |
foreach ($user_ids as $user_id) { | |
$user = User::model()->findByPk($user_id); | |
if ($user !== null) { | |
$user->admin_change_password = true; | |
$user->save(['admin_change_password']); | |
} | |
} | |
// Удаляем данные о сроке действия паролей для этих пользователей | |
$user_ids_string = implode(', ', $user_ids); | |
$query = "DELETE FROM ".self::TABLE_NAME." WHERE user_id IN ({$user_ids_string})"; | |
\App::i()->getDbConnection()->query($query); | |
return $user_ids; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment