示例#1
0
        $parent_cat_name = stripslashes($parent_cat_obj->name);
        $parent_cat_description = stripslashes($parent_cat_obj->description);
    } catch (PAException $e) {
        $msg = "Error occured in retreiving category information\n";
        $msg .= "<br><center><font color=\"red\">" . $e->message . "</font></center>";
        $error_code = $e->code;
        $error = TRUE;
    }
    if ($error) {
        $redirect_msg = "Category does not exist.";
        $back_to_page = $base_url . '/forums.php';
        header("Location: {$base_url}/generic_error.php?msg={$redirect_msg}&back_to_page={$back_to_page}");
        exit;
    }
    $thread_obj = new MessageBoard();
    $thread_obj->set_category_id($parent_id);
    $arr_threads = $thread_obj->get();
}
html_header($HTML_TITLE, '');
?>

<?php 
$content =& new Template(CURRENT_THEME_FSPATH . "/threads.tpl");
if ($error == TRUE) {
    $content->set('msg', $msg);
}
$content->set('uid', $uid);
$content->set('cid', $parent_id);
$header =& new Template(CURRENT_THEME_FSPATH . "/header.tpl");
$header->set('user_name', $first_name . " " . $last_name);
$content->set('header', $header);
}
if (isset($_POST['submit'])) {
    $txt_title = trim($_POST['txt_title']);
    $textarea_contents = trim($_POST['textarea_contents']);
    if ($txt_title == '') {
        $post_error = TRUE;
        $msg .= "<font color=\"red\">Please specify title</font><br>";
    }
    if ($textarea_contents == '') {
        $post_error = TRUE;
        $msg .= "<font color=\"red\">Please enter contents</font><br>";
    }
    if (!$error) {
        $cat_obj = new MessageBoard();
        if ($parent_id) {
            $cat_obj->set_category_id($parent_id);
        } else {
            if ($group_id) {
                $cat_obj->set_collection_id($group_id);
            }
        }
        $cat_obj->title = $txt_title;
        $cat_obj->body = $textarea_contents;
        $cat_obj->user_id = $uid;
        if (!$_POST['chk_allow_anonymous']) {
            $cat_obj->allow_anonymous = 0;
        } else {
            $cat_obj->allow_anonymous = 1;
        }
        try {
            $cat_obj->save();