You are here

function _me_views_set_argument in me aliases 6

Helper function to set the views user arguments we override.

Parameters

$arg: The arg(s) we are checking.

&$view: The view object.

$break_phase: Helps us determine if there are multiple arguments.

$username: Wehter or not this is the username argument.

Return value

string The modified argument list.

2 calls to _me_views_set_argument()
me_views_handler_argument_user_name::set_argument in includes/me_views_handler_argument_user_name.inc
Set the input for this argument
me_views_handler_argument_user_uid::set_argument in includes/me_views_handler_argument_user_uid.inc
Set the input for this argument

File

includes/me.views.inc, line 73
Provides views intergration for the me module.

Code

function _me_views_set_argument($arg, &$view, $break_phase, $username = FALSE) {
  $uid_args = array();
  $seperator = ' ';
  if (empty($break_phase)) {
    $uid_args[] = $arg;
  }
  else {

    // Modified from views_break_phrase() to include characters that a 'me' alias
    // may include.
    if (preg_match('/^([0-9a-zA-Z]+[+ ])+[0-9a-zA-Z]+$/', $arg)) {

      // The '+' character in a query string may be parsed as ' '.
      $uid_args = preg_split('/[+ ]/', $arg);
    }
    else {
      if (preg_match('/^([0-9a-zA-Z]+,)*[0-9a-zA-Z]+$/', $arg)) {
        $seperator = ',';
        $uid_args = explode(',', $arg);
      }
    }
  }

  // Be sure not to redirect in a live preview.
  if (!empty($view->live_preview)) {
    $view->me_redirect = FALSE;
  }

  // Check if we need to do a redirect, and make sure the option is disabled if we don't.
  if ($view->me_redirect) {
    $redirect_args = array_filter($uid_args, create_function('$n', 'return _me_is_alias($n);'));
    if (empty($redirect_args)) {
      $view->me_redirect = FALSE;
    }
  }

  // The alias could potentially show up more than once. Loop over each argument
  // and check to be sure.
  foreach ($uid_args as $key => $uid_arg) {
    $uid_args[$key] = _me_check_arg($uid_arg, $username, FALSE);
  }
  return implode($seperator, $uid_args);
}