You are here

function views_handler_arg_username in Views (for Drupal 7) 5

1 string reference to 'views_handler_arg_username'
user_views_arguments in modules/views_user.inc

File

modules/views_user.inc, line 309

Code

function views_handler_arg_username($op, &$query, $argtype, $arg = '') {
  switch ($op) {
    case 'summary':
      $query
        ->add_table('users', true);
      $query
        ->add_field('name', 'users');
      $query
        ->add_field('uid', 'users');
      $fieldinfo['field'] = "users.name";
      return $fieldinfo;
      break;
    case 'sort':
      $query
        ->add_orderby('users', 'name', $argtype);
      break;
    case 'filter':
      $name = check_plain($arg);
      $table_data = _views_get_tables();
      $joininfo = $table_data['users']['join'];
      $query
        ->add_table('users', false, 1, $joininfo);
      $query
        ->add_where("users.name = '%s'", $name);
      break;
    case 'link':
      $name = $query->name ? $query->name : variable_get('anonymous', 'Anonymous');
      return l($name, "{$arg}/" . check_plain($name));
    case 'title':
      if (!$query) {
        return variable_get('anonymous', 'Anonymous');
      }
      $user = db_fetch_object(db_query("SELECT name FROM {users} WHERE name = '%s'", $query));
      return check_plain($user->name);
  }
}