You are here

function dialog_comment_reply in Dialog 6

Menu page callback for comment/%ctools_js/reply/%node

1 string reference to 'dialog_comment_reply'
dialog_comment_menu in modules/dialog_comment/dialog_comment.module
Implementation of hook_menu().

File

modules/dialog_comment/dialog_comment.module, line 94
Provides Dialog integration for the core comment module. NOTE: In order for the edit, delete and reply links on comments to work, you must patch the Drupal 6 comment module with the patch from http://drupal.org/node/374463#comment-2393592.

Code

function dialog_comment_reply($node, $ajax = FALSE, $pid = NULL) {
  if (!$ajax) {
    module_load_include('inc', 'comment', 'comment.pages');
    return comment_reply($node);
  }

  // TODO: comment_reply does a whole bunch of access checking and other
  // stuff. Not sure how much we should do here, beyond the user_access below
  if (!user_access('post comments')) {

    // TODO: maybe we should have a dialog_access_denied().
    $commands = array();
    $commands[] = dialog_command_display(t('Access denied'), t('You are not authorized to access this page.'));
    ctools_ajax_render($commands);

    // implicit exit();
  }
  ctools_include('ajax');
  $form_state = array(
    'ajax' => TRUE,
    'title' => t('Reply to %title', array(
      '%title' => $node->title,
    )),
    'args' => array(
      array(
        'pid' => $pid,
        'nid' => $node->nid,
      ),
    ),
  );
  $output = dialog_form_wrapper('comment_form', $form_state);
  if (empty($output)) {
    $output[] = dialog_command_display(t('Comment submitted'), t('Reloading...'));
    $output[] = ctools_ajax_command_reload();
  }
  ctools_ajax_render($output);
}