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