dblog_user_filter.module

Tracking 6.x-3.x branch
  1. drupal
    1. 6 contributions/util/contribs/dblog_ext/dblog_filters/dblog_user_filter.module

Functions & methods

NameDescription
dblog_user_filter_log_filtersImplementation of hook_log_filters() on behalf of dblog.
dblog_user_filter_log_filters_settingsImplementation of hook_log_filters_settings().

File

View source
  1. <?php
  2. /**
  3. * Implementation of hook_log_filters_settings().
  4. */
  5. function dblog_user_filter_log_filters_settings() {
  6. $settings['username'] = array(
  7. 'title' => 'Username',
  8. 'description' => 'Filters by username with autocompletion.',
  9. //'page arguments' => array('dblog_user_filter_settings'),
  10. //'file' => 'dblog_filters.user.admin.inc',
  11. );
  12. return $settings;
  13. }
  14. /**
  15. * Implementation of hook_log_filters() on behalf of dblog.
  16. */
  17. function dblog_user_filter_log_filters() {
  18. if (!dblog_filters_is_enabled('username')) {
  19. return array();
  20. }
  21. // $user_list = array('' => t('- None -'));
  22. $use_realname = module_exists('realname');
  23. $result = db_query("SELECT DISTINCT(w.uid) AS x, u.* FROM {watchdog} w INNER JOIN {users} u ON u.uid = w.uid");
  24. while ($row = db_fetch_object($result)) {
  25. $user_list[$row->uid] = ($row->uid == 0 || $use_realname) ? theme('username', $row, array('plain' => TRUE)) : $row->name;
  26. }
  27. // Sort the list by user name.
  28. asort($user_list);
  29. $filters['username'] = array(
  30. 'title' => t('Username'),
  31. 'where' => "u.uid = %d",
  32. 'conjunction' => TRUE,
  33. 'options' => $user_list,
  34. );
  35. return $filters;
  36. }