/**
 *
 *
 * @param unknown $params
 * @param unknown $bBlog  (reference)
 */
function smarty_function_getcomments($params, &$bBlog)
{
    $assign = "comments";
    $postid = $bBlog->show_post;
    $replyto = $_REQUEST['replyto'];
    extract($params);
    // first, assign the hidden fields
    $commentformhiddenfields = '<input type="hidden" name="do" value="submitcomment" />';
    $commentformhiddenfields .= '<input type="hidden" name="comment_postid" value="' . $postid . '" />';
    if (is_numeric($replyto)) {
        $commentformhiddenfields .= '<a name="commentform"></a><input type="hidden" name="replytos" value="' . $replyto . '" />';
    }
    $bBlog->assign("commentformhiddenfields", $commentformhiddenfields);
    $bBlog->assign("commentformaction", $bBlog->_get_entry_permalink($postid));
    // are we posting a comment ?
    if ($_POST['do'] == 'submitcomment' && is_numeric($_POST['comment_postid'])) {
        // we are indeed!
        if (is_numeric($_POST['replytos'])) {
            $rt = $_POST['replytos'];
        } else {
            $rt = false;
        }
        $bBlog->new_comment($_POST['comment_postid'], $rt);
    }
    // get the comments.
    /* start loop and get posts*/
    $rt = false;
    if (is_numeric($_GET['replyto'])) {
        $rt = $_GET['replyto'];
        $cs = $bBlog->get_comment($postid, $rt);
    } else {
        $cs = $bBlog->get_comments($postid, FALSE);
    }
    /* assign loop variable */
    $bBlog->assign($assign, $cs);
}
/**
 *
 *
 * @param unknown $bBlog     (reference)
 * @param unknown $commentid
 * @param unknown $postid
 * @return unknown
 */
function editComment(&$bBlog, $commentid, $postid)
{
    $rval = true;
    if (!(is_numeric($commentid) && is_numeric($postid))) {
        $rval = false;
    }
    $comment = $bBlog->get_comment($postid, $commentid);
    if (!$comment) {
        $rval = false;
    }
    if ($rval === true) {
        $bBlog->assign('showeditform', TRUE);
        $bBlog->assign('comment', $comment[0]);
    }
    return $rval;
}