<?php
// $Id$

/**
 * 删除评论
 * @param (object) $comment
 *  评论对象
 */
function comment_page_delete($comment) {
  if (db_exec('DELETE FROM {comment} WHERE cid = ?', array($comment->cid))) {
    module_invoke_all('comment_delete', $comment);
    dd_set_message(t('comment', '删除成功'));
    if ($_GET['redirect']) {
      dd_goto($_GET['redirect']);
    } else if ($comment->redirect) {
      dd_goto($comment->redirect);
    } else {
      dd_goto(NULL);
    }
  }
}

/**
 * 编辑评论
 * @param (object) $comment
 *  评论对象
 */
function comment_page_edit($comment) {
  $info = comment_get_comment_info($comment->ext_type);
  dd_set_title(array(t('comment', '编辑!name', array('!name' => $info['name']))));
  
  return dd_get_form('comment_form', $comment);
}

/**
 * 根据评论 id 跳转到所属节点
 * @param (object) $comment
 *  评论对象
 */
function comment_page_goto($comment) {
  if ($url = module_invoke_first('comment_goto', $comment)) {
    dd_goto($url);
  } else {
    dd_goto(NULL);
  }
}