mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
Bugtracker #4651 - news comment counting
This commit is contained in:
@@ -11,37 +11,54 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $
|
||||||
| $Revision: 1.1.1.1 $
|
| $Revision: 1.2 $
|
||||||
| $Date: 2006-12-02 04:33:12 $
|
| $Date: 2009-05-08 21:50:19 $
|
||||||
| $Author: mcfly_e107 $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
require_once("../class2.php");
|
require_once("../class2.php");
|
||||||
if (!getperms("B")) {
|
if (!getperms("B"))
|
||||||
|
{
|
||||||
header("location:".e_BASE."index.php");
|
header("location:".e_BASE."index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e_QUERY) {
|
if (e_QUERY)
|
||||||
|
{
|
||||||
$temp = explode("-", e_QUERY);
|
$temp = explode("-", e_QUERY);
|
||||||
$action = $temp[0];
|
$action = $temp[0];
|
||||||
$id = intval($temp[1]);
|
$id = intval($temp[1]);
|
||||||
$item = $temp[2];
|
$item = $temp[2];
|
||||||
$c_item = $temp[3];
|
$c_item = $temp[3];
|
||||||
if ($action == "block") {
|
if ($sql->select('comments','*', 'comment_id='.$id))
|
||||||
$sql->db_Update("comments", "comment_blocked='1' WHERE comment_id='$id' ");
|
{
|
||||||
|
$comment = $sql->db_Fetch();
|
||||||
|
if ($action == "block")
|
||||||
|
{
|
||||||
|
$sql->db_Update("comments", "comment_blocked='1' WHERE comment_id=".$id);
|
||||||
}
|
}
|
||||||
if ($action == "unblock") {
|
if ($action == "unblock")
|
||||||
$sql->db_Update("comments", "comment_blocked='0' WHERE comment_id='$id' ");
|
{
|
||||||
|
$sql->db_Update("comments", "comment_blocked='0' WHERE comment_id=".$id);
|
||||||
}
|
}
|
||||||
if ($action == "delete") {
|
if ($action == "delete")
|
||||||
$sql->db_Delete("comments", "comment_id='$id' ");
|
{
|
||||||
|
$sql->db_Delete("comments", "comment_id=".$id);
|
||||||
|
switch ($comment['comment_type'])
|
||||||
|
{
|
||||||
|
case '0' :
|
||||||
|
case 'news' : // Need to update count in news record as well
|
||||||
|
$sql2->db_Update('news', 'news_comment_total = CAST(GREATEST(CAST(news_comment_total AS SIGNED) - 1, 0) AS UNSIGNED) WHERE news_id='.$comment['comment_item_id']);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!$e107cache->clear($item)) {
|
}
|
||||||
|
if (!$e107cache->clear($item))
|
||||||
|
{
|
||||||
$tmp = explode("?", $item);
|
$tmp = explode("?", $item);
|
||||||
$item = $tmp[0]."?news.".$c_item;
|
$item = $tmp[0]."?news.".$c_item;
|
||||||
$e107cache->clear($item);
|
$e107cache->clear($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
echo "<script type='text/javascript'>window.history.go(-1);</script>\n";
|
echo "<script type='text/javascript'>window.history.go(-1);</script>\n";
|
||||||
?>
|
?>
|
@@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_admin/modcomment.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_admin/modcomment.php,v $
|
||||||
| $Revision: 1.6 $
|
| $Revision: 1.7 $
|
||||||
| $Date: 2009-04-16 20:50:38 $
|
| $Date: 2009-05-08 21:50:19 $
|
||||||
| $Author: e107steved $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -50,19 +50,14 @@ if (isset($_POST['moderate']))
|
|||||||
{
|
{
|
||||||
$sql->db_Update('comments', "comment_lock='0' WHERE `comment_item_id`=".$id." AND `comment_type`='".$tp -> toDB($type, true)."' ");
|
$sql->db_Update('comments', "comment_lock='0' WHERE `comment_item_id`=".$id." AND `comment_type`='".$tp -> toDB($type, true)."' ");
|
||||||
}
|
}
|
||||||
|
if (is_array($_POST['comment_blocked'])) {
|
||||||
if (is_array($_POST['comment_blocked']))
|
while (list ($key, $cid) = each ($_POST['comment_blocked'])) {
|
||||||
{
|
$sql->db_Update("comments", "comment_blocked='1' WHERE comment_id='$cid' ");
|
||||||
while (list ($key, $cid) = each ($_POST['comment_blocked']))
|
|
||||||
{
|
|
||||||
$sql->db_Update('comments', "comment_blocked='1' WHERE `comment_id`=".$cid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($_POST['comment_unblocked']))
|
if (is_array($_POST['comment_unblocked'])) {
|
||||||
{
|
while (list ($key, $cid) = each ($_POST['comment_unblocked'])) {
|
||||||
while (list ($key, $cid) = each ($_POST['comment_unblocked']))
|
$sql->db_Update("comments", "comment_blocked='0' WHERE comment_id='$cid' ");
|
||||||
{
|
|
||||||
$sql->db_Update('comments', "comment_blocked='0' WHERE `comment_id`=".$cid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($_POST['comment_delete']))
|
if (is_array($_POST['comment_delete']))
|
||||||
@@ -172,24 +167,32 @@ $ns->tablerender(MDCLAN_8, $text);
|
|||||||
|
|
||||||
require_once("footer.php");
|
require_once("footer.php");
|
||||||
|
|
||||||
function delete_children($row, $cid) {
|
|
||||||
|
|
||||||
|
function delete_children($row, $cid)
|
||||||
|
{
|
||||||
global $sql, $sql2, $table;
|
global $sql, $sql2, $table;
|
||||||
|
|
||||||
$tmp = explode(".", $row['comment_author']);
|
$tmp = explode(".", $row['comment_author']);
|
||||||
$u_id = $tmp[0];
|
$u_id = intval($tmp[0]);
|
||||||
if ($u_id >= 1) {
|
if ($u_id >= 1)
|
||||||
$sql->db_Update("user", "user_comments=user_comments-1 WHERE user_id='$u_id'");
|
{
|
||||||
|
$sql->db_Update("user", "user_comments=user_comments-1 WHERE user_id=".$u_id);
|
||||||
}
|
}
|
||||||
if($table == "news"){
|
if (($table == "news") || ($table == '0'))
|
||||||
|
{
|
||||||
$sql->db_Update("news", "news_comment_total=news_comment_total-1 WHERE news_id='".$row['comment_item_id']."'");
|
$sql->db_Update("news", "news_comment_total=news_comment_total-1 WHERE news_id='".$row['comment_item_id']."'");
|
||||||
}
|
}
|
||||||
if ($sql2->db_Select("comments", "*", "comment_pid='".$row['comment_id']."'")) {
|
if ($sql2->db_Select("comments", "*", "comment_pid='".$row['comment_id']."'"))
|
||||||
while ($row2 = $sql2->db_Fetch()) {
|
{
|
||||||
|
while ($row2 = $sql2->db_Fetch())
|
||||||
|
{
|
||||||
delete_children($row2, $row2['comment_id']);
|
delete_children($row2, $row2['comment_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$c_del[] = $cid;
|
$c_del[] = $cid;
|
||||||
while (list ($key, $cid) = each ($c_del)) {
|
while (list ($key, $cid) = each ($c_del))
|
||||||
|
{
|
||||||
$sql->db_Delete("comments", "comment_id='$cid'");
|
$sql->db_Delete("comments", "comment_id='$cid'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* News Administration
|
* News Administration
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
||||||
* $Revision: 1.36 $
|
* $Revision: 1.37 $
|
||||||
* $Date: 2009-05-06 20:40:16 $
|
* $Date: 2009-05-08 21:50:19 $
|
||||||
* $Author: bugrain $
|
* $Author: e107steved $
|
||||||
*/
|
*/
|
||||||
require_once("../class2.php");
|
require_once("../class2.php");
|
||||||
|
|
||||||
@@ -106,10 +106,10 @@ function headerjs()
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
$e_sub_cat = 'news';
|
$e_sub_cat = 'news';
|
||||||
$e_wysiwyg = "data,news_extended";
|
$e_wysiwyg = 'data,news_extended';
|
||||||
|
|
||||||
require_once("auth.php");
|
require_once('auth.php');
|
||||||
require_once (e_HANDLER."message_handler.php");
|
require_once (e_HANDLER.'message_handler.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Observe for delete action
|
* Observe for delete action
|
||||||
@@ -247,6 +247,10 @@ class admin_newspost
|
|||||||
{
|
{
|
||||||
$this->_observe_upload();
|
$this->_observe_upload();
|
||||||
}
|
}
|
||||||
|
elseif(isset($_POST['news_comments_recalc']))
|
||||||
|
{
|
||||||
|
$this->_observe_newsCommentsRecalc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_page()
|
function show_page()
|
||||||
@@ -276,6 +280,10 @@ class admin_newspost
|
|||||||
$this->show_news_prefs();
|
$this->show_news_prefs();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'maint' :
|
||||||
|
$this->showMaintenance();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->show_existing_items();
|
$this->show_existing_items();
|
||||||
break;
|
break;
|
||||||
@@ -1422,6 +1430,7 @@ class admin_newspost
|
|||||||
echo $frm->selectbox('newsposts_archive', $this->_optrange(intval($this->getSubAction()) - 1), intval($pref['newsposts_archive']), 'class=tbox&tabindex='.intval($this->getId()));
|
echo $frm->selectbox('newsposts_archive', $this->_optrange(intval($this->getSubAction()) - 1), intval($pref['newsposts_archive']), 'class=tbox&tabindex='.intval($this->getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function show_news_prefs()
|
function show_news_prefs()
|
||||||
{
|
{
|
||||||
global $pref;
|
global $pref;
|
||||||
@@ -1551,6 +1560,7 @@ class admin_newspost
|
|||||||
$e107->ns->tablerender(NWSLAN_90, $emessage->render().$text);
|
$e107->ns->tablerender(NWSLAN_90, $emessage->render().$text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function show_submitted_news()
|
function show_submitted_news()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1624,6 +1634,54 @@ class admin_newspost
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function showMaintenance()
|
||||||
|
{
|
||||||
|
require_once(e_HANDLER."form_handler.php");
|
||||||
|
$frm = new e_form(true); //enable inner tabindex counter
|
||||||
|
|
||||||
|
$e107 = &e107::getInstance();
|
||||||
|
|
||||||
|
$text = "
|
||||||
|
<form method='post' action='".e_SELF."?maint' id='core-newspost-maintenance-form'>
|
||||||
|
<div style='text-align:center'>
|
||||||
|
<table class='fborder' style='".ADMIN_WIDTH."'>
|
||||||
|
|
||||||
|
<tr><td class='forumheader3'>".LAN_NEWS_56."</td><td style='text-align:center' class='forumheader3'>";
|
||||||
|
$text .= "<input class='button' type='submit' name='news_comments_recalc' value='".LAN_NEWS_57."' /></td></tr>";
|
||||||
|
|
||||||
|
$text .= "</table></div>
|
||||||
|
</form>";
|
||||||
|
|
||||||
|
$emessage = &eMessage::getInstance();
|
||||||
|
$e107->ns->tablerender(LAN_NEWS_59, $emessage->render().$text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _observe_newsCommentsRecalc()
|
||||||
|
{
|
||||||
|
global $sql2;
|
||||||
|
|
||||||
|
$e107 = &e107::getInstance();
|
||||||
|
$qry = "SELECT
|
||||||
|
COUNT(`comment_id`) AS c_count,
|
||||||
|
`comment_item_id`
|
||||||
|
FROM `#comments`
|
||||||
|
WHERE (`comment_type`='0') OR (`comment_type`='news')
|
||||||
|
GROUP BY `comment_item_id`";
|
||||||
|
|
||||||
|
if ($e107->sql->db_Select_gen($qry))
|
||||||
|
{
|
||||||
|
while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||||
|
{
|
||||||
|
$sql2->db_Update('news', 'news_comment_total = '.$row['c_count'].' WHERE news_id='.$row['comment_item_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->show_message(LAN_NEWS_58, E_MESSAGE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function show_message($message, $type = E_MESSAGE_INFO, $session = false)
|
function show_message($message, $type = E_MESSAGE_INFO, $session = false)
|
||||||
{
|
{
|
||||||
// ##### Display comfort ---------
|
// ##### Display comfort ---------
|
||||||
@@ -1656,6 +1714,13 @@ class admin_newspost
|
|||||||
$var['sn']['perm'] = "N";
|
$var['sn']['perm'] = "N";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getperms('0'))
|
||||||
|
{
|
||||||
|
$var['maint']['text'] = LAN_NEWS_55;
|
||||||
|
$var['maint']['link'] = e_SELF."?maint";
|
||||||
|
$var['maint']['perm'] = "N";
|
||||||
|
}
|
||||||
|
|
||||||
e_admin_menu(NWSLAN_48, $this->getAction(), $var);
|
e_admin_menu(NWSLAN_48, $this->getAction(), $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,9 +4,9 @@
|
|||||||
| e107 website system - Language File.
|
| e107 website system - Language File.
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_newspost.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_newspost.php,v $
|
||||||
| $Revision: 1.9 $
|
| $Revision: 1.10 $
|
||||||
| $Date: 2009-01-18 19:02:07 $
|
| $Date: 2009-05-08 21:50:19 $
|
||||||
| $Author: secretr $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
define("NWSLAN_1", "News story deleted.");
|
define("NWSLAN_1", "News story deleted.");
|
||||||
@@ -185,4 +185,11 @@ define("LAN_NEWS_53", "Advanced Options");
|
|||||||
define("LAN_NEWS_54", "stay in edit mode");
|
define("LAN_NEWS_54", "stay in edit mode");
|
||||||
|
|
||||||
|
|
||||||
|
define('LAN_NEWS_55', 'Maintenance'); // Was LAN_NEWS_50 in 0.7
|
||||||
|
define('LAN_NEWS_56', 'Recalculate comment counts');
|
||||||
|
define('LAN_NEWS_57', 'Proceed');
|
||||||
|
define('LAN_NEWS_58', 'Update complete');
|
||||||
|
define('LAN_NEWS_59', 'News Maintenance');
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user