You are here

function views_attach_plugin_display_profile::pre_execute in Views attach 7.2

Same name and namespace in other branches
  1. 6.2 views_attach_plugin_display_profile.inc \views_attach_plugin_display_profile::pre_execute()

We have to run token replacement before the arguments are used.

Overrides views_plugin_display::pre_execute

File

./views_attach_plugin_display_profile.inc, line 171

Class

views_attach_plugin_display_profile
The plugin that handles a user profile.

Code

function pre_execute() {

  // Call the parent setup function so we do not lose data.
  parent::pre_execute();
  $account = $this->view->current_account;
  $arg_mode = $this->view->display_handler
    ->get_option('argument_mode');
  if (module_exists('token') && $arg_mode == 'token') {
    if ($token_string = $this->view->display_handler
      ->get_option('default_argument')) {

      // Now do the token replacement.
      $token_values = views_attach_get_arguments_from_token_string($token_string, 'user', $account);
      $new_args = array();

      // We have to be careful to only replace arguments that have tokens.
      foreach ($token_values as $key => $value) {
        $new_args[$key] = $value;
      }
      $this->view->args = $new_args;
    }
  }
  elseif ($arg_mode == 'uid') {
    $this->view->args = array(
      $account->uid,
    );
  }
}