commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / views / modules / comment / views_handler_field_comment_link_edit.inc
1 <?php
2
3 /**
4 * @file
5 * Definition of views_handler_field_comment_link_edit.
6 */
7
8 /**
9 * Field handler to present a link node edit.
10 *
11 * @ingroup views_field_handlers
12 */
13 class views_handler_field_comment_link_edit extends views_handler_field_comment_link {
14 function option_definition() {
15 $options = parent::option_definition();
16 $options['destination'] = array('default' => FALSE, 'bool' => TRUE);
17
18 return $options;
19 }
20
21 function options_form(&$form, &$form_state) {
22 parent::options_form($form, $form_state);
23
24 $form['destination'] = array(
25 '#type' => 'checkbox',
26 '#title' => t('Use destination'),
27 '#description' => t('Add destination to the link'),
28 '#default_value' => $this->options['destination'],
29 '#fieldset' => 'more',
30 );
31 }
32
33 function render_link($data, $values) {
34 parent::render_link($data, $values);
35 // ensure user has access to edit this comment.
36 $comment = $this->get_value($values);
37 if (!comment_access('edit', $comment)) {
38 return;
39 }
40
41 $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
42 unset($this->options['alter']['fragment']);
43
44 if (!empty($this->options['destination'])) {
45 $this->options['alter']['query'] = drupal_get_destination();
46 }
47
48 $this->options['alter']['path'] = "comment/" . $comment->cid . "/edit";
49
50 return $text;
51 }
52 }