1 |
85ad3d82
|
Assos Assos
|
<?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 |
a45e4bc1
|
Assos Assos
|
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 |
85ad3d82
|
Assos Assos
|
/**
|
30 |
|
|
* Renders the link.
|
31 |
|
|
*/
|
32 |
|
|
function render_link($node, $values) {
|
33 |
a45e4bc1
|
Assos Assos
|
// 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 |
85ad3d82
|
Assos Assos
|
return;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
$this->options['alter']['make_link'] = TRUE;
|
44 |
a45e4bc1
|
Assos Assos
|
$this->options['alter']['path'] = "node/$node->nid/webform-results" .
|
45 |
|
|
(strlen($this->options['subpath']) ? '/' . $this->options['subpath'] : '');
|
46 |
85ad3d82
|
Assos Assos
|
|
47 |
|
|
$text = !empty($this->options['text']) ? $this->options['text'] : t('results');
|
48 |
|
|
return $text;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
} |