diff --git a/login_history.module b/login_history.module index 624774b..98991a3 100644 --- a/login_history.module +++ b/login_history.module @@ -32,7 +32,7 @@ function login_history_user_login($account) { } // Now save the user's current login timestamp to login_history. - db_insert('login_history') + \Drupal::database()->insert('login_history') ->fields(array( 'uid' => $account->id(), 'login' => $account->getLastLoginTime(), @@ -60,7 +60,7 @@ function login_history_last_login(AccountInterface $account = NULL) { if ($account->isAnonymous()) { return; } - $last_login = db_query("SELECT login, hostname, one_time, user_agent + $last_login = \Drupal::database()->insert("SELECT login, hostname, one_time, user_agent FROM {login_history} WHERE uid = :uid ORDER BY login DESC diff --git a/src/Controller/LoginHistoryController.php b/src/Controller/LoginHistoryController.php index 21afd31..380ed2e 100644 --- a/src/Controller/LoginHistoryController.php +++ b/src/Controller/LoginHistoryController.php @@ -11,8 +11,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Access\AccessResult; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatterInterface; -use Drupal\user\Entity\User; -use Drupal\user\UserInterface; +use Drupal\Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -58,7 +57,7 @@ class LoginHistoryController extends ControllerBase { array('data' => t('User Agent')), ); - $query = db_select('login_history', 'lh') + $query = \Drupal::database()->select('login_history', 'lh') ->extend('Drupal\Core\Database\Query\TableSortExtender') ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); @@ -104,7 +103,7 @@ class LoginHistoryController extends ControllerBase { foreach ($history as $entry) { $rows[] = array( $this->dateFormatter->format($entry->login, 'small'), - $users[$entry->uid]->getUsername(), + $users[$entry->uid]->getDisplayName(), $entry->hostname, empty($entry->one_time) ? t('Regular login') : t('One-time login'), $entry->user_agent,