You are here

function views_handler_arg_signup_uid in Signup 5.2

An argument handler for signup_uid

1 string reference to 'views_handler_arg_signup_uid'
_signup_views_arguments in views/views.inc
Private implementation of hook_views_arguments().

File

views/views.inc, line 256
Provides support for Views integration.

Code

function views_handler_arg_signup_uid($op, &$query, $argtype, $arg = '') {
  switch ($op) {
    case 'summary':
      $query
        ->add_table('signup_log', TRUE);
      $query
        ->add_field('uid', 'signup_log');
      $fieldinfo['field'] = "signup_log.uid";
      return $fieldinfo;
    case 'sort':
      $query
        ->add_orderby('users', 'name', $argtype);
      break;
    case 'filter':
      $option = $argtype['options'];
      $uid = intval($arg);
      if ($option) {
        $query
          ->ensure_table('signup_log');
        $query
          ->add_where("signup_log.uid = {$uid}");
      }
      else {
        $joininfo = array(
          'type' => 'LEFT',
          'left' => array(
            'table' => 'node',
            'field' => 'nid',
          ),
          'right' => array(
            'field' => 'nid',
          ),
          'extra' => array(
            'uid' => $uid,
          ),
        );
        $num = $query
          ->add_table('signup_log', TRUE, 1, $joininfo);
        $tablename = $query
          ->get_table_name('signup_log', $num);
        $query
          ->add_where("{$tablename}.uid IS NULL");
      }
      break;
    case 'link':
      $name = $query->name ? $query->name : variable_get('anonymous', t('Anonymous'));
      return l($name, "{$arg}/" . intval($query->uid));
    case 'title':
      if (!$query) {
        return variable_get('anonymous', t('Anonymous'));
      }
      $user = db_fetch_object(db_query("SELECT name FROM {users} WHERE uid = '%d'", $query));
      return $user->name;
  }
}