First, you have to "alter" your database to add a new field to the b2posts table. Login to your CPanel and then
phpMyAdmin; click on "b2posts" table and then go into the SQL section. In this section, run the following:
ALTER TABLE b2posts ADD post_closecomment INT(1) DEFAULT 0 NOT NULL;
---
In b2functions.php file, locate get_postdata and get_postdata2 fuunctions. Then add in the following lines in each
function respectively:
'CloseComment' => $mysql->post_closecomment
and
'CloseComment' => $row->post_closecomment
---
In b2edit.form.php file, locate:
Add the following next to it:
tabindex="8" id="closecomment" />
If this does not work for some reason, use the following instead:
post_closecomment;
if ($rc == 1) { echo " checked"; }
}
?>
tabindex="9" id="closecomment" />
Which ever you use, you might want to change the tabindex value.
---
In b2template.functions.php file, replace the comments_link function with the following:
function comments_link($file='') {
global $id, $pagenow, $postdata;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
if ($postdata["CloseComment"] == 0) {
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1#comments';
}
else {
echo 'comments closed';
}
}
If you use the popup comment, replace the comments_popup_link function with the following:
function comments_popup_link($zero='no comment', $one='1 comment', $more='% comments', $CSSclass='') {
global $id, $b2commentspopupfile, $b2commentsjavascript, $postdata;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($postdata["CloseComment"] == 0) {
echo '';
comments_number($zero, $one, $more);
echo '';
}
else {
echo 'comments closed';
}
}
And if you use trackback, do the same:
function trackback_link($file='') {
global $id, $pagenow, $postdata;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
if ($postdata["CloseComment"] == 0) {
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'tb'.$querystring_equal.'1';
}
else {
echo 'trackbacks closed';
}
}
function trackback_popup_link($zero='no trackback', $one='1 trackback', $more='% trackbacks', $CSSclass='') {
global $id, $b2trackbackpopupfile, $b2commentsjavascript, $postdata;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($postdata["CloseComment"] == 0) {
echo '';
trackback_number($zero, $one, $more);
echo '';
}
else {
echo 'trackbacks closed';
}
}
---
In b2edit.php file, add in the following line under both "post" and "editpost" sections:
$post_closecomment = intval($HTTP_POST_VARS["post_closecomment"]);
Then edit the INSERT statement under "post" as:
$query = "INSERT INTO $tableposts (ID, post_author, post_date, post_content, post_title, post_category, post_closecomment) VALUES ('0','$user_ID','$now','$content','".$post_title."','".$post_category."','".$post_closecomment."')";
Also edit the UPDATE statement under "editpost" as:
$query = "UPDATE $tableposts post_closecomment=\"$post_closecomment\", post_mood=\"$post_mood\", post_content=\"$content\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
These lines may look different depending which hack(s) you have installed.
---
If you use inline comments, you don't have to edit the b2comments.php file since it can be loaded by itself, but you do
need to restrict the inclusion of comments within your index... like:
However, if you use the popup comments, open up b2commentspopup.php file and locate: