Skip to content

Instantly share code, notes, and snippets.

@cezar62882
Created March 24, 2016 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cezar62882/bfbd817be5ffa477ccf9 to your computer and use it in GitHub Desktop.
Save cezar62882/bfbd817be5ffa477ccf9 to your computer and use it in GitHub Desktop.
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