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 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * Views handler to display a results link for Webform submissions.
5 01f36513 Assos Assos
 *
6 85ad3d82 Assos Assos
 * 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 feca1e4a Assos Assos
  /**
11
   *
12
   */
13
  public function option_definition() {
14 a45e4bc1 Assos Assos
    $options = parent::option_definition();
15
    $options['subpath'] = array('default' => '');
16
    return $options;
17
  }
18
19 feca1e4a Assos Assos
  /**
20
   *
21
   */
22
  public function options_form(&$form, &$form_state) {
23 a45e4bc1 Assos Assos
    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 85ad3d82 Assos Assos
  /**
33
   * Renders the link.
34
   */
35 feca1e4a Assos Assos
  public function render_link($node, $values) {
36 a45e4bc1 Assos Assos
    // 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 85ad3d82 Assos Assos
      return;
44
    }
45
46
    $this->options['alter']['make_link'] = TRUE;
47 a45e4bc1 Assos Assos
    $this->options['alter']['path'] = "node/$node->nid/webform-results" .
48
                                      (strlen($this->options['subpath']) ? '/' . $this->options['subpath'] : '');
49 85ad3d82 Assos Assos
50
    $text = !empty($this->options['text']) ? $this->options['text'] : t('results');
51
    return $text;
52
  }
53
54
}