views_handler_field_comment_link_approve.inc

Definition of views_handler_field_comment_link_approve.

File

modules/comment/views_handler_field_comment_link_approve.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_comment_link_approve.
  5. */
  6. /**
  7. * Provides a comment approve link.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_comment_link_approve extends views_handler_field_comment_link {
  12. function access() {
  13. //needs permission to administer comments in general
  14. return user_access('administer comments');
  15. }
  16. function render_link($data, $values) {
  17. $status = $this->get_value($values, 'status');
  18. // Don't show an approve link on published nodes.
  19. if ($status == COMMENT_PUBLISHED) {
  20. return;
  21. }
  22. $text = !empty($this->options['text']) ? $this->options['text'] : t('approve');
  23. $cid = $this->get_value($values, 'cid');
  24. $this->options['alter']['make_link'] = TRUE;
  25. $this->options['alter']['path'] = "comment/" . $cid . "/approve";
  26. $this->options['alter']['query'] = drupal_get_destination() + array('token' => drupal_get_token("comment/$cid/approve"));
  27. return $text;
  28. }
  29. }