Projet

Général

Profil

Paste
Télécharger (827 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / user / views_handler_field_user_link_cancel.inc @ 6eb8d15f

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
  function render_link($data, $values) {
16
    $uid = $values->{$this->aliases['uid']};
17

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

    
22
    if ($uid && user_cancel_access($account)) {
23
      $this->options['alter']['make_link'] = TRUE;
24

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

    
27
      $this->options['alter']['path'] = "user/$uid/cancel";
28
      $this->options['alter']['query'] = drupal_get_destination();
29

    
30
      return $text;
31
    }
32
  }
33
}