comment_admin_edit

Versions
4.6
comment_admin_edit($cid)

Menu callback; edit a comment from the administrative interface.

Code

modules/comment.module, line 921

<?php
function comment_admin_edit($cid) {
  // Comment edits need to be saved.
  if ($_POST['op'] == t('Submit')) {
    $edit = $_POST['edit'];
    comment_save($edit['cid'], $edit);
    drupal_goto('admin/comment');
  }

  // If we're not saving our changes above, we're editing it.
  $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid);
  $comment = db_fetch_object($result);
  $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
  $comment = drupal_unpack($comment);

  if ($comment) {
    if (!$comment->uid && (variable_get('comment_anonymous', 0) > 0)) {
      // If comment from non-registered user, allow admin to modify anonymous fields.
      $form .= form_textfield(t('Name'), 'name', $comment->name ? $comment->name : variable_get('anonymous', 'Anonymous') , 20, 60);
      $form .= form_textfield(t('E-mail'), 'mail', $comment->mail, 20, 64);
      $form .= form_textfield(t('Homepage'), 'homepage', $comment->homepage, 20, 255);
    }
    else {
      // Otherwise, just display the author's name.
      $form .= form_item(t('Author'), format_name($comment));
    }
    $form .= form_textfield(t('Subject'), 'subject', $comment->subject, 70, 128);
    $form .= form_textarea(t('Comment'), 'comment', $comment->comment, 70, 15, '');
    $form .= filter_form('format', $comment->format);
    $form .= form_radios(t('Status'), 'status', $comment->status, array(t('Published'), t('Not published')));
    $form .= form_hidden('nid', $comment->nid);
    $form .= form_hidden('cid', $comment->cid);
    $form .= form_submit(t('Submit'));
    print theme('page', form($form));
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.