Project

General

Profile

Paste
Download (866 Bytes) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / views / modules / user / views_handler_field_user_link_cancel.inc @ 8be7bf84

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_field_user_link_cancel.
6
 */
7

    
8
/**
9
 * Field handler to present a link to user cancel.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_user_link_cancel extends views_handler_field_user_link {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function render_link($data, $values) {
19
    $uid = $values->{$this->aliases['uid']};
20

    
21
    // Build a pseudo account object to be able to check the access.
22
    $account = new stdClass();
23
    $account->uid = $uid;
24

    
25
    if ($uid && user_cancel_access($account)) {
26
      $this->options['alter']['make_link'] = TRUE;
27

    
28
      $text = !empty($this->options['text']) ? $this->options['text'] : t('Cancel account');
29

    
30
      $this->options['alter']['path'] = "user/$uid/cancel";
31
      $this->options['alter']['query'] = drupal_get_destination();
32

    
33
      return $text;
34
    }
35
  }
36

    
37
}