1 views_plugin_argument_default_user.inc views_plugin_argument_default_user::get_argument()

Return the default argument.

This needs to be overridden by every default argument handler to properly do what is needed.

Overrides views_plugin_argument_default::get_argument

File

core/modules/user/views/views_plugin_argument_default_user.inc, line 33
Contains the user from URL argument default plugin.

Class

views_plugin_argument_default_user
Default argument plugin to extract a user via menu_get_object.

Code

function get_argument() {
  foreach (range(1, 3) as $i) {
    $user = menu_get_object('user', $i);
    if (!empty($user)) {
      return $user->uid;
    }
  }

  foreach (range(1, 3) as $i) {
    $user = menu_get_object('user_uid_optional', $i);
    if (!empty($user)) {
      return $user->uid;
    }
  }

  if (!empty($this->options['user'])) {
    foreach (range(1, 3) as $i) {
      $node = menu_get_object('node', $i);
      if (!empty($node)) {
        return $node->uid;
      }
    }
  }

  if (arg(0) == 'user' && is_numeric(arg(1))) {
    return arg(1);
  }

  if (!empty($this->options['user'])) {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if ($node) {
        return $node->uid;
      }
    }
  }

  // If the current page is a view that takes uid as an argument, return the uid.
  $view = views_get_page_view();

  if ($view && isset($view->argument['uid'])) {
    return $view->argument['uid']->argument;
  }
}