You are here

function UserpointsTransaction::defaultUri in User Points 7.2

Overrides Entity::defaultUri().

Parameters

bool $prefix_only: If only the url prefix (without /view suffix) should be returned. Defaults to FALSE.

Overrides Entity::defaultUri

1 call to UserpointsTransaction::defaultUri()
UserpointsTransaction::getActions in ./userpoints.transaction.inc
Returns a list of operations as links.

File

./userpoints.transaction.inc, line 140
Contains the UserpointsTransaction and related classes.

Class

UserpointsTransaction
A Userpoints transaction.

Code

function defaultUri($prefix_only = FALSE) {
  global $user;
  $uri = array(
    // Default path is displaying it below myuserpoints for the current user.
    'path' => 'myuserpoints/transaction/' . $this->txn_id,
    'options' => array(),
  );

  // When viewing the transaction in the admin UI (but not the add points page, as this might be called for generating
  // tokens), use the admin link.
  if (strpos($_GET['q'], 'admin/config/people/userpoints') !== FALSE && strpos($_GET['q'], 'admin/config/people/userpoints/add') === FALSE) {
    $uri['path'] = "admin/config/people/userpoints/transaction/{$this->txn_id}";
  }
  elseif ($this->uid != $user->uid) {

    // When not in the admin ui but viewing the transaction of someone else, use the path for another user.
    $uri['path'] = "user/{$this->uid}/points/{$this->txn_id}";
  }
  if (!$prefix_only) {
    $uri['path'] .= '/view';
  }
  return $uri;
}