1 (edited by 2008-08-02 13:24:28)

Topic: [HACK] Disable Posting of Comments

Name: Disable Posting of Comments for individual News Articles
Author: Jetski
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: This will add a Tick Box to the Add News & Edit News Options. This way you can choose if people can comment on this article or not.
Requirements: 1.3.6 - 1.4.1
Instructions:

1. First of all lets add the Tick Box to the Add News Options & Also Make it right a variable to the news file  (addnews.mdu)

Find...

<tr id='options' style='display:none;'>
        <td width=\"75\">
Options
        <td width=\"575\" colspan=\"4\">
    


    $article_format_options

And add the following after the above code

<input type=\"checkbox\" name=\"dis_comm\" value=\"yes\" />Disable Comments for this Article?<br/>

Find...

        $full_story  = replace_news("add", $full_story, $n_to_br, $use_html);
        $short_story = replace_news("add", $short_story, $n_to_br, $use_html);
        $title                  = replace_news("add", $title, TRUE, $use_html);

and add the following code, the line after that above code

$dis_comm = trim($dis_comm);

Now find

fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category||\n");

and replace it with

fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category|$dis_comm||\n");

2. Now lets do the same plus a few extra things but for the Edit News (editnews.mdu)

Find...

    if (!$found){ msg("error","Error !!!","The selected news item can [b]not[/b] be found."); }
    $newstime   = date("D, d F Y h:i:s", $item_db[0]);
    $item_db[2] = stripslashes( preg_replace(array("'\|'", "'\"'", "'\''"), array("I", """, "'"), $item_db[2]) );

And add the following after the above..

    if($item_db[7] == "yes"){ $dis_comm_check = "checked"; }
    else{ $dis_comm_check = ""; }


Find...

        <tr id='options' style='display:none;'>
        <td width=\"75\">
    
Options
        <td width=\"565\" colspan=\"4\">
     

$article_format_options

And below the above code add this code

<input type=\"checkbox\" name=\"dis_comm\" value=\"yes\" $dis_comm_check/>Disable Comments for this Article?

Find...

    $full_story =         replace_news("add", rtrim($full_story), $n_to_br, $use_html);
        $title =                 stripslashes( preg_replace(array("'\|'", "'\n'", "''"), array("I", "
", ""), $title) );
    $avatar =                stripslashes( preg_replace(array("'\|'", "'\n'", "''"), array("I", "
", ""), $avatar) );

And add this code the line after the above code...

$dis_comm = trim($dis_comm);

Find...

fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$title|$short_story|$full_story|$editavatar|$category||\n");

and replace the above with...

fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$title|$short_story|$full_story|$editavatar|$category|$dis_comm||\n");

3. Now We have to tell the show_news.php that we dont want the comment form to appear on certian news articles.. (shows.inc.php)

Find... (around lines 360-368)

                        $output = str_replace("{news-id}", $news_arr[0], $output);
                        $output = str_replace("{archive-id}", $archive, $output);
                        $output = str_replace("{php-self}", $PHP_SELF, $output);
                        $output = str_replace("{cute-http-path}", $config_http_script_dir, $output);


                        $output = replace_news("show", $output);

                        echo $output;

and after the above code add the following..

if($news_arr[7] == "yes"){ $dis_comm = true;}

Find...(around lines 540-546)

    if        (!$no_prev or !$no_next){
            echo $prev_next_msg;
    }



        $template_form = str_replace("{config_http_script_dir}", "$config_http_script_dir", $template_form);

and after the above add this

if(!$dis_comm){

Now find...

    echo"<form  $CN_remember_form  method=\"post\" name=\"comment\" id=\"comment\" action=\"\">".$template_form."<div><input type=\"hidden\" name=\"subaction\" value=\"addcomment\" /><input type=\"hidden\" name=\"ucat\" value=\"$ucat\" /><input type=\"hidden\" name=\"show\" value=\"$show\" />$user_post_query</div></form>
                    \n $CN_remember_include";

and add the following on the next line

}

4. Now we just need to fix up a little thing in the mass changing of cateogories function (massactions.mdu)

Find...

fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$old_db_arr[2]|$old_db_arr[3]|$old_db_arr[4]|$old_db_arr[5]|$move_to_category|||\n");

and replace that code with the following..

fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$old_db_arr[2]|$old_db_arr[3]|$old_db_arr[4]|$old_db_arr[5]|$move_to_category|$old_db_arr[7]|||\n");

Now thats it there should be no problems!
This will not remove the comments link when commenting is disabled for an article.

2 (edited by 2009-08-08 20:15:14)

Re: [HACK] Disable Posting of Comments

Author: eyece & Ifa
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Disable the comments link when listing the news and commenting isn't allowed.
Requirements: this hack
Instructions:
in shows.inc.php find 2 times

if($config_comments_popup == "yes"){
                        $output = str_replace("[com-link]","[url=]", $output);
                }else{
                        $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query\">", $output);
                }
                $output = str_replace("[/com-link]","[/url]", $output);


replace with both with

if($news_arr[7] == "yes"){
$output = str_replace("[com-link]","-Comments Disabled-<!--", $output);
$output = str_replace("[/com-link]","-->", $output);
}
else{
                    if($config_comments_popup == "yes"){
                                $output = str_replace("[com-link]","[url=]", $output);
                        }else{
                                $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from& amp;ucat=$news_arr[6]&$user_query\">", $output);
                        }
                        $output = str_replace("[/com-link]","[/url]", $output);
}


find 2 times

$output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);

replace both with

$output = str_replace("{comments-num}", (($news_arr[7] == "yes")?'':countComments($news_arr[0], $archive)), $output);

3 (edited by 2009-01-17 16:37:04)

Re: [HACK] Disable Posting of Comments

Name: Disable Posting of Comments for individual News Articles
Author: Jetski
Updated by: FUNimations
CuteNews Compatibility: 1.4.5 - * (no incompatibility reported yet)
Description: Same hack but compatible for newer CuteNews versions. As this hack destroys your ability to save categories.
Requirements: this hack
Instructions:

install the original hack and then in addnews.mdu and editnews.mdu find

fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category|$dis_comm||\n");

and

fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$title|$short_story|$full_story|$editavatar|$category|$dis_comm||\n");

and replace $category with $nice_category