The attached patch implements a new argument validation plugin to check if a domain ID is valid. The validator may optionally be set to also verify the current user's domain memberships or node grants.

The validation logic is somewhat derived from domain_views_access(), but I'm not sure I really understood what was going on with strict option for checking node grants.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Status: Needs review » Needs work

I don't understand how this is working. A validator should ensure that the value is valid, not worry about access.

For instance, this logic just seems wrong to me:

   // Respect "Bypass views access control" permission.
   if (user_access('access all views')) {
     return TRUE;
   }

If the passed argument is "FOO", and FOO is not a domain, then why return TRUE?

I think you just need the validate_argument method, and it should load the passed argument to check if a valid domain is returned.

Les Lim’s picture

If the passed argument is "FOO", and FOO is not a domain, then why return TRUE?

The check directly above that should have already returned FALSE in that case:

    // Ensure that the argument represents an active domain.
    $domains = domain_domains();
    if (empty($domains[$argument])){
      return FALSE;
    }
A validator should ensure that the value is valid, not worry about access.

I'd argue access validation is still validation. There's precedent for that in the Views module itself; if you look at the "Content" argument validator, there's a configuration section for "Validate user has access to the content".

agentrickard’s picture

Status: Needs work » Needs review

Fair enough.