Projet

Général

Profil

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

root / drupal7 / sites / all / modules / webform / views / webform_handler_field_node_link_results.inc @ 651307cd

1
<?php
2

    
3
/**
4
 * @file
5
 * Views handler to display a results link for Webform submissions.
6
 */
7

    
8
/**
9
 * Field handler to present a link node edit.
10
 */
11
class webform_handler_field_node_link_results extends views_handler_field_node_link {
12

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

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

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

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

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

    
47
    $text = !empty($this->options['text']) ? $this->options['text'] : t('results');
48
    return $text;
49
  }
50

    
51
}