views_handler_field_user_link_cancel.inc 819 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_user_link_cancel.
  5. */
  6. /**
  7. * Field handler to present a link to user cancel.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_user_link_cancel extends views_handler_field_user_link {
  12. function render_link($data, $values) {
  13. $uid = $values->{$this->aliases['uid']};
  14. // Build a pseudo account object to be able to check the access.
  15. $account = new stdClass();
  16. $account->uid = $uid;
  17. if ($uid && user_cancel_access($account)) {
  18. $this->options['alter']['make_link'] = TRUE;
  19. $text = !empty($this->options['text']) ? $this->options['text'] : t('cancel');
  20. $this->options['alter']['path'] = "user/$uid/cancel";
  21. $this->options['alter']['query'] = drupal_get_destination();
  22. return $text;
  23. }
  24. }
  25. }