1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

Bugtracker #4364 - support comment edit for downloads, content. Also bugtracker #4381 don't display blocked comments

This commit is contained in:
e107steved 2008-05-25 08:26:11 +00:00
parent 62401cd74d
commit 33f96bb871
6 changed files with 377 additions and 334 deletions

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/comment.php,v $ | $Source: /cvs_backup/e107_0.8/comment.php,v $
| $Revision: 1.4 $ | $Revision: 1.5 $
| $Date: 2007-12-08 14:49:44 $ | $Date: 2008-05-25 08:26:11 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -36,40 +36,38 @@ $id = intval(varset($temp_query[2], "")); // ID of item associated with comment
$nid = intval(varset($temp_query[3], "")); // Action - e.g. 'edit'. Or news ID for reply with nested comments $nid = intval(varset($temp_query[3], "")); // Action - e.g. 'edit'. Or news ID for reply with nested comments
$xid = intval(varset($temp_query[4], "")); // ID of target comment $xid = intval(varset($temp_query[4], "")); // ID of target comment
global $comment_edit_query; global $comment_edit_query;
//$comment_edit_query = '';
//if ($temp_query[3] == 'edit') $comment_edit_query = $temp_query[0].".".$temp_query[1].".".$temp_query[2];
$comment_edit_query = $temp_query[0].".".$temp_query[1].".".$temp_query[2]; $comment_edit_query = $temp_query[0].".".$temp_query[1].".".$temp_query[2];
unset($temp_query); unset($temp_query);
$redirectFlag = 0;
if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit'])) if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit']))
{ { // New comment, or edited comment, being posted.
if(!ANON && !USER) if(!ANON && !USER)
{ {
header("location: ".e_BASE."index.php"); header("location: ".e_BASE."index.php");
exit; exit;
} }
if($table == "poll") if($table == "poll")
{ {
if (!$sql->db_Select("polls", "poll_title", "`poll_id` = '{$id}' AND `poll_comment` = 1")) if (!$sql->db_Select("polls", "poll_title", "`poll_id` = '{$id}' AND `poll_comment` = 1"))
{ {
header("location: ".e_BASE."index.php"); header("location: ".e_BASE."index.php");
exit; exit;
} }
} else if($table == "news") }
elseif($table == "news")
{ {
if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = '{$id}' AND `news_allow_comments` = 0")) if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = '{$id}' AND `news_allow_comments` = 0"))
{ {
header("location: ".e_BASE."index.php"); header("location: ".e_BASE."index.php");
exit; exit;
} }
} }
// $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0); $pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies)
// $pid = intval($pid);
$pid = intval(varset($_POST['pid'], 0));
$editpid = intval(varset($_POST['editpid'], 0)); // ID of the specific comment being edited $editpid = intval(varset($_POST['editpid'], 0)); // ID of the specific comment being edited (in-line comments)
$clean_authorname = $_POST['author_name']; $clean_authorname = $_POST['author_name'];
$clean_comment = $_POST['comment']; $clean_comment = $_POST['comment'];
@ -87,74 +85,78 @@ if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit']))
if($editpid) if($editpid)
{ {
$redir = preg_replace("#\.edit.*#si", "", e_QUERY); $redirectFlag = $id;
/* $redir = preg_replace("#\.edit.*#si", "", e_QUERY);
header("Location: ".e_SELF."?{$redir}"); header("Location: ".e_SELF."?{$redir}");
exit; exit; */
} }
} }
if (isset($_POST['replysubmit'])) if (isset($_POST['replysubmit']))
{ { // Reply to nested comment being posted
if ($table == "news" && !$sql->db_Select("news", "news_allow_comments", "news_id='{$nid}' ")) if ($table == "news" && !$sql->db_Select("news", "news_allow_comments", "news_id='{$nid}' "))
{ {
header("location:".e_BASE."index.php"); header("location:".e_BASE."index.php");
exit; exit;
} }
else else
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
if (!$row['news_id']) { if (!$row['news_id'])
$pid = (isset($_POST['pid']) ? $_POST['pid'] : 0); {
$pid = intval($pid); $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0);
$pid = intval($pid);
$clean_authorname = $_POST['author_name']; $clean_authorname = $_POST['author_name'];
$clean_comment = $_POST['comment']; $clean_comment = $_POST['comment'];
$clean_subject = $_POST['subject']; $clean_subject = $_POST['subject'];
$cobj->enter_comment($clean_authorname, $clean_comment, $table, $nid, $pid, $clean_subject); $cobj->enter_comment($clean_authorname, $clean_comment, $table, $nid, $pid, $clean_subject);
$e107cache->clear("comment.php?{$table}.{$id}"); $e107cache->clear("comment.php?{$table}.{$id}");
} }
//plugin e_comment.php files $redirectFlag = $nid;
$plugin_redir = false;
$e_comment = $cobj->get_e_comment();
if ($table == $e_comment[$table]['eplug_comment_ids']){
$plugin_redir = TRUE;
$reply_location = str_replace("{NID}", $nid, $e_comment[$table]['reply_location']);
}
if ($plugin_redir)
{
echo "<script type='text/javascript'>document.location.href='{$reply_location}'</script>\n";
exit;
} elseif ($table == "news" || $table == "poll")
{
echo "<script type='text/javascript'>document.location.href='".e_BASE."comment.php?comment.{$table}.{$nid}'</script>\n";
exit;
} elseif($table == "bugtrack")
{
echo "<script type='text/javascript'>document.location.href='".e_PLUGIN."bugtracker/bugtracker.php?show.{$nid}'</script>\n";
exit;
} elseif($table == "faq")
{
echo "<script type='text/javascript'>document.location.href='".e_PLUGIN."faq/faq.php?cat.{$xid}.{$nid}'</script>\n";
exit;
} elseif ($table == "content")
{
echo "<script type='text/javascript'>document.location.href='".e_BASE."content.php?{$_POST['content_type']}.{$nid}'</script>\n";
exit;
} elseif ($table == "download")
{
echo "<script type='text/javascript'>document.location.href='".e_BASE."download.php?view.{$nid}'</script>\n";
exit;
} elseif ($table == "page")
{
echo "<script type='text/javascript'>document.location.href='".e_BASE."page.php?{$nid}'</script>\n";
exit;
}
} }
} }
if ($redirectFlag)
{ // Need to go back to original page
// Check plugin e_comment.php files
$plugin_redir = false;
$e_comment = $cobj->get_e_comment();
if ($table == $e_comment[$table]['eplug_comment_ids'])
{
$plugin_redir = TRUE;
$reply_location = str_replace("{NID}", $redirectFlag, $e_comment[$table]['reply_location']);
}
if ($plugin_redir)
{
echo "<script type='text/javascript'>document.location.href='{$reply_location}'</script>\n";
exit;
}
else
{
switch ($table)
{
case "news" :
case "poll" :
echo "<script type='text/javascript'>document.location.href='".e_BASE."comment.php?comment.{$table}.{$redirectFlag}'</script>\n";
exit;
break;
case "download" :
echo "<script type='text/javascript'>document.location.href='".e_BASE."download.php?view.{$redirectFlag}'</script>\n";
exit;
break;
case "page" :
echo "<script type='text/javascript'>document.location.href='".e_BASE."page.php?{$redirectFlag}'</script>\n";
exit;
break;
}
}
}
$comment_ob_start = FALSE; $comment_ob_start = FALSE;
if ($action == "reply") if ($action == "reply")
{ {
@ -174,83 +176,70 @@ if ($action == "reply")
if ($subject == "") if ($subject == "")
{ {
if ($table == "news") switch ($table)
{ {
if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' ")) case "news" :
{ if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' "))
header("location: ".e_BASE."index.php"); {
exit; header("location: ".e_BASE."index.php");
} exit;
else }
{ else
list($news['news_title']) = $sql->db_Fetch(); {
$subject = $news['news_title']; list($news['news_title']) = $sql->db_Fetch();
$title = COMLAN_100; $subject = $news['news_title'];
} $title = COMLAN_100;
} }
elseif ($table == "poll") case "poll" :
{ if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' "))
if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' ")) { {
header("location:".e_BASE."index.php"); header("location:".e_BASE."index.php");
exit; exit;
} else { }
list($poll['poll_title']) = $sql->db_Fetch(); else
$subject = $poll['poll_title']; {
$title = COMLAN_101; list($poll['poll_title']) = $sql->db_Fetch();
} $subject = $poll['poll_title'];
} $title = COMLAN_101;
elseif ($table == "content") }
{ break;
$sql->db_Select("content", "content_heading", "content_id='{$nid}'"); case 'download' :
$subject = $content['content_heading']; if ($sql->db_Select('download','download_name',"download_id={$nid} "))
} {
elseif ($table == "bugtracker") $row = $sql->db_Fetch();
{ $subject = $row['download_name'];
$sql->db_Select("bugtrack", "bugtrack_summary", "bugtrack_id='{$nid}'"); $title = COMLAN_106;
$subject = $content['content_heading']; }
else
{
header("location:".e_BASE."index.php");
exit;
}
break;
} }
} }
if ($table == "content")
{
$sql->db_Select("content", "content_type", "content_id='{$nid}'");
list($content['content_type']) = $sql->db_Fetch();
if ($content['content_type'] == "0") {
$content_type = "article";
$title = COMLAN_103;
} elseif ($content['content_type'] == "3") {
$content_type = "review";
$title = COMLAN_104;
} elseif ($content['content_type'] == "1") {
$content_type = "content";
$title = COMLAN_105;
}
}
define('e_PAGETITLE', $title." / ".COMLAN_99." / ".COMLAN_102.$subject.""); define('e_PAGETITLE', $title." / ".COMLAN_99." / ".COMLAN_102.$subject."");
require_once(HEADERF); require_once(HEADERF);
} }
else else
{ { // Default code if not reply
// Check cache
if ($cache = $e107cache->retrieve("comment.php?{$table}.{$id}")) if ($cache = $e107cache->retrieve("comment.php?{$table}.{$id}"))
{ {
require_once(HEADERF); require_once(HEADERF);
echo $cache; echo $cache;
require_once(FOOTERF); require_once(FOOTERF);
exit; exit;
} }
else else
{ {
if ($table == "news") switch ($table)
{ {
/* case "news" :
changes by jalist 19/01/05: if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'])
updated db query removed one call {
*/ $query = "SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'])
{
$query = "SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id
@ -258,76 +247,116 @@ else
AND n.news_id={$id} AND n.news_id={$id}
AND n.news_allow_comments=0 AND n.news_allow_comments=0
GROUP by n.news_id"; GROUP by n.news_id";
} }
else else
{ {
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' WHERE n.news_class REGEXP '".e_CLASS_REGEXP."'
AND n.news_id={$id} AND n.news_id={$id}
AND n.news_allow_comments=0"; AND n.news_allow_comments=0";
} }
if (!$sql->db_Select_gen($query)) if (!$sql->db_Select_gen($query))
{
header("location:".e_BASE."index.php");
exit;
}
else
{
$news = $sql->db_Fetch();
$subject = $tp->toForm($news['news_title']);
define("e_PAGETITLE", COMLAN_100." / ".COMLAN_99." / {$subject}");
require_once(HEADERF);
ob_start();
$comment_ob_start = TRUE;
$ix = new news;
$ix->render_newsitem($news, "extend"); // extend so that news-title-only news text is displayed in full when viewing comments.
$field = $news['news_id'];
}
break;
case "poll" :
if (!$sql->db_Select("polls", "*", "poll_id='{$id}'"))
{
header("location:".e_BASE."index.php");
exit;
}
else
{
$row = $sql->db_Fetch();
$comments_poll = $row['poll_comment'];
$subject = $row['poll_title'];
define("e_PAGETITLE", COMLAN_101." / ".COMLAN_99." / ".$subject."");
require_once(HEADERF);
require(e_PLUGIN."poll/poll_menu.php");
$field = $row['poll_id'];
if(!$comments_poll)
{ {
header("location:".e_BASE."index.php"); require_once(FOOTERF);
exit; exit;
}
else
{
$news = $sql->db_Fetch();
$subject = $tp->toForm($news['news_title']);
define("e_PAGETITLE", COMLAN_100." / ".COMLAN_99." / {$subject}");
require_once(HEADERF);
ob_start();
$comment_ob_start = TRUE;
$ix = new news;
$ix->render_newsitem($news, "extend"); // extend so that news-title-only news text is displayed in full when viewing comments.
$field = $news['news_id'];
$comtype = 0;
} }
} require_once(HEADERF);
else if($table == "poll") }
{ break;
if (!$sql->db_Select("polls", "*", "poll_id='{$id}'")) case 'download' :
if ($sql->db_Select('download','download_name',"download_id={$id} "))
{
$row = $sql->db_Fetch();
$subject = $row['download_name'];
$title = COMLAN_106;
$field = $id;
require_once(HEADERF);
}
else
{
header("location:".e_BASE."index.php");
exit;
}
break;
default : // Hope its a plugin table
$e_comment = $cobj->get_e_comment();
if ($table == $e_comment[$table]['eplug_comment_ids'])
{
if ($sql->db_Select($table,$e_comment[$table]['db_title'],$e_comment[$table]['db_id']."={$id} "))
{ {
header("location:".e_BASE."index.php"); $row = $sql->db_Fetch();
exit; $subject = $row[$e_comment[$table]['db_title']];
} $title = $e_comment[$table]['plugin_name'];
else $field = $id;
{ require_once(HEADERF);
$row = $sql->db_Fetch();
$comments_poll = $row['poll_comment'];
$subject = $row['poll_title'];
define("e_PAGETITLE", COMLAN_101." / ".COMLAN_99." / ".$subject."");
require_once(HEADERF);
require(e_PLUGIN."poll/poll_menu.php");
$field = $row['poll_id'];
$comtype = 4;
if(!$comments_poll)
{
require_once(FOOTERF);
exit;
}
} }
} else
require_once(HEADERF); {
header("location:".e_BASE."index.php");
exit;
}
}
else
{ // Error - emit some debug code
require_once(HEADERF);
echo "Comment error: {$table} Field: {$e_comment['db_id']} ID {$id} Title: {$e_comment['db_title']}<br />";
echo "<pre>";
var_dump($e_comment);
echo "</pre>";
}
}
} }
} }
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news") if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news")
{ {
echo "<span class='smalltext'><b>".$pref['trackbackString']."</b> ".$e107->http_path.e_PLUGIN."trackback/trackback.php?pid={$id}</span>"; echo "<span class='smalltext'><b>".$pref['trackbackString']."</b> ".$e107->http_path.e_PLUGIN."trackback/trackback.php?pid={$id}</span>";
} }
$field = ($field ? $field : ($id ? $id : ""));
$field = ($field ? $field : ($id ? $id : "")); // ID of associated source item
$width = (isset($width) && $width ? $width : ""); $width = (isset($width) && $width ? $width : "");
$cobj->compose_comment($table, $action, $field, $width, $subject, $rate=FALSE); $cobj->compose_comment($table, $action, $field, $width, $subject, $rate=FALSE);
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news"){ if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news")
{
if($sql->db_Select("trackback", "*", "trackback_pid={$id}")) if($sql->db_Select("trackback", "*", "trackback_pid={$id}"))
{ {
$tbArray = $sql -> db_getList(); $tbArray = $sql -> db_getList();

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/download.php,v $ | $Source: /cvs_backup/e107_0.8/download.php,v $
| $Revision: 1.18 $ | $Revision: 1.19 $
| $Date: 2007-11-21 22:52:45 $ | $Date: 2008-05-25 08:26:11 $
| $Author: e107steved $ | $Author: e107steved $
| |
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
@ -399,6 +399,8 @@ if ($action == "view")
$dl = $sql -> db_Fetch(); $dl = $sql -> db_Fetch();
$comment_edit_query = 'comment.download.'.$id;
$load_template = 'download_template'; $load_template = 'download_template';
if (!isset($DOWNLOAD_VIEW_TABLE)) eval($template_load_core); if (!isset($DOWNLOAD_VIEW_TABLE)) eval($template_load_core);
if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:0px");} if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:0px");}

View File

@ -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_files/shortcode/batch/comment_shortcodes.php,v $ | $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/comment_shortcodes.php,v $
| $Revision: 1.5 $ | $Revision: 1.6 $
| $Date: 2008-05-24 12:45:34 $ | $Date: 2008-05-25 08:26:11 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -110,7 +110,8 @@ if ($pref['allowCommentEdit'] && USER && $comrow['user_id'] == USERID && $comrow
} }
else else
{ {
return "<a href='".e_SELF."?".$comment_edit_query.".edit.".$comrow['comment_id']."'><img src='".e_IMAGE."packs/".$imode."/generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>"; // return "<a href='".e_SELF."?".$comment_edit_query.".edit.".$comrow['comment_id']."'><img src='".e_IMAGE."packs/".$imode."/generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>";
return "<a href='".e_BASE."comment.php?".$comment_edit_query.".edit.".$comrow['comment_id']."'><img src='".e_IMAGE."packs/".$imode."/generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>";
} }
} }
else else

