1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

Removed directory scanning and replaced with e_comment_list

This commit is contained in:
CaMer0n
2009-08-24 18:36:07 +00:00
parent fcc085aee3
commit 7075dfc98c

View File

@@ -1,10 +1,9 @@
<?php <?php
/* /*
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| <20>Steve Dunstan 2001-2002 | <20>Steve Dunstan 2001-2002
| http://e107.org | http://e107.org
| jalist@e107.org | jalist@e107.org
| |
@@ -12,25 +11,26 @@
| 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.22 $ | $Revision: 1.23 $
| $Date: 2009-08-15 11:55:30 $ | $Date: 2009-08-24 18:36:07 $
| $Author: marj_nl_fr $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT'))
if (!defined('e107_INIT')) { exit; } {
exit;
}
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_comment.php"); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_comment.php");
global $comment_shortcodes; global $comment_shortcodes;
require_once (e_FILE."shortcode/batch/comment_shortcodes.php"); require_once (e_FILE."shortcode/batch/comment_shortcodes.php");
/** /**
* Enter description here... * Enter description here...
* *
*/ */
class comment {
class comment
{
/** /**
* Display the comment editing form * Display the comment editing form
* *
@@ -43,6 +43,8 @@ class comment {
* @param unknown_type $rating * @param unknown_type $rating
* @return unknown * @return unknown
*/ */
function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE) function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE)
{ {
//rating : boolean, to show rating system in comment //rating : boolean, to show rating system in comment
@@ -51,7 +53,6 @@ class comment {
{ {
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)
{ {
@@ -61,9 +62,7 @@ class comment {
{ {
$subject = COMLAN_325.' '.$subject; $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%'>"; $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']) if ($pref['nested_comments'])
{ {
$text .= "<tr>\n<td style='width:20%'>".COMLAN_324."</td>\n<td style='width:80%'>\n $text .= "<tr>\n<td style='width:20%'>".COMLAN_324."</td>\n<td style='width:80%'>\n
@@ -74,7 +73,6 @@ class comment {
{ {
$text2 = "<input type='hidden' name='subject' value='".$tp->toForm($subject)."' />\n"; $text2 = "<input type='hidden' name='subject' value='".$tp->toForm($subject)."' />\n";
} }
if (isset($_GET['comment']) && $_GET['comment'] == 'edit') if (isset($_GET['comment']) && $_GET['comment'] == 'edit')
{ {
$eaction = 'edit'; $eaction = 'edit';
@@ -85,7 +83,6 @@ class comment {
$eaction = 'edit'; $eaction = 'edit';
$tmp = explode(".", e_QUERY); $tmp = explode(".", e_QUERY);
$count = 0; $count = 0;
foreach ($tmp as $t) foreach ($tmp as $t)
{ {
if ($t == "edit") if ($t == "edit")
@@ -96,7 +93,6 @@ class comment {
$count++; $count++;
} }
} }
if (isset($eaction) && $eaction == "edit") if (isset($eaction) && $eaction == "edit")
{ // Get existing comment { // Get existing comment
$id = intval($id); $id = intval($id);
@@ -111,14 +107,12 @@ class comment {
$prid = $ecom['comment_author_id']; $prid = $ecom['comment_author_id'];
$pname = $ecom['comment_author_name']; $pname = $ecom['comment_author_name'];
} }
if ($prid != USERID || !USER) if ($prid != USERID || !USER)
{ // Editing not allowed { // Editing not allowed
echo "<div style='text-align: center;'>".COMLAN_329."</div>"; echo "<div style='text-align: center;'>".COMLAN_329."</div>";
require_once (FOOTERF); require_once (FOOTERF);
exit; exit;
} }
$caption = COMLAN_318; $caption = COMLAN_318;
$comval = $tp->toForm($ecom['comment_comment']); $comval = $tp->toForm($ecom['comment_comment']);
$comval = preg_replace("#\[ ".COMLAN_319.".*\]#si", "", $comval); $comval = preg_replace("#\[ ".COMLAN_319.".*\]#si", "", $comval);
@@ -128,18 +122,19 @@ class comment {
$caption = COMLAN_9; $caption = COMLAN_9;
$comval = ""; $comval = "";
} }
//add the rating select box/result ? //add the rating select box/result ?
$rate = ""; $rate = "";
if ($rating == TRUE && !(ANON == TRUE && USER == FALSE)) if ($rating == TRUE && !(ANON == TRUE && USER == FALSE))
{ {
global $rater; global $rater;
require_once (e_HANDLER."rate_class.php"); require_once (e_HANDLER."rate_class.php");
if(!is_object($rater)){ $rater = new rater; } if (!is_object($rater))
{
$rater = new rater;
}
$rate = $rater->composerating($table, $itemid, $enter = TRUE, USERID, TRUE); $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"; $rate = "<tr><td style='width:20%; vertical-align:top;'>".COMLAN_327.":</td>\n<td style='width:80%;'>".$rate."</td></tr>\n";
} //end rating area } //end rating area
if (ANON == TRUE && USER == FALSE) if (ANON == TRUE && USER == FALSE)
{ // Box for author name (anonymous comments - if allowed) { // Box for author name (anonymous comments - if allowed)
$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 .= "<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>";
@@ -149,12 +144,10 @@ class comment {
".display_help('helpb', "comment")."</td></tr>\n<tr style='vertical-align:top'> \n<td style='width:20%'>".$text2."</td>\n ".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 <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>"; ".(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;
@@ -169,7 +162,6 @@ class comment {
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>";
} }
} }
/** /**
* Enter description here... * Enter description here...
* *
@@ -182,54 +174,63 @@ class comment {
* @param unknown_type $addrating * @param unknown_type $addrating
* @return unknown * @return unknown
*/ */
function render_comment($row, $table, $action, $id, $width, $subject, $addrating = FALSE) function render_comment($row, $table, $action, $id, $width, $subject, $addrating = FALSE)
{ {
//addrating : boolean, to show rating system in rendered comment //addrating : boolean, to show rating system in rendered comment
global $sql,$sc_style,$comment_shortcodes,$COMMENTSTYLE,$rater,$gen; global $sql,$sc_style,$comment_shortcodes,$COMMENTSTYLE,$rater,$gen;
global $pref,$comrow,$tp,$NEWIMAGE,$USERNAME,$RATING,$datestamp; global $pref,$comrow,$tp,$NEWIMAGE,$USERNAME,$RATING,$datestamp;
global $thisaction,$thistable,$thisid,$e107; global $thisaction,$thistable,$thisid,$e107;
if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
{ {
return; return;
} }
$comrow = $row; $comrow = $row;
$thistable = $table; $thistable = $table;
$thisid = $id; $thisid = $id;
$thisaction = $action; $thisaction = $action;
if ($addrating === TRUE)
if($addrating===TRUE){ {
require_once (e_HANDLER."rate_class.php"); require_once (e_HANDLER."rate_class.php");
if(!$rater || !is_object($rater)){ $rater = new rater; } if (!$rater || !is_object($rater))
{
$rater = new rater;
}
} }
require_once (e_HANDLER."level_handler.php"); require_once (e_HANDLER."level_handler.php");
if (!$width) { if (!$width)
{
$width = 0; $width = 0;
} }
if(!defined("IMAGE_nonew_comments")){ if (!defined("IMAGE_nonew_comments"))
{
define("IMAGE_nonew_comments", (file_exists(THEME."images/nonew_comments.png") ? "<img src='".THEME_ABS."images/nonew_comments.png' alt='' /> " : "<img src='".e_IMAGE_ABS."generic/nonew_comments.png' alt='' />")); define("IMAGE_nonew_comments", (file_exists(THEME."images/nonew_comments.png") ? "<img src='".THEME_ABS."images/nonew_comments.png' alt='' /> " : "<img src='".e_IMAGE_ABS."generic/nonew_comments.png' alt='' />"));
} }
if(!defined("IMAGE_new_comments")){ if (!defined("IMAGE_new_comments"))
{
define("IMAGE_new_comments", (file_exists(THEME."images/new_comments.png") ? "<img src='".THEME_ABS."images/new_comments.png' alt='' /> " : "<img src='".e_IMAGE_ABS."generic/new_comments.png' alt='' /> ")); define("IMAGE_new_comments", (file_exists(THEME."images/new_comments.png") ? "<img src='".THEME_ABS."images/new_comments.png' alt='' /> " : "<img src='".e_IMAGE_ABS."generic/new_comments.png' alt='' /> "));
} }
$ns = new e107table; $ns = new e107table;
if(!$gen || !is_object($gen)){ $gen = new convert; } if (!$gen || !is_object($gen))
{
$gen = new convert;
}
$url = e_PAGE."?".e_QUERY; $url = e_PAGE."?".e_QUERY;
$unblock = "[<a href='".e_ADMIN_ABS."comment.php?unblock-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_1."</a>] "; $unblock = "[<a href='".e_ADMIN_ABS."comment.php?unblock-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_1."</a>] ";
$block = "[<a href='".e_ADMIN_ABS."comment.php?block-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_2."</a>] "; $block = "[<a href='".e_ADMIN_ABS."comment.php?block-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_2."</a>] ";
$delete = "[<a href='".e_ADMIN_ABS."comment.php?delete-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_3."</a>] "; $delete = "[<a href='".e_ADMIN_ABS."comment.php?delete-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_3."</a>] ";
$userinfo = "[<a href='".e_ADMIN_ABS."userinfo.php?".$e107->ipDecode($comrow['comment_ip'])."'>".COMLAN_4."</a>]"; $userinfo = "[<a href='".e_ADMIN_ABS."userinfo.php?".$e107->ipDecode($comrow['comment_ip'])."'>".COMLAN_4."</a>]";
if (!$COMMENTSTYLE) if (!$COMMENTSTYLE)
{ {
global $THEMES_DIRECTORY; global $THEMES_DIRECTORY;
$COMMENTSTYLE = ""; $COMMENTSTYLE = "";
if (file_exists(THEME."comment_template.php")) { if (file_exists(THEME."comment_template.php"))
{
require_once (THEME."comment_template.php"); require_once (THEME."comment_template.php");
} else { }
else
{
require_once (e_BASE.$THEMES_DIRECTORY."templates/comment_template.php"); require_once (e_BASE.$THEMES_DIRECTORY."templates/comment_template.php");
} }
} }
@@ -247,41 +248,50 @@ class comment {
</td> </td>
</tr> </tr>
</table>"; </table>";
}else{ }
else
{
$renderstyle = $COMMENTSTYLE; $renderstyle = $COMMENTSTYLE;
} }
if($pref['comments_icon']) { if ($pref['comments_icon'])
if ($comrow['comment_datestamp'] > USERLV ) { {
if ($comrow['comment_datestamp'] > USERLV)
{
$NEWIMAGE = IMAGE_new_comments; $NEWIMAGE = IMAGE_new_comments;
} else { }
else
{
$NEWIMAGE = IMAGE_nonew_comments; $NEWIMAGE = IMAGE_nonew_comments;
} }
} else { }
else
{
$NEWIMAGE = ""; $NEWIMAGE = "";
} }
} else { }
else
{
$renderstyle = $COMMENTSTYLE; $renderstyle = $COMMENTSTYLE;
} }
$highlight_search = FALSE; $highlight_search = FALSE;
if (isset($_POST['highlight_search'])) { if (isset($_POST['highlight_search']))
{
$highlight_search = TRUE; $highlight_search = TRUE;
} }
if (!defined("IMAGE_rank_main_admin_image"))
if(!defined("IMAGE_rank_main_admin_image")){ {
define("IMAGE_rank_main_admin_image", (isset($pref['rank_main_admin_image']) && $pref['rank_main_admin_image'] && file_exists(THEME."forum/".$pref['rank_main_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_main_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/main_admin.png' alt='' />")); define("IMAGE_rank_main_admin_image", (isset($pref['rank_main_admin_image']) && $pref['rank_main_admin_image'] && file_exists(THEME."forum/".$pref['rank_main_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_main_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/main_admin.png' alt='' />"));
} }
if(!defined("IMAGE_rank_moderator_image")){ if (!defined("IMAGE_rank_moderator_image"))
{
define("IMAGE_rank_moderator_image", (isset($pref['rank_moderator_image']) && $pref['rank_moderator_image'] && file_exists(THEME."forum/".$pref['rank_moderator_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_moderator_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/admin.png' alt='' />")); define("IMAGE_rank_moderator_image", (isset($pref['rank_moderator_image']) && $pref['rank_moderator_image'] && file_exists(THEME."forum/".$pref['rank_moderator_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_moderator_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/admin.png' alt='' />"));
} }
if(!defined("IMAGE_rank_admin_image")){ if (!defined("IMAGE_rank_admin_image"))
{
define("IMAGE_rank_admin_image", (isset($pref['rank_admin_image']) && $pref['rank_admin_image'] && file_exists(THEME."forum/".$pref['rank_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/admin.png' alt='' />")); define("IMAGE_rank_admin_image", (isset($pref['rank_admin_image']) && $pref['rank_admin_image'] && file_exists(THEME."forum/".$pref['rank_admin_image']) ? "<img src='".THEME_ABS."forum/".$pref['rank_admin_image']."' alt='' />" : "<img src='".e_PLUGIN_ABS."forum/images/".IMODE."/admin.png' alt='' />"));
} }
$RATING = ($addrating == TRUE && $comrow['user_id'] ? $rater->composerating($thistable, $thisid, FALSE, $comrow['user_id']) : ""); $RATING = ($addrating == TRUE && $comrow['user_id'] ? $rater->composerating($thistable, $thisid, FALSE, $comrow['user_id']) : "");
$text = $tp->parseTemplate($renderstyle, TRUE, $comment_shortcodes); $text = $tp->parseTemplate($renderstyle, TRUE, $comment_shortcodes);
if ($action == "comment" && $pref['nested_comments']) if ($action == "comment" && $pref['nested_comments'])
{ {
$type = $this->getCommentType($thistable); $type = $this->getCommentType($thistable);
@@ -293,7 +303,6 @@ class comment {
WHERE comment_item_id='".intval($thisid)."' AND comment_type='".$tp->toDB($type, true)."' AND comment_pid='".intval($comrow['comment_id'])."' WHERE comment_item_id='".intval($thisid)."' AND comment_type='".$tp->toDB($type, true)."' AND comment_pid='".intval($comrow['comment_id'])."'
ORDER BY comment_datestamp ORDER BY comment_datestamp
"; ";
$sql_nc = new db; /* a new db must be created here, for nested comment */ $sql_nc = new db; /* a new db must be created here, for nested comment */
if ($sub_total = $sql_nc->db_Select_gen($sub_query)) if ($sub_total = $sql_nc->db_Select_gen($sub_query))
{ {
@@ -310,7 +319,6 @@ class comment {
} // End (nested comment handling) } // End (nested comment handling)
return $text; return $text;
} }
/** /**
* Enter description here... * Enter description here...
* *
@@ -322,16 +330,16 @@ class comment {
* @param unknown_type $subject * @param unknown_type $subject
* @param unknown_type $rateindex * @param unknown_type $rateindex
*/ */
function enter_comment($author_name, $comment, $table, $id, $pid, $subject, $rateindex = FALSE) function enter_comment($author_name, $comment, $table, $id, $pid, $subject, $rateindex = FALSE)
{ {
//rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect()) //rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect())
global $sql,$sql2,$tp,$e107cache,$e_event,$e107,$pref,$rater; global $sql,$sql2,$tp,$e107cache,$e_event,$e107,$pref,$rater;
if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
{ {
return; return;
} }
if (isset($_GET['comment']) && $_GET['comment'] == 'edit') if (isset($_GET['comment']) && $_GET['comment'] == 'edit')
{ {
$eaction = 'edit'; $eaction = 'edit';
@@ -352,9 +360,7 @@ class comment {
$count++; $count++;
} }
} }
$type = $this->getCommentType($table); $type = $this->getCommentType($table);
$comment = $tp->toDB($comment); $comment = $tp->toDB($comment);
$subject = $tp->toDB($subject); $subject = $tp->toDB($subject);
$cuser_id = 0; $cuser_id = 0;
@@ -386,12 +392,10 @@ class comment {
$cuser_name = $tp->toDB($author_name); $cuser_name = $tp->toDB($author_name);
} }
} }
if (!defined("emessage")) if (!defined("emessage"))
{ {
$ip = $e107->getip(); // Store IP 'in the raw' - could be IPv4 or IPv6. Its always returned in a normalised form $ip = $e107->getip(); // Store IP 'in the raw' - could be IPv4 or IPv6. Its always returned in a normalised form
$_t = time(); $_t = time();
if ($editpid) if ($editpid)
{ {
$comment .= "\n[ ".COMLAN_319." [time=short]".time()."[/time] ]"; $comment .= "\n[ ".COMLAN_319." [time=short]".time()."[/time] ]";
@@ -399,20 +403,11 @@ class comment {
$e107cache->clear("comment"); $e107cache->clear("comment");
return; return;
} }
$edata_li = array( $edata_li = array(
// comment_id - auto-assigned // comment_id - auto-assigned
'comment_pid' => intval($pid), 'comment_pid'=>intval($pid), "comment_item_id"=>$id, "comment_subject"=>$subject, 'comment_author_id'=>$cuser_id, 'comment_author_name'=>$cuser_name,
"comment_item_id" => $id,
"comment_subject" => $subject,
'comment_author_id' => $cuser_id,
'comment_author_name' => $cuser_name,
// 'comment_author_email' => '', Field not saved ATM // 'comment_author_email' => '', Field not saved ATM
"comment_datestamp" => $_t, "comment_datestamp"=>$_t, "comment_comment"=>$comment, 'comment_ip'=>$ip, "comment_type"=>$tp->toDB($type, true));
"comment_comment" => $comment,
'comment_ip' => $ip,
"comment_type" => $tp -> toDB($type, true)
);
// if (!$sql->db_Insert("comments", "0, '".intval($pid)."', '".intval($id)."', '$subject', '$nick', '', '".$_t."', '$comment', '0', '$ip', '".$tp -> toDB($type, true)."', '0' ")) // if (!$sql->db_Insert("comments", "0, '".intval($pid)."', '".intval($id)."', '$subject', '$nick', '', '".$_t."', '$comment', '0', '$ip', '".$tp -> toDB($type, true)."', '0' "))
if (!$sql->db_Insert("comments", $edata_li)) if (!$sql->db_Insert("comments", $edata_li))
{ {
@@ -430,7 +425,6 @@ class comment {
unset($edata_li['comment_pid']); unset($edata_li['comment_pid']);
unset($edata_li['comment_author_email']); unset($edata_li['comment_author_email']);
unset($edata_li['comment_ip']); unset($edata_li['comment_ip']);
// $edata_li = array("comment_type" => $type, "comment_subject" => $subject, "comment_item_id" => $id, "comment_nick" => $nick, "comment_time" => $_t, "comment_comment" => $comment); // $edata_li = array("comment_type" => $type, "comment_subject" => $subject, "comment_item_id" => $id, "comment_nick" => $nick, "comment_time" => $_t, "comment_comment" => $comment);
$e_event->trigger("postcomment", $edata_li); $e_event->trigger("postcomment", $edata_li);
$e107cache->clear("comment"); $e107cache->clear("comment");
@@ -447,36 +441,55 @@ class comment {
define("emessage", COMLAN_312); define("emessage", COMLAN_312);
} }
//if rateindex is posted, enter the rating from this user //if rateindex is posted, enter the rating from this user
if($rateindex){ if ($rateindex)
{
$rater->enterrating($rateindex); $rater->enterrating($rateindex);
} }
if (defined("emessage")) if (defined("emessage"))
{ {
message_handler("ALERT", emessage); message_handler("ALERT", emessage);
} }
} }
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $table * @param unknown_type $table
* @return unknown * @return unknown
*/ */
function getCommentType($table) function getCommentType($table)
{ {
if(is_numeric($table)) { return $table; } if (is_numeric($table))
{
return $table;
}
switch ($table) switch ($table)
{ {
case "news" : $type = 0; break; case "news":
case "content" : $type = 1; break; $type = 0;
case "download" : $type = 2; break; break;
case "faq" : $type = 3; break; case "content":
case "poll" : $type = 4; break; $type = 1;
case "docs" : $type = 5; break; break;
case "bugtrack" : $type = 6; break; case "download":
default : $type = $table; break; $type = 2;
break;
case "faq":
$type = 3;
break;
case "poll":
$type = 4;
break;
case "docs":
$type = 5;
break;
case "bugtrack":
$type = 6;
break;
default:
$type = $table;
break;
/**************************************** /****************************************
Add your comment type here in same format as above, ie ... Add your comment type here in same format as above, ie ...
case "your_comment_type"; $type = your_type_id; break; case "your_comment_type"; $type = your_type_id; break;
@@ -484,7 +497,6 @@ class comment {
} }
return $type; return $type;
} }
/** /**
* Enter description here... * Enter description here...
* *
@@ -492,6 +504,8 @@ class comment {
* @param unknown_type $id * @param unknown_type $id
* @return unknown * @return unknown
*/ */
function count_comments($table, $id) function count_comments($table, $id)
{ {
global $sql,$tp; global $sql,$tp;
@@ -499,8 +513,6 @@ class comment {
$count_comments = $sql->db_Count("comments", "(*)", "WHERE comment_item_id='".intval($id)."' AND comment_type='".$tp->toDB($type, true)."' "); $count_comments = $sql->db_Count("comments", "(*)", "WHERE comment_item_id='".intval($id)."' AND comment_type='".$tp->toDB($type, true)."' ");
return $count_comments; return $count_comments;
} }
/** /**
* Enter description here... * Enter description here...
* *
@@ -511,39 +523,32 @@ class comment {
* @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;
} }
// Query no longer used // Query no longer used
// $count_comments = $this -> count_comments($table, $id, $pid=FALSE); // $count_comments = $this -> count_comments($table, $id, $pid=FALSE);
$type = $this->getCommentType($table); $type = $this->getCommentType($table);
$query = $pref['nested_comments'] ? "SELECT c.*, u.*, ue.* FROM #comments AS c
$query = $pref['nested_comments'] ?
"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_item_id='".intval($id)."' AND c.comment_type='".$tp -> toDB($type, true)."' AND c.comment_pid='0' ORDER BY c.comment_datestamp" WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' AND c.comment_pid='0' ORDER BY c.comment_datestamp" : "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_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' ORDER BY c.comment_datestamp"; WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' ORDER BY c.comment_datestamp";
$text = ""; $text = "";
$comment = ''; $comment = '';
$modcomment = ''; $modcomment = '';
$lock = ''; $lock = '';
$ret['comment'] = ''; $ret['comment'] = '';
if ($comment_total = $sql->db_Select_gen($query)) if ($comment_total = $sql->db_Select_gen($query))
{ {
$width = 0; $width = 0;
@@ -560,12 +565,10 @@ class comment {
$text .= $this->render_comment($row, $table, $action, $id, $width, $tp->toHTML($subject), $rate); $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;
@@ -574,13 +577,11 @@ class comment {
{ {
$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);
@@ -589,26 +590,20 @@ class comment {
{ {
$comment = "<br /><div style='text-align:center'><b>".COMLAN_328."</b></div>"; $comment = "<br /><div style='text-align:center'><b>".COMLAN_328."</b></div>";
} }
if (!$return) if (!$return)
{ {
echo $modcomment.$comment; echo $modcomment.$comment;
} }
$ret['comment'] .= $modcomment; $ret['comment'] .= $modcomment;
$ret['comment_form'] = $comment; $ret['comment_form'] = $comment;
$ret['caption'] = COMLAN_99; $ret['caption'] = COMLAN_99;
return (!$return) ? "" : $ret; return (!$return) ? "" : $ret;
} }
function recalc_user_comments($id) function recalc_user_comments($id)
{ {
global $sql; global $sql;
if (is_array($id)) if (is_array($id))
{ {
foreach ($id as $_id) foreach ($id as $_id)
@@ -651,11 +646,9 @@ class comment {
} }
function delete_comments($table, $id) function delete_comments($table, $id)
{ {
global $sql,$tp; global $sql,$tp;
$type = $this->getCommentType($table); $type = $this->getCommentType($table);
$type = $tp->toDB($type, true); $type = $tp->toDB($type, true);
$id = intval($id); $id = intval($id);
@@ -664,16 +657,15 @@ class comment {
$this->recalc_user_comments($author_list); $this->recalc_user_comments($author_list);
return $num_deleted; return $num_deleted;
} }
//1) call function getCommentData(); from file //1) call function getCommentData(); from file
//2) function-> get number of records from comments db //2) function-> get number of records from comments db
//3) get all e_comment.php files and collect the variables //3) get all e_comment.php files and collect the variables
//4) interchange the db rows and the e_ vars //4) interchange the db rows and the e_ vars
//5) return the interchanged data in array //5) return the interchanged data in array
//6) from file: render the returned data //6) from file: render the returned data
//get all e_comment.php files and collect the variables //get all e_comment.php files and collect the variables
function get_e_comment() function get_e_comment()
{ {
$data = getcachedvars('e_comment'); $data = getcachedvars('e_comment');
@@ -682,24 +674,26 @@ class comment {
return $data; return $data;
} }
require_once(e_HANDLER."file_class.php"); $files = e107::getPref('e_comment_list');
$fl = new e_file;
$omit = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$','.bak$'); foreach ($files as $file=>$perms)
$files = $fl->get_files(e_PLUGIN, 'e_comment.php', $omit, 1, 0); {
foreach($files as $file){
unset($e_comment, $key); unset($e_comment, $key);
include($file['path'].$file['fname']); include (e_PLUGIN.$file."/e_comment.php");
if($e_comment && is_array($e_comment)){ if ($e_comment && is_array($e_comment))
{
$key = $e_comment['eplug_comment_ids']; $key = $e_comment['eplug_comment_ids'];
if(isset($key) && $key!=''){ if (isset($key) && $key != '')
{
$data[$key] = $e_comment; $data[$key] = $e_comment;
} }
}else{ }
else
{
//convert old method variables into the same array method //convert old method variables into the same array method
$key = $e_plug_table; $key = $e_plug_table;
if(isset($key) && $key!=''){ if (isset($key) && $key != '')
{
$e_comment['eplug_comment_ids'] = $e_plug_table; $e_comment['eplug_comment_ids'] = $e_plug_table;
$e_comment['plugin_name'] = $plugin_name; $e_comment['plugin_name'] = $plugin_name;
$e_comment['plugin_path'] = $plugin_path; $e_comment['plugin_path'] = $plugin_path;
@@ -715,8 +709,6 @@ class comment {
cachevars('e_comment', $data); cachevars('e_comment', $data);
return $data; return $data;
} }
/* /*
* get number of records from comments db * get number of records from comments db
* interchange the db rows and the e_comment vars * interchange the db rows and the e_comment vars
@@ -730,20 +722,17 @@ class comment {
* @param array $cdreta : current data set * @param array $cdreta : current data set
*/ */
function getCommentData($amount = '', $from = '', $qry = '', $cdvalid = FALSE, $cdreta = FALSE) function getCommentData($amount = '', $from = '', $qry = '', $cdvalid = FALSE, $cdreta = FALSE)
{ {
global $pref,$menu_pref,$sql,$sql2,$tp; global $pref,$menu_pref,$sql,$sql2,$tp;
$from1 = ($from ? $from : '0'); $from1 = ($from ? $from : '0');
$amount1 = ($amount ? $amount : '10'); $amount1 = ($amount ? $amount : '10');
$valid = ($cdvalid ? $cdvalid : '0'); $valid = ($cdvalid ? $cdvalid : '0');
$reta = ($cdreta ? $cdreta : array()); $reta = ($cdreta ? $cdreta : array());
//get all e_comment data //get all e_comment data
$e_comment = $this->get_e_comment(); $e_comment = $this->get_e_comment();
$qry1 = ($qry ? " AND ".$qry : ""); $qry1 = ($qry ? " AND ".$qry : "");
//get 'amount' of records from comment db //get 'amount' of records from comment db
/* /*
$query = $pref['nested_comments'] ? $query = $pref['nested_comments'] ?
@@ -757,42 +746,34 @@ class comment {
LEFT JOIN #user_extended AS ue ON c.comment_author = ue.user_extended_id LEFT JOIN #user_extended AS ue ON c.comment_author = ue.user_extended_id
WHERE c.comment_id!='' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." "; WHERE c.comment_id!='' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." ";
*/ */
$query = " $query = "
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!='' AND c.comment_blocked = 0 ".$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))
{ {
$width = 0; $width = 0;
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ {
$ret = array(); $ret = array();
//date //date
$ret['comment_datestamp'] = $row['comment_datestamp']; $ret['comment_datestamp'] = $row['comment_datestamp'];
//author - no ned to split now //author - no ned to split now
$comment_author_id = $row['comment_author_id']; $comment_author_id = $row['comment_author_id'];
$comment_author_name = $row['comment_author_name']; $comment_author_name = $row['comment_author_name'];
$ret['comment_author'] = (USERID ? "<a href='".e_BASE."user.php?id.".$comment_author_id."'>".$comment_author_name."</a>" : $comment_author_name); $ret['comment_author'] = (USERID ? "<a href='".e_BASE."user.php?id.".$comment_author_id."'>".$comment_author_name."</a>" : $comment_author_name);
//comment text //comment text
$comment = strip_tags(preg_replace("/\[.*\]/", "", $row['comment_comment'])); // remove bbcode $comment = strip_tags(preg_replace("/\[.*\]/", "", $row['comment_comment'])); // remove bbcode
$ret['comment_comment'] = $tp->toHTML($comment, FALSE, "", "", $pref['main_wordwrap']); $ret['comment_comment'] = $tp->toHTML($comment, FALSE, "", "", $pref['main_wordwrap']);
//subject //subject
$ret['comment_subject'] = $tp->toHTML($row['comment_subject'], TRUE); $ret['comment_subject'] = $tp->toHTML($row['comment_subject'], TRUE);
switch ($row['comment_type']) switch ($row['comment_type'])
{ {
case '0': // news case '0': // news
if ($sql2->db_Select("news", "*", "news_id='".$row['comment_item_id']."' AND news_class REGEXP '".e_CLASS_REGEXP."' ")) if ($sql2->db_Select("news", "*", "news_id='".$row['comment_item_id']."' AND news_class REGEXP '".e_CLASS_REGEXP."' "))
{ {
$row2 = $sql2->db_Fetch(); $row2 = $sql2->db_Fetch();
$ret['comment_type'] = COMLAN_TYPE_1; $ret['comment_type'] = COMLAN_TYPE_1;
$ret['comment_title'] = $tp->toHTML($row2['news_title'], TRUE, 'emotes_off, no_make_clickable'); $ret['comment_title'] = $tp->toHTML($row2['news_title'], TRUE, 'emotes_off, no_make_clickable');
$ret['comment_url'] = e_HTTP."comment.php?comment.news.".$row['comment_item_id']; $ret['comment_url'] = e_HTTP."comment.php?comment.news.".$row['comment_item_id'];
@@ -800,16 +781,13 @@ class comment {
$ret['comment_category_url'] = e_HTTP."news.php"; $ret['comment_category_url'] = e_HTTP."news.php";
} }
break; break;
case '1': // article, review or content page - defunct category, but filter them out case '1': // article, review or content page - defunct category, but filter them out
break; break;
case '2': // downloads case '2': // downloads
$qryd = "SELECT d.download_name, dc.download_category_class, dc.download_category_id, dc.download_category_name FROM #download AS d LEFT JOIN #download_category AS dc ON d.download_category=dc.download_category_id WHERE d.download_id={$row['comment_item_id']} AND dc.download_category_class REGEXP '".e_CLASS_REGEXP."' "; $qryd = "SELECT d.download_name, dc.download_category_class, dc.download_category_id, dc.download_category_name FROM #download AS d LEFT JOIN #download_category AS dc ON d.download_category=dc.download_category_id WHERE d.download_id={$row['comment_item_id']} AND dc.download_category_class REGEXP '".e_CLASS_REGEXP."' ";
if ($sql2->db_Select_gen($qryd)) if ($sql2->db_Select_gen($qryd))
{ {
$row2 = $sql2->db_Fetch(); $row2 = $sql2->db_Fetch();
$ret['comment_type'] = COMLAN_TYPE_2; $ret['comment_type'] = COMLAN_TYPE_2;
$ret['comment_title'] = $tp->toHTML($row2['download_name'], TRUE, 'emotes_off, no_make_clickable'); $ret['comment_title'] = $tp->toHTML($row2['download_name'], TRUE, 'emotes_off, no_make_clickable');
$ret['comment_url'] = e_HTTP."download.php?view.".$row['comment_item_id']; $ret['comment_url'] = e_HTTP."download.php?view.".$row['comment_item_id'];
@@ -822,18 +800,15 @@ class comment {
if ($sql2->db_Select("polls", "*", "poll_id='".$row['comment_item_id']."' ")) if ($sql2->db_Select("polls", "*", "poll_id='".$row['comment_item_id']."' "))
{ {
$row2 = $sql2->db_Fetch(); $row2 = $sql2->db_Fetch();
$ret['comment_type'] = COMLAN_TYPE_4; $ret['comment_type'] = COMLAN_TYPE_4;
$ret['comment_title'] = $tp->toHTML($row2['poll_title'], TRUE, 'emotes_off, no_make_clickable'); $ret['comment_title'] = $tp->toHTML($row2['poll_title'], TRUE, 'emotes_off, no_make_clickable');
$ret['comment_url'] = e_HTTP."comment.php?comment.poll.".$row['comment_item_id']; $ret['comment_url'] = e_HTTP."comment.php?comment.poll.".$row['comment_item_id'];
$ret['comment_category_url'] = e_PLUGIN_ABS.'poll/poll.php'; $ret['comment_category_url'] = e_PLUGIN_ABS.'poll/poll.php';
} }
break; break;
// '5' was docs // '5' was docs
// '6' was bugtracker // '6' was bugtracker
// 'ideas' was implemented // 'ideas' was implemented
case 'profile': // userprofile case 'profile': // userprofile
if (USER) if (USER)
{ {
@@ -842,13 +817,12 @@ class comment {
$ret['comment_url'] = e_HTTP."user.php?id.".$row['comment_item_id']; $ret['comment_url'] = e_HTTP."user.php?id.".$row['comment_item_id'];
} }
break; break;
case 'page': // Custom Page case 'page': // Custom Page
$ret['comment_type'] = COMLAN_TYPE_PAGE; $ret['comment_type'] = COMLAN_TYPE_PAGE;
$ret['comment_title'] = $ret['comment_subject'] ? $ret['comment_subject'] : $ret['comment_comment']; $ret['comment_title'] = $ret['comment_subject'] ? $ret['comment_subject']:
$ret['comment_comment'];
$ret['comment_url'] = e_HTTP."page.php?".$row['comment_item_id']; $ret['comment_url'] = e_HTTP."page.php?".$row['comment_item_id'];
break; break;
default: default:
if (isset($e_comment[$row['comment_type']]) && is_array($e_comment[$row['comment_type']])) if (isset($e_comment[$row['comment_type']]) && is_array($e_comment[$row['comment_type']]))
{ {
@@ -904,7 +878,6 @@ class comment {
} }
return $reta; return $reta;
} }
} //end class } //end class
?> ?>