You are here

function shurly_handler_field_shurly_link_delete::render in ShURLy 7

Same name and namespace in other branches
  1. 6 views/shurly_handler_field_shurly_link_delete.inc \shurly_handler_field_shurly_link_delete::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

views/shurly_handler_field_shurly_link_delete.inc, line 39
Shurly Views handler for delete links function

Class

shurly_handler_field_shurly_link_delete
Field handler to present a link to the short URL entry.

Code

function render($values) {
  global $user;
  $uid = $values->{$this->aliases['uid']};
  $active = $values->{$this->aliases['active']};
  if (!$active) {
    return t('deactivated');
  }

  // only allow the user to view the link if they can actually delete
  if (user_access('Administer short URLs') || user_access('Delete own URLs') && $uid == $user->uid) {
    $text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
    $rid = $values->rid;
    return l($text, "shurly/delete/{$rid}", array(
      'query' => drupal_get_destination(),
    ));
  }
}