1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-14 01:22:13 +02:00

Bugtracker #4990, EONE-14:bug - couldn't edit comments on user info page

This commit is contained in:
e107steved 2010-08-23 07:28:46 +00:00
parent 8f12e9ada3
commit 049cf5344b
5 changed files with 248 additions and 225 deletions

View File

@ -1,21 +1,16 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/comment.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
*/
* e107 website system
*
* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Comment handling generic interface
*
* $URL$
* $Id$
*/
/**
@ -44,8 +39,8 @@ $cobj = new comment;
$temp_query = explode(".", e_QUERY);
$action = $temp_query[0]; // Usually says 'comment' - may say 'reply'
$table = $temp_query[1]; // Table containing item associated with comment(s)
$id = intval(varset($temp_query[2], "")); // ID of item associated with comments (e.g. news ID)
// For reply with nested comments, its the ID of the comment
$id = intval(varset($temp_query[2], 0)); // ID of item associated with comments (e.g. news ID)
// For reply with nested comments, its the ID of the 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;
@ -61,21 +56,27 @@ if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit']))
exit;
}
if($table == "poll")
switch ($table)
{
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;
}
case 'poll' :
if (!$sql->db_Select("polls", "poll_title", "`poll_id` = '{$id}' AND `poll_comment` = 1"))
{
header("location: ".e_BASE."index.php");
exit;
}
break;
case 'news' :
if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = '{$id}' AND `news_allow_comments` = 0"))
{
header("location: ".e_BASE."index.php");
exit;
}
case 'user' :
if (!$sql->db_Select('user', 'user_name', '`user_id` ='.$id))
{
header("location: ".e_BASE."index.php");
exit;
}
}
$pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies)
@ -135,13 +136,33 @@ if (isset($_POST['replysubmit']))
if ($redirectFlag)
{ // Need to go back to original page
// Check for core tables first
switch ($table)
{
case "news" :
header('Location: '.e107::getUrl()->create('core:news', 'main', 'action=extend&id='.$redirectFlag));
exit;
case "poll" :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."comment.php?comment.{$table}.{$redirectFlag}'</script>\n";
exit;
case "download" :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."download.php?view.{$redirectFlag}'</script>\n";
exit;
case "page" :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."page.php?{$redirectFlag}'</script>\n";
exit;
case 'user' :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."user.php?id.{$redirectFlag}'</script>\n";
exit;
}
// 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']);
$reply_location = str_replace('{NID}', $redirectFlag, $e_comment[$table]['reply_location']);
}
if ($plugin_redir)
@ -149,28 +170,8 @@ if ($redirectFlag)
echo "<script type='text/javascript'>document.location.href='{$reply_location}'</script>\n";
exit;
}
else
{
switch ($table)
{
case "news" :
header('Location: '.e107::getUrl()->create('core:news', 'main', 'action=extend&id='.$redirectFlag));
exit;
case "poll" :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."comment.php?comment.{$table}.{$redirectFlag}'</script>\n";
exit;
break;
case "download" :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."download.php?view.{$redirectFlag}'</script>\n";
exit;
break;
case "page" :
echo "<script type='text/javascript'>document.location.href='".e_HTTP."page.php?{$redirectFlag}'</script>\n";
exit;
break;
}
}
// No redirect found if we get here.
}
$comment_ob_start = FALSE;
@ -195,43 +196,56 @@ if ($action == "reply")
switch ($table)
{
case "news" :
if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' "))
{
header("location: ".e_BASE."index.php");
exit;
}
else
{
$news = $sql->db_Fetch();
$subject = $news['news_title'];
$title = COMLAN_100;
}
if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' "))
{
header("location: ".e_BASE."index.php");
exit;
}
else
{
$news = $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
{
$poll = $sql->db_Fetch();
$subject = $poll['poll_title'];
$title = COMLAN_101;
}
break;
if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' "))
{
header("location:".e_BASE."index.php");
exit;
}
else
{
$poll = $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 ($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;
case 'user' :
if ($sql->db_Select('user','user_name',"user_id={$nid} "))
{
$row = $sql->db_Fetch();
$subject = $row['user_name'];
$title = COMLAN_12;
}
else
{
header("location:".e_BASE."index.php");
exit;
}
break;
}
}
define('e_PAGETITLE', COMLAN_102.$subject.($title ? ' / '.$title : '')." / ".COMLAN_99);
@ -253,93 +267,74 @@ elseif ($action == 'comment')
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
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."'
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
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))
{
header("location:".e_BASE."index.php");
exit;
}
else
{
$news = $sql->db_Fetch();
$subject = $tp->toForm($news['news_title']);
define("e_PAGETITLE", "{$subject} - ".COMLAN_100." / ".COMLAN_99);
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", $subject.' - '.COMLAN_101." / ".COMLAN_99);
$poll_to_show = $id; // Need to pass poll number through to display routine
require_once(HEADERF);
require(e_PLUGIN."poll/poll_menu.php");
$field = $row['poll_id'];
if(!$comments_poll)
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'])
{
require_once(FOOTERF);
$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
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."'
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
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))
{
header("location:".e_BASE."index.php");
exit;
}
}
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} "))
else
{
$news = $sql->db_Fetch();
$subject = $tp->toForm($news['news_title']);
define("e_PAGETITLE", "{$subject} - ".COMLAN_100." / ".COMLAN_99);
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();
$subject = $row[$e_comment[$table]['db_title']];
$title = $e_comment[$table]['plugin_name'];
$comments_poll = $row['poll_comment'];
$subject = $row['poll_title'];
define("e_PAGETITLE", $subject.' - '.COMLAN_101." / ".COMLAN_99);
$poll_to_show = $id; // Need to pass poll number through to display routine
require_once(HEADERF);
require(e_PLUGIN."poll/poll_menu.php");
$field = $row['poll_id'];
if(!$comments_poll)
{
require_once(FOOTERF);
exit;
}
}
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);
}
@ -348,23 +343,56 @@ elseif ($action == 'comment')
header("location:".e_BASE."index.php");
exit;
}
}
else
{ // Error - emit some debug code
require_once(HEADERF);
if (E107_DEBUG_LEVEL)
break;
case 'user' :
if ($sql->db_Select('user','user_name',"user_id={$id} "))
{
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>";
$row = $sql->db_Fetch();
$subject = $row['user_name'];
//$title = 'Edit comment about user';
$field = $id;
require_once(HEADERF);
}
else
{
header('location:'.e_BASE.'index.php');
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} "))
{
$row = $sql->db_Fetch();
$subject = $row[$e_comment[$table]['db_title']];
$title = $e_comment[$table]['plugin_name'];
$field = $id;
require_once(HEADERF);
}
else
{
header("location:".e_BASE."index.php");
exit;
}
}
else
{ // Error - emit some debug code
require_once(HEADERF);
if (E107_DEBUG_LEVEL)
{
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>";
}
else
{
header('location:'.e_BASE.'index.php');
exit;
}
}
}
}
}

View File

@ -8,12 +8,10 @@
*
* User information - shortcodes
*
* $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/user_shortcodes.php,v $
* $Revision$
* $Date$
* $Author$
* $URL$
* $Id$
*
*/
*/
if (!defined('e107_INIT')) { exit; }
include_once(e_HANDLER.'shortcode_handler.php');
$user_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
@ -471,9 +469,9 @@ if($pref['profile_comments'])
$cobj = new comment;
$qry = "
SELECT c.*, u.*, ue.* FROM #comments AS c
LEFT JOIN #user AS u ON c.comment_author = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author = ue.user_extended_id
WHERE c.comment_item_id='".intval($user['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
WHERE c.comment_item_id=".intval($user['user_id'])."
AND c.comment_type='profile'
AND c.comment_pid='0'
ORDER BY c.comment_datestamp
@ -502,7 +500,7 @@ if($pref['profile_comments'])
{
$ret .= "<a href='".e_BASE.e_ADMIN."modcomment.php?profile.{$user['user_id']}'>".COMLAN_314."</a><br /><br />";
}
$ret .= $cobj->form_comment("comment", "profile", $user['user_id'], "", "", TRUE);
$ret .= $cobj->form_comment("comment", "profile", $user['user_id'], $user['user_name'], "", TRUE);
return $ret;
}
SC_END

