You are here

function commentaccess_comment_view in Comment Access 7

Implementation of hook_comment_view().

Adds approve and delete links for node authors.

File

./commentaccess.module, line 176
Provides users with permissions for comments on nodes they own.

Code

function commentaccess_comment_view($comment, $view_mode, $langcode) {

  // Comment module adds these links for users with 'administer comments'
  if (!user_access('administer comments')) {
    if (commentaccess_access_check($comment, 'delete') && empty($comment->content['links']['comment']['#links']['comment-delete'])) {
      $comment->content['links']['comment']['#links']['comment-delete'] = array(
        'title' => t('delete'),
        'href' => 'comment/' . $comment->cid . '/delete',
        'html' => TRUE,
      );
    }
    if (commentaccess_access_check($comment, 'approve') && empty($comment->content['links']['comment']['#links']['comment-approve'])) {
      $comment->content['links']['comment']['#links']['comment-approve'] = array(
        'title' => t('approve'),
        'href' => 'comment/' . $comment->cid . '/approve',
        'html' => TRUE,
        'query' => array(
          'token' => drupal_get_token("comment/{$comment->cid}/approve"),
        ),
      );
    }
  }
}