You are here

function domain_views_handler_arg_domain_id in Domain Access 5

This is the function that handles all the work for dealing with view arguments There is some *very rough* documentation on argument handlers for views here http://drupal.org/node/99566.

1 string reference to 'domain_views_handler_arg_domain_id'
domain_views_arguments in domain_views/domain_views.module
Implement hook_views_arguments(). Provide a filter that restricts a view to only show nodes from a specific domain (by domain_id). If you pass "current" as the argument, it filters according to the domain the page is being viewed from.

File

domain_views/domain_views.module, line 97
Provides a Views filter for the Domain Access module.

Code

function domain_views_handler_arg_domain_id($op, &$query, $argtype, $arg = '') {
  switch ($op) {
    case 'summary':
      $query
        ->add_table('domain_access');

      // Re-uses the node_access table info from the domain_views_tables() function
      $query
        ->add_table('domain');

      // Re-uses the domain table info from the domain_views_tables() function
      $query
        ->add_field('sitename', 'domain');
      $query
        ->add_field('domain_id', 'domain');
      $query
        ->add_where("domain.valid = '%s'", 1);

      // don't show summary item for inactive domains
      $fieldinfo['field'] = "domain.domain_id";
      return $fieldinfo;
    case 'sort':
      $query
        ->add_orderby('domain', 'sitename', $argtype);
      break;
    case 'filter':
      $domain_id = $arg == 'current' ? (int) $GLOBALS['_domain']['domain_id'] : (int) $arg;
      $query
        ->add_table('domain_access');
      $query
        ->add_where("domain_access.gid = '%s'", $domain_id);

      // domain_access is an alias for the node_access table
      $query
        ->set_distinct();
      break;
    case 'link':
      return l($query->sitename, "{$arg}/" . intval($query->domain_id));
    case 'title':
      return '';
  }
}