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

File

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