diff --git a/comment.php b/comment.php
index a811890f3..5170862f2 100644
--- a/comment.php
+++ b/comment.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/comment.php,v $
-| $Revision: 1.4 $
-| $Date: 2007-12-08 14:49:44 $
+| $Revision: 1.5 $
+| $Date: 2008-05-25 08:26:11 $
| $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
$xid = intval(varset($temp_query[4], "")); // ID of target comment
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];
unset($temp_query);
+$redirectFlag = 0;
if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit']))
-{
+{ // New comment, or edited comment, being posted.
if(!ANON && !USER)
{
- header("location: ".e_BASE."index.php");
- exit;
+ header("location: ".e_BASE."index.php");
+ exit;
}
if($table == "poll")
{
- if (!$sql->db_Select("polls", "poll_title", "`poll_id` = '{$id}' AND `poll_comment` = 1"))
- {
- header("location: ".e_BASE."index.php");
- exit;
- }
- } else if($table == "news")
+ if (!$sql->db_Select("polls", "poll_title", "`poll_id` = '{$id}' AND `poll_comment` = 1"))
+ {
+ header("location: ".e_BASE."index.php");
+ exit;
+ }
+ }
+ elseif($table == "news")
{
- if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = '{$id}' AND `news_allow_comments` = 0"))
- {
- header("location: ".e_BASE."index.php");
- exit;
- }
+ if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = '{$id}' AND `news_allow_comments` = 0"))
+ {
+ header("location: ".e_BASE."index.php");
+ exit;
+ }
}
-// $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0);
-// $pid = intval($pid);
- $pid = intval(varset($_POST['pid'], 0));
+ $pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies)
- $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_comment = $_POST['comment'];
@@ -87,74 +85,78 @@ if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit']))
if($editpid)
{
- $redir = preg_replace("#\.edit.*#si", "", e_QUERY);
+ $redirectFlag = $id;
+/* $redir = preg_replace("#\.edit.*#si", "", e_QUERY);
header("Location: ".e_SELF."?{$redir}");
- exit;
+ exit; */
}
}
if (isset($_POST['replysubmit']))
-{
+{ // Reply to nested comment being posted
if ($table == "news" && !$sql->db_Select("news", "news_allow_comments", "news_id='{$nid}' "))
{
- header("location:".e_BASE."index.php");
- exit;
+ header("location:".e_BASE."index.php");
+ exit;
}
else
{
- $row = $sql->db_Fetch();
- if (!$row['news_id']) {
- $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0);
- $pid = intval($pid);
+ $row = $sql->db_Fetch();
+ if (!$row['news_id'])
+ {
+ $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0);
+ $pid = intval($pid);
- $clean_authorname = $_POST['author_name'];
- $clean_comment = $_POST['comment'];
- $clean_subject = $_POST['subject'];
+ $clean_authorname = $_POST['author_name'];
+ $clean_comment = $_POST['comment'];
+ $clean_subject = $_POST['subject'];
- $cobj->enter_comment($clean_authorname, $clean_comment, $table, $nid, $pid, $clean_subject);
- $e107cache->clear("comment.php?{$table}.{$id}");
- }
- //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}", $nid, $e_comment[$table]['reply_location']);
- }
-
- if ($plugin_redir)
- {
- echo "\n";
- exit;
- } elseif ($table == "news" || $table == "poll")
- {
- echo "\n";
- exit;
- } elseif($table == "bugtrack")
- {
- echo "\n";
- exit;
- } elseif($table == "faq")
- {
- echo "\n";
- exit;
- } elseif ($table == "content")
- {
- echo "\n";
- exit;
- } elseif ($table == "download")
- {
- echo "\n";
- exit;
- } elseif ($table == "page")
- {
- echo "\n";
- exit;
- }
+ $cobj->enter_comment($clean_authorname, $clean_comment, $table, $nid, $pid, $clean_subject);
+ $e107cache->clear("comment.php?{$table}.{$id}");
+ }
+ $redirectFlag = $nid;
}
}
+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 "\n";
+ exit;
+ }
+ else
+ {
+ switch ($table)
+ {
+ case "news" :
+ case "poll" :
+ echo "\n";
+ exit;
+ break;
+ case "download" :
+ echo "\n";
+ exit;
+ break;
+ case "page" :
+ echo "\n";
+ exit;
+ break;
+ }
+ }
+}
+
$comment_ob_start = FALSE;
if ($action == "reply")
{
@@ -174,83 +176,70 @@ if ($action == "reply")
if ($subject == "")
{
- if ($table == "news")
+ switch ($table)
{
- if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' "))
- {
- header("location: ".e_BASE."index.php");
- exit;
- }
- else
- {
- list($news['news_title']) = $sql->db_Fetch();
- $subject = $news['news_title'];
- $title = COMLAN_100;
- }
- }
- elseif ($table == "poll")
- {
- if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' ")) {
- header("location:".e_BASE."index.php");
- exit;
- } else {
- list($poll['poll_title']) = $sql->db_Fetch();
- $subject = $poll['poll_title'];
- $title = COMLAN_101;
- }
- }
- elseif ($table == "content")
- {
- $sql->db_Select("content", "content_heading", "content_id='{$nid}'");
- $subject = $content['content_heading'];
- }
- elseif ($table == "bugtracker")
- {
- $sql->db_Select("bugtrack", "bugtrack_summary", "bugtrack_id='{$nid}'");
- $subject = $content['content_heading'];
+ case "news" :
+ if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' "))
+ {
+ header("location: ".e_BASE."index.php");
+ exit;
+ }
+ else
+ {
+ list($news['news_title']) = $sql->db_Fetch();
+ $subject = $news['news_title'];
+ $title = COMLAN_100;
+ }
+ case "poll" :
+ if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' "))
+ {
+ header("location:".e_BASE."index.php");
+ exit;
+ }
+ else
+ {
+ list($poll['poll_title']) = $sql->db_Fetch();
+ $subject = $poll['poll_title'];
+ $title = COMLAN_101;
+ }
+ break;
+ case 'download' :
+ if ($sql->db_Select('download','download_name',"download_id={$nid} "))
+ {
+ $row = $sql->db_Fetch();
+ $subject = $row['download_name'];
+ $title = COMLAN_106;
+ }
+ 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."");
require_once(HEADERF);
}
else
-{
+{ // Default code if not reply
+
+ // Check cache
if ($cache = $e107cache->retrieve("comment.php?{$table}.{$id}"))
{
- require_once(HEADERF);
- echo $cache;
- require_once(FOOTERF);
- exit;
+ require_once(HEADERF);
+ echo $cache;
+ require_once(FOOTERF);
+ exit;
}
else
{
- if ($table == "news")
- {
- /*
- changes by jalist 19/01/05:
- updated db query removed one call
- */
-
- 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
+ switch ($table)
+ {
+ case "news" :
+ 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 #news_category AS nc ON n.news_category = nc.category_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_allow_comments=0
GROUP by n.news_id";
- }
- else
- {
- $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
+ }
+ else
+ {
+ $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 #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."'
AND n.news_id={$id}
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");
- 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(FOOTERF);
+ exit;
}
- }
- else if($table == "poll")
- {
- if (!$sql->db_Select("polls", "*", "poll_id='{$id}'"))
+ require_once(HEADERF);
+ }
+ break;
+ 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");
- 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'];
- $comtype = 4;
-
- if(!$comments_poll)
- {
- require_once(FOOTERF);
- exit;
- }
+ $row = $sql->db_Fetch();
+ $subject = $row[$e_comment[$table]['db_title']];
+ $title = $e_comment[$table]['plugin_name'];
+ $field = $id;
+ require_once(HEADERF);
}
- }
- require_once(HEADERF);
+ else
+ {
+ 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']}
";
+ echo "
"; + var_dump($e_comment); + echo ""; + } + } } } if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news") { - echo "".$pref['trackbackString']." ".$e107->http_path.e_PLUGIN."trackback/trackback.php?pid={$id}"; + echo "".$pref['trackbackString']." ".$e107->http_path.e_PLUGIN."trackback/trackback.php?pid={$id}"; } -$field = ($field ? $field : ($id ? $id : "")); + +$field = ($field ? $field : ($id ? $id : "")); // ID of associated source item $width = (isset($width) && $width ? $width : ""); $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}")) { $tbArray = $sql -> db_getList(); diff --git a/download.php b/download.php index 8964c8f3f..773d2b3ad 100644 --- a/download.php +++ b/download.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/download.php,v $ -| $Revision: 1.18 $ -| $Date: 2007-11-21 22:52:45 $ +| $Revision: 1.19 $ +| $Date: 2008-05-25 08:26:11 $ | $Author: e107steved $ | +----------------------------------------------------------------------------+ @@ -399,6 +399,8 @@ if ($action == "view") $dl = $sql -> db_Fetch(); +$comment_edit_query = 'comment.download.'.$id; + $load_template = 'download_template'; if (!isset($DOWNLOAD_VIEW_TABLE)) eval($template_load_core); if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:0px");} diff --git a/e107_files/shortcode/batch/comment_shortcodes.php b/e107_files/shortcode/batch/comment_shortcodes.php index 6ee79ed82..43b05e146 100644 --- a/e107_files/shortcode/batch/comment_shortcodes.php +++ b/e107_files/shortcode/batch/comment_shortcodes.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/comment_shortcodes.php,v $ -| $Revision: 1.5 $ -| $Date: 2008-05-24 12:45:34 $ +| $Revision: 1.6 $ +| $Date: 2008-05-25 08:26:11 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -110,7 +110,8 @@ if ($pref['allowCommentEdit'] && USER && $comrow['user_id'] == USERID && $comrow } else { - return ""; +// return ""; + return ""; } } else diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 1b23c4302..62469ccf6 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -12,8 +12,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/comment_class.php,v $ -| $Revision: 1.11 $ -| $Date: 2008-05-24 15:14:36 $ +| $Revision: 1.12 $ +| $Date: 2008-05-25 08:26:11 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -32,7 +32,7 @@ require_once(e_FILE."shortcode/batch/comment_shortcodes.php"); class comment { /** - * Enter description here... + * Display the comment editing form * * @param unknown_type $action * @param unknown_type $table @@ -47,123 +47,126 @@ class comment { { //rating : boolean, to show rating system in comment global $pref, $sql, $tp; - if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE){ - return; + if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) + { + return; } require_once(e_HANDLER."ren_help.php"); if (ANON == TRUE || USER == TRUE) { - $itemid = $id; - $ns = new e107table; - if ($action == "reply" && substr($subject, 0, 4) != "Re: ") + $itemid = $id; + $ns = new e107table; + if ($action == "reply" && substr($subject, 0, 4) != "Re: ") + { + $subject = COMLAN_325.' '.$subject; + } + + $text = "\n"; - if($tablerender) - { - $text = $ns->tablerender($caption, $text, '', TRUE); - } + if($tablerender) + { + $text = $ns->tablerender($caption, $text, '', TRUE); + } - if($return) - { - return $text; - } - else - { - echo $text; - } + if($return) + { + return $text; + } + else + { + echo $text; + } } else - { - echo "