View File

@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/comment_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/comment_class.php,v $
| $Revision: 1.11 $ | $Revision: 1.12 $
| $Date: 2008-05-24 15:14:36 $ | $Date: 2008-05-25 08:26:11 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -32,7 +32,7 @@ require_once(e_FILE."shortcode/batch/comment_shortcodes.php");
class comment { class comment {
/** /**
* Enter description here... * Display the comment editing form
* *
* @param unknown_type $action * @param unknown_type $action
* @param unknown_type $table * @param unknown_type $table
@ -47,123 +47,126 @@ class comment {
{ {
//rating : boolean, to show rating system in comment //rating : boolean, to show rating system in comment
global $pref, $sql, $tp; global $pref, $sql, $tp;
if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE){ if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
return; {
return;
} }
require_once(e_HANDLER."ren_help.php"); require_once(e_HANDLER."ren_help.php");
if (ANON == TRUE || USER == TRUE) if (ANON == TRUE || USER == TRUE)
{ {
$itemid = $id; $itemid = $id;
$ns = new e107table; $ns = new e107table;
if ($action == "reply" && substr($subject, 0, 4) != "Re: ") if ($action == "reply" && substr($subject, 0, 4) != "Re: ")
{
$subject = COMLAN_325.' '.$subject;
}
$text = "\n<div style='text-align:center'><form method='post' action='".e_SELF."?".e_QUERY."' id='dataform' >\n<table style='width:100%'>";
if ($pref['nested_comments'])
{
$text .= "<tr>\n<td style='width:20%'>".COMLAN_324."</td>\n<td style='width:80%'>\n
<input class='tbox comment subject' type='text' name='subject' size='61' value='".$tp -> toForm($subject)."' maxlength='100' />\n</td>\n</tr>";
$text2 = "";
}
else
{
$text2 = "<input type='hidden' name='subject' value='".$tp -> toForm($subject)."' />\n";
}
if (isset($_GET['comment']) && $_GET['comment'] == 'edit')
{
$eaction = 'edit';
$id = $_GET['comment_id'];
}
elseif (strstr(e_QUERY, "edit"))
{
$eaction = "edit";
$tmp = explode(".", e_QUERY);
$count = 0;
foreach($tmp as $t)
{ {
$subject = COMLAN_325.' '.$subject; if($t == "edit")
{
$id = $tmp[($count+1)];
break;
}
$count++;
} }
}
$text = "\n<div style='text-align:center'><form method='post' action='".e_SELF."?".e_QUERY."' id='dataform' >\n<table style='width:100%'>"; if(isset($eaction) && $eaction == "edit")
{ // Get existing comment
if ($pref['nested_comments']) $id=intval($id);
{ $sql -> db_Select("comments", "*", "comment_id='{$id}' ");
$text .= "<tr>\n<td style='width:20%'>".COMLAN_324."</td>\n<td style='width:80%'>\n<input class='tbox comment subject' type='text' name='subject' size='61' value='".$tp -> toForm($subject)."' maxlength='100' />\n</td>\n</tr>"; $ecom = $sql -> db_Fetch();
$text2 = ""; if (isset($ecom['comment_author']))
{ // Old comment DB format
list($prid, $pname) = explode(".", $ecom['comment_author'],2);
} }
else else
{ {
$text2 = "<input type='hidden' name='subject' value='".$tp -> toForm($subject)."' />\n"; $prid = $ecom['comment_author_id'];
$pname = $ecom['comment_author_name'];
} }
if (isset($_GET['comment']) && $_GET['comment'] == 'edit') if($prid != USERID || !USER)
{ { // Editing not allowed
$eaction = 'edit'; echo "<div style='text-align: center;'>".COMLAN_329."</div>";
$id = $_GET['comment_id']; require_once(FOOTERF);
} exit;
else if (strstr(e_QUERY, "edit"))
{
$eaction = "edit";
$tmp = explode(".", e_QUERY);
$count = 0;
foreach($tmp as $t)
{
if($t == "edit")
{
$id = $tmp[($count+1)];
break;
}
$count++;
}
} }
if(isset($eaction) && $eaction == "edit") $caption = COMLAN_318;
{ $comval = $tp -> toForm($ecom['comment_comment']);
$id=intval($id); $comval = preg_replace("#\[ ".COMLAN_319.".*\]#si", "", $comval);
$sql -> db_Select("comments", "*", "comment_id='$id' "); }
$ecom = $sql -> db_Fetch(); else
if (isset($ecom['comment_author'])) { // New comment - blank form
{ // Old comment DB format $caption = COMLAN_9;
list($prid, $pname) = explode(".", $ecom['comment_author'],2); $comval = "";
} }
else
{
$prid = $ecom['comment_author_id'];
$pname = $ecom['comment_author_name'];
}
if($prid != USERID || !USER) //add the rating select box/result ?
{ $rate = "";
echo "<div style='text-align: center;'>".COMLAN_329."</div>"; if($rating == TRUE && !(ANON == TRUE && USER == FALSE) )
require_once(FOOTERF); {
exit; global $rater;
} require_once(e_HANDLER."rate_class.php");
if(!is_object($rater)){ $rater = new rater; }
$rate = $rater -> composerating($table, $itemid, $enter=TRUE, USERID, TRUE);
$rate = "<tr><td style='width:20%; vertical-align:top;'>".COMLAN_327.":</td>\n<td style='width:80%;'>".$rate."</td></tr>\n";
} //end rating area
$caption = COMLAN_318; if (ANON == TRUE && USER == FALSE)
$comval = $tp -> toFORM($ecom['comment_comment']); { // Box for author name (anonymous comments - if allowed)
$comval = preg_replace("#\[ ".COMLAN_319.".*\]#si", "", $comval); $text .= "<tr>\n<td style='width:20%; vertical-align:top;'>".COMLAN_16."</td>\n<td style='width:80%'>\n<input class='tbox comment author' type='text' name='author_name' size='61' value='{$author_name}' maxlength='100' />\n</td>\n</tr>";
} }
else $text .= $rate."<tr> \n
{
$caption = COMLAN_9;
$comval = "";
}
//add the rating select box/result ?
$rate = "";
if($rating == TRUE && !(ANON == TRUE && USER == FALSE) )
{
global $rater;
require_once(e_HANDLER."rate_class.php");
if(!is_object($rater)){ $rater = new rater; }
$rate = $rater -> composerating($table, $itemid, $enter=TRUE, USERID, TRUE);
$rate = "<tr><td style='width:20%; vertical-align:top;'>".COMLAN_327.":</td>\n<td style='width:80%;'>".$rate."</td></tr>\n";
}
//end rating area
if (ANON == TRUE && USER == FALSE)
{
$text .= "<tr>\n<td style='width:20%; vertical-align:top;'>".COMLAN_16."</td>\n<td style='width:80%'>\n<input class='tbox comment author' type='text' name='author_name' size='61' value='$author_name' maxlength='100' />\n</td>\n</tr>";
}
$text .= $rate."<tr> \n
<td style='width:20%; vertical-align:top;'>".COMLAN_8.":</td>\n<td id='commentform' style='width:80%;'>\n<textarea class='tbox comment' id='comment' name='comment' cols='62' rows='7' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$comval</textarea>\n<br /> <td style='width:20%; vertical-align:top;'>".COMLAN_8.":</td>\n<td id='commentform' style='width:80%;'>\n<textarea class='tbox comment' id='comment' name='comment' cols='62' rows='7' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$comval</textarea>\n<br />
".display_help('helpb',"comment")."</td></tr>\n<tr style='vertical-align:top'> \n<td style='width:20%'>".$text2."</td>\n<td id='commentformbutton' style='width:80%;'>\n". (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='$id' />" : '').(isset($eaction) && $eaction == "edit" ? "<input type='hidden' name='editpid' value='$id' />" : "").(isset($content_type) && $content_type ? "<input type='hidden' name='content_type' value='$content_type' />" : ''). "<input class='button' type='submit' name='".$action."submit' value='".(isset($eaction) && $eaction == "edit" ? COMLAN_320 : COMLAN_9)."' />\n</td>\n</tr>\n</table>\n</form></div>"; ".display_help('helpb',"comment")."</td></tr>\n<tr style='vertical-align:top'> \n<td style='width:20%'>".$text2."</td>\n
<td id='commentformbutton' style='width:80%;'>\n
". (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='{$id}' />" : '').(isset($eaction) && $eaction == "edit" ? "<input type='hidden' name='editpid' value='{$id}' />" : "").(isset($content_type) && $content_type ? "<input type='hidden' name='content_type' value='{$content_type}' />" : ''). "<input class='button' type='submit' name='".$action."submit' value='".(isset($eaction) && $eaction == "edit" ? COMLAN_320 : COMLAN_9)."' />\n</td>\n</tr>\n</table>\n</form></div>";
if($tablerender) if($tablerender)
{ {
$text = $ns->tablerender($caption, $text, '', TRUE); $text = $ns->tablerender($caption, $text, '', TRUE);
} }
if($return) if($return)
{ {
return $text; return $text;
} }
else else
{ {
echo $text; echo $text;
} }
} }
else else
{ { // Comment entry not allowed - point to signup link
echo "<br /><div style='text-align:center'><b>".COMLAN_6." <a href='".e_SIGNUP."'>".COMLAN_321."</a> ".COMLAN_322."</b></div>"; echo "<br /><div style='text-align:center'><b>".COMLAN_6." <a href='".e_SIGNUP."'>".COMLAN_321."</a> ".COMLAN_322."</b></div>";
} }
} }
@ -502,20 +505,22 @@ class comment {
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $table * @param unknown_type $table - the source table for the associated item
* @param unknown_type $action * @param unknown_type $action - usually 'comment' or 'reply'
* @param unknown_type $id * @param unknown_type $id - ID of item associated with comments (e.g. news ID)
* @param unknown_type $width * @param unknown_type $width - appears to not be used
* @param unknown_type $subject * @param unknown_type $subject
* @param unknown_type $rate * @param unknown_type $rate
*/ */
function compose_comment($table, $action, $id, $width, $subject, $rate=FALSE, $return=FALSE, $tablerender=TRUE){ function compose_comment($table, $action, $id, $width, $subject, $rate=FALSE, $return=FALSE, $tablerender=TRUE)
{
//compose comment : single call function will render the existing comments and show the form_comment //compose comment : single call function will render the existing comments and show the form_comment
//rate : boolean, to show/hide rating system in comment, default FALSE //rate : boolean, to show/hide rating system in comment, default FALSE
global $pref, $sql, $ns, $e107cache, $tp, $totcc; global $pref, $sql, $ns, $e107cache, $tp, $totcc;
if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE){ if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
return; {
return;
} }
$count_comments = $this -> count_comments($table, $id, $pid=FALSE); $count_comments = $this -> count_comments($table, $id, $pid=FALSE);
@ -541,44 +546,44 @@ class comment {
if ($comment_total = $sql->db_Select_gen($query)) if ($comment_total = $sql->db_Select_gen($query))
{ {
$width = 0; $width = 0;
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{
$lock = $row['comment_lock'];
// $subject = $tp->toHTML($subject);
if ($pref['nested_comments'])
{ {
$lock = $row['comment_lock']; $text .= $this->render_comment($row, $table , $action, $id, $width, $tp->toHTML($subject), $rate);
// $subject = $tp->toHTML($subject);
if ($pref['nested_comments'])
{
$text .= $this->render_comment($row, $table , $action, $id, $width, $tp->toHTML($subject), $rate);
}
else
{
$text .= $this->render_comment($row, $table , $action, $id, $width, $tp->toHTML($subject), $rate);
}
} }
else
{
$text .= $this->render_comment($row, $table , $action, $id, $width, $tp->toHTML($subject), $rate);
}
}
if ($tablerender) if ($tablerender)
{ {
$text = $ns->tablerender(COMLAN_99, $text, '', TRUE); $text = $ns->tablerender(COMLAN_99, $text, '', TRUE);
} }
if (!$return) if (!$return)
{ {
echo $text; echo $text;
} }
else else
{ {
$ret['comment'] = $text; $ret['comment'] = $text;
} }
if (ADMIN && getperms("B")) if (ADMIN && getperms("B"))
{ {
$modcomment = "<div style='text-align:right'><a href='".e_ADMIN_ABS."modcomment.php?$table.$id'>".COMLAN_314."</a></div><br />"; $modcomment = "<div style='text-align:right'><a href='".e_ADMIN_ABS."modcomment.php?$table.$id'>".COMLAN_314."</a></div><br />";
} }
} }
if ($lock != "1") if ($lock != "1")
{ {
$comment = $this->form_comment($action, $table, $id, $subject, "", TRUE, $rate, $tablerender); $comment = $this->form_comment($action, $table, $id, $subject, "", TRUE, $rate, $tablerender);
} }
else else
{ {
@ -597,6 +602,9 @@ class comment {
return (!$return) ? "" : $ret; return (!$return) ? "" : $ret;
} }
function recalc_user_comments($id) function recalc_user_comments($id)
{ {
global $sql; global $sql;
@ -678,7 +686,7 @@ class comment {
$fl = new e_file; $fl = new e_file;
$omit = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$','.bak$'); $omit = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$','.bak$');
$files = $fl->get_files(e_PLUGIN, $fmask = 'e_comment.php', $omit, $recurse_level = 1, $current_level = 0); $files = $fl->get_files(e_PLUGIN, 'e_comment.php', $omit, 1, 0);
foreach($files as $file){ foreach($files as $file){
unset($e_comment, $key); unset($e_comment, $key);
@ -754,7 +762,7 @@ class comment {
SELECT c.*, u.*, ue.* FROM #comments AS c SELECT c.*, u.*, ue.* FROM #comments AS c
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id
WHERE c.comment_id!='' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." "; WHERE c.comment_id!='' AND c.comment_blocked = 0 ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." ";
if ($comment_total = $sql->db_Select_gen($query)) if ($comment_total = $sql->db_Select_gen($query))
{ {

View File

@ -4,8 +4,8 @@
| e107 website system - Language File. | e107 website system - Language File.
| |
| $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_comment.php,v $ | $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_comment.php,v $
| $Revision: 1.4 $ | $Revision: 1.5 $
| $Date: 2007-12-25 12:43:05 $ | $Date: 2008-05-25 08:26:11 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -30,6 +30,7 @@ define("COMLAN_102", "Replying to: ");
define("COMLAN_103", "Article"); define("COMLAN_103", "Article");
define("COMLAN_104", "Review"); define("COMLAN_104", "Review");
define("COMLAN_105", "Content"); define("COMLAN_105", "Content");
define("COMLAN_106", "Download");
define("COMLAN_145", "Registered: "); define("COMLAN_145", "Registered: ");
define("COMLAN_194", "Guest"); define("COMLAN_194", "Guest");
define("COMLAN_195", "Registered member"); define("COMLAN_195", "Registered member");

View File

@ -12,9 +12,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/content/content.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/content/content.php,v $
| $Revision: 1.18 $ | $Revision: 1.19 $
| $Date: 2008-02-20 21:42:25 $ | $Date: 2008-05-25 08:26:11 $
| $Author: lisa_ $ | $Author: e107steved $
+---------------------------------------------------------------+ +---------------------------------------------------------------+
*/ */
@ -1062,9 +1062,11 @@ function show_content_item(){
global $pref, $content_pref, $custom, $plugindir, $plugintable, $array, $content_shortcodes, $datequery, $order, $nextprevquery, $from, $number, $row, $qs, $gen, $sql, $aa, $tp, $rs, $cobj, $e107, $e107cache, $eArrayStorage, $ns, $rater, $ep, $row, $authordetails, $mainparent; global $pref, $content_pref, $custom, $plugindir, $plugintable, $array, $content_shortcodes, $datequery, $order, $nextprevquery, $from, $number, $row, $qs, $gen, $sql, $aa, $tp, $rs, $cobj, $e107, $e107cache, $eArrayStorage, $ns, $rater, $ep, $row, $authordetails, $mainparent;
global $CONTENT_CONTENT_TABLE_TEXT, $CONTENT_CONTENT_TABLE_PAGENAMES, $CONTENT_CONTENT_TABLE_SUMMARY, $CONTENT_CONTENT_TABLE_CUSTOM_TAGS, $CONTENT_CONTENT_TABLE_PARENT, $CONTENT_CONTENT_TABLE_INFO_PRE, $CONTENT_CONTENT_TABLE_INFO_POST, $CM_AUTHOR, $CONTENT_CONTENT_TABLE_INFO_PRE_HEADDATA, $CONTENT_CONTENT_TABLE_INFO_POST_HEADDATA; global $CONTENT_CONTENT_TABLE_TEXT, $CONTENT_CONTENT_TABLE_PAGENAMES, $CONTENT_CONTENT_TABLE_SUMMARY, $CONTENT_CONTENT_TABLE_CUSTOM_TAGS, $CONTENT_CONTENT_TABLE_PARENT, $CONTENT_CONTENT_TABLE_INFO_PRE, $CONTENT_CONTENT_TABLE_INFO_POST, $CM_AUTHOR, $CONTENT_CONTENT_TABLE_INFO_PRE_HEADDATA, $CONTENT_CONTENT_TABLE_INFO_POST_HEADDATA;
global $CONTENT_CONTENT_TABLE_PREV_PAGE, $CONTENT_CONTENT_TABLE_NEXT_PAGE; global $CONTENT_CONTENT_TABLE_PREV_PAGE, $CONTENT_CONTENT_TABLE_NEXT_PAGE;
global $comment_edit_query;
$mainparent = $aa -> getMainParent(intval($qs[1])); $mainparent = $aa -> getMainParent(intval($qs[1]));
$content_pref = $aa -> getContentPref($mainparent, true); $content_pref = $aa -> getContentPref($mainparent, true);
$comment_edit_query = 'comment.pcontent.'.$qs[1];
show_content_search_menu("item", $mainparent); //show navigator/search/order menu show_content_search_menu("item", $mainparent); //show navigator/search/order menu
$array = $aa -> getCategoryTree("", $mainparent, TRUE); $array = $aa -> getCategoryTree("", $mainparent, TRUE);