function dialog_comment_edit in Dialog 6
Menu page callback for comment/%ctools_js/edit/%
1 string reference to 'dialog_comment_edit'
- dialog_comment_menu in modules/
dialog_comment/ dialog_comment.module - Implementation of hook_menu().
File
- modules/
dialog_comment/ dialog_comment.module, line 127 - 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_edit($cid, $ajax = FALSE) {
if (!$ajax) {
module_load_include('inc', 'comment', 'comment.pages');
return comment_edit($cid);
}
$comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
ctools_include('ajax');
if (!comment_access('edit', $comment)) {
$commands = array();
$commands[] = dialog_command_display(t('Access denied'), t('You are not authorized to access this page.'));
ctools_ajax_render($commands);
// implicit exit();
}
$form_state = array(
'ajax' => TRUE,
'title' => t('Edit comment'),
'args' => array(
(array) $comment,
),
);
$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);
}