View File

@ -1,21 +1,17 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/comment_class.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2002-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Comment handler class
*
* $URL$
* $Id$
*/
if (!defined('e107_INIT'))
{
exit;
@ -24,8 +20,12 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_comment.php");
global $comment_shortcodes;
require_once (e_CORE."shortcodes/batch/comment_shortcodes.php");
/**
* Enter description here...
*
* @package e107
* @subpackage e107_handlers
* @version $Id$;
*
* This class handles all comment-related functions.
*/
@ -53,8 +53,6 @@ class comment
* @param unknown_type $rating
* @return unknown
*/
function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE)
{
//rating : boolean, to show rating system in comment

View File

@ -22,6 +22,7 @@ define("COMLAN_8", "Comment");
define("COMLAN_9", "Submit comment");
define("COMLAN_10", "Administrator");
define("COMLAN_11", "Was unable to enter your comment into the database - please retype leaving out any non-standard characters.");
define('COMLAN_12', 'User');
define("COMLAN_16", "Username: ");
define("COMLAN_99", "Comments");
define("COMLAN_100", "News");
@ -63,6 +64,6 @@ define("COMLAN_TYPE_5", "docs");
define("COMLAN_TYPE_6", "bugtrack");
define("COMLAN_TYPE_7", "ideas");
define("COMLAN_TYPE_8", "userprofile");
define("COMLAN_TYPE_PAGE", "Content"); // Reall custom page, but use a 'non-technical' description
define("COMLAN_TYPE_PAGE", "Content"); // Really custom page, but use a 'non-technical' description
?>

View File

@ -2,18 +2,16 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* User information
*
* $Source: /cvs_backup/e107_0.8/user.php,v $
* $Revision$
* $Date$
* $Author$
* $URL$
* $Id$
*
*/
*/
//HCL define('PAGE_NAME', 'Members');
require_once("class2.php");
@ -126,16 +124,16 @@ if (isset($id))
exit;
}
if (isset($_POST['commentsubmit']) && $pref['profile_comments'])
{
require_once(e_HANDLER."comment_class.php");
$cobj = new comment;
$cobj->enter_comment($_POST['author_name'], $_POST['comment'], 'profile', $id, $pid, $_POST['subject']);
}
if($pref['profile_comments'])
{
include_once(e_HANDLER."comment_class.php");
require_once(e_HANDLER."comment_class.php");
$comment_edit_query = 'comment.user.'.$id;
}
if (isset($_POST['commentsubmit']) && $pref['profile_comments'])
{
$cobj = new comment;
$cobj->enter_comment($_POST['author_name'], $_POST['comment'], 'profile', $id, $pid, $_POST['subject']);
}
if($text = renderuser($id))