You are here

function user_views_convert in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 6.2 modules/user.views_convert.inc \user_views_convert()

Implementation of hook_views_convert().

File

modules/user.views_convert.inc, line 11
Field conversion for fields handled by this module.

Code

function user_views_convert($display, $type, &$view, $field, $id = NULL) {
  switch ($type) {
    case 'field':
      switch ($field['tablename']) {
        case 'users':
          switch ($field['field']) {
            case 'uid':
              $view
                ->set_item_option($display, 'field', $id, 'field', 'picture');
              break;
          }
          break;
      }
      break;
    case 'filter':
      if ($field['tablename'] == 'users' || !strncmp($field['tablename'], 'users_role_', 11)) {
        switch ($field['field']) {
          case 'uid':
            $operators = array(
              'OR' => 'in',
              'NOR' => 'not in',
            );
            $view
              ->set_item_option($display, 'filter', $id, 'operator', $operators[$field['operator']]);
            if ($rid = (int) substr($field['tablename'], 11)) {
              $view
                ->add_item($display, 'filter', 'users_roles', 'rid', array(
                'value' => $rid,
              ));
            }
            break;
        }
      }
      elseif ($field['tablename'] == 'users_roles') {
        switch ($field['field']) {
          case 'rid':
            $operators = array(
              'AND' => 'and',
              'OR' => 'or',
              'NOR' => 'not',
            );
            $view
              ->set_item_option($display, 'filter', $id, 'operator', $operators[$field['operator']]);
            break;
        }
      }
      break;
    case 'argument':
      $options = $field['argoptions'];
      switch ($field['type']) {
        case 'uid':
          $view
            ->add_item($display, 'argument', 'users', 'uid', $options, $field['id']);
          break;
        case 'uidtouch':
          $view
            ->add_item($display, 'argument', 'node', 'uid_touch', $options, $field['id']);
          break;
        case 'username':
          $view
            ->add_item($display, 'argument', 'users', 'name', $options, $field['id']);
          break;
      }
      break;
  }
}