views_handler_field_comment_link_edit.inc

  1. 3.x modules/comment/views_handler_field_comment_link_edit.inc
  2. 2.x modules/comment/views_handler_field_comment_link_edit.inc

Definition of views_handler_field_comment_link_edit.

File

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