=== modified file 'modules/comment.module' --- modules/comment.module +++ modules/comment.module @@ -120,20 +120,29 @@ $items[] = array('path' => 'admin/comment/configure/settings', 'title' => t('settings'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); - - $items[] = array('path' => 'comment/delete', 'title' => t('delete comment'), - 'callback' => 'comment_delete', 'access' => $access, 'type' => MENU_CALLBACK); - - $access = user_access('post comments'); - $items[] = array('path' => 'comment/edit', 'title' => t('edit comment'), - 'callback' => 'comment_edit', 'access' => $access, 'type' => MENU_CALLBACK); } else { - if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) { - $node = node_load(arg(2)); - if ($node->nid) { - $items[] = array('path' => 'comment/reply', 'title' => t('reply to comment'), - 'callback' => 'comment_reply', 'access' => node_access('view', $node), 'type' => MENU_CALLBACK); + if (arg(0) == 'comment' && is_numeric(arg(2))) { + if (arg(1) == 'delete') { + $comment_exists = db_result(db_query("SELECT 1 FROM {comments} WHERE cid = %d", arg(2))); + if ($comment_exists) { + $items[] = array('path' => 'comment/delete', 'title' => t('delete comment'), + 'callback' => 'comment_delete', 'access' => user_access('administer comments'), 'type' => MENU_CALLBACK); + } + } + else if (arg(1) == 'edit') { + $comment_exists = db_result(db_query("SELECT 1 FROM {comments} WHERE cid = %d", arg(2))); + if ($comment_exists) { + $items[] = array('path' => 'comment/edit', 'title' => t('edit comment'), + 'callback' => 'comment_edit', 'access' => user_access('post comments'), 'type' => MENU_CALLBACK); + } + } + else if (arg(1) == 'reply') { + $node = node_load(arg(2)); + if ($node->nid) { + $items[] = array('path' => 'comment/reply', 'title' => t('reply to comment'), + 'callback' => 'comment_reply', 'access' => node_access('view', $node), 'type' => MENU_CALLBACK); + } } } if ((arg(0) == 'node') && is_numeric(arg(1)) && is_numeric(arg(2))) {