Projet

Général

Profil

Paste
Télécharger (1,51 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / webform / views / webform_handler_field_node_link_results.inc @ 01f36513

1
<?php
2

    
3
/**
4
 * Views handler to display a results link for Webform submissions.
5
 *
6
 * Field handler to present a link node edit.
7
 */
8
class webform_handler_field_node_link_results extends views_handler_field_node_link {
9

    
10
  /**
11
   *
12
   */
13
  public function option_definition() {
14
    $options = parent::option_definition();
15
    $options['subpath'] = array('default' => '');
16
    return $options;
17
  }
18

    
19
  /**
20
   *
21
   */
22
  public function options_form(&$form, &$form_state) {
23
    parent::options_form($form, $form_state);
24
    $form['subpath'] = array(
25
      '#type' => 'textfield',
26
      '#title' => t('Subpath'),
27
      '#default_value' => $this->options['subpath'],
28
      '#field_prefix' => 'node/NID/webform-results/',
29
    );
30
  }
31

    
32
  /**
33
   * Renders the link.
34
   */
35
  public function render_link($node, $values) {
36
    // Ensure node is webform-enabled and user has access node's webform results.
37
    if (!in_array($node->type, webform_node_types()) || !webform_results_access($node)) {
38
      return;
39
    }
40

    
41
    // For clear, ensure user has access to clear all the submissions.
42
    if (stripos($this->options['subpath'], 'clear') === 0 && !user_access('delete all webform submissions')) {
43
      return;
44
    }
45

    
46
    $this->options['alter']['make_link'] = TRUE;
47
    $this->options['alter']['path'] = "node/$node->nid/webform-results" .
48
                                      (strlen($this->options['subpath']) ? '/' . $this->options['subpath'] : '');
49

    
50
    $text = !empty($this->options['text']) ? $this->options['text'] : t('results');
51
    return $text;
52
  }
53

    
54
}