1.20.x comment.pages.inc comment_approve($cid)

Page callback: Publishes the specified comment.

Parameters

$cid: A comment identifier.

See also

comment_menu()

File

modules/comment/comment.pages.inc, line 110
User page callbacks for the Comment module.

Code

function comment_approve($cid) {
  if (!isset($_GET['token']) || !backdrop_valid_token($_GET['token'], "comment/$cid/approve")) {
    return MENU_ACCESS_DENIED;
  }
  if ($comment = comment_load($cid)) {
    $comment->status = COMMENT_PUBLISHED;
    comment_save($comment);

    backdrop_set_message(t('Comment approved.'));
    backdrop_goto('node/' . $comment->nid);
  }
  return MENU_NOT_FOUND;
}