You are here

function ajax_comments_link_alter in AJAX Comments 6

Implementation of hook_link_alter().

File

./ajax_comments.module, line 227
Implements AJAX handling for Drupal comment forms.

Code

function ajax_comments_link_alter(&$links, $node, $comment = NULL) {
  $node = menu_get_object();
  $allowed_node_types = variable_get('ajax_comments_node_types', array());
  $all_allowed = TRUE;
  foreach ($allowed_node_types as $type) {
    if ($type) {
      $all_allowed = FALSE;
      break;
    }
  }
  if ($all_allowed || isset($allowed_node_types[$node->type]) && $allowed_node_types[$node->type]) {
    if (is_array($links) && isset($links['comment_delete']) && isset($comment->cid)) {
      $links['comment_delete'] = array(
        'title' => t('delete'),
        'href' => 'comment/delete/' . $comment->cid,
        'query' => 'token=' . drupal_get_token($comment->cid),
      );
    }
  }
}