From 7075dfc98c608e6894c23827c4e2442b9bb1111d Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Mon, 24 Aug 2009 18:36:07 +0000 Subject: [PATCH] Removed directory scanning and replaced with e_comment_list --- e107_handlers/comment_class.php | 1377 +++++++++++++++---------------- 1 file changed, 675 insertions(+), 702 deletions(-) diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index ae5f10e81..e81f565c7 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -1,36 +1,36 @@
\n"; - - if ($pref['nested_comments']) - { - $text .= "\n\n\n"; - $text2 = ""; - } - else - { - $text2 = "\n"; - } - - if (isset($_GET['comment']) && $_GET['comment'] == 'edit') - { - $eaction = 'edit'; - $id = $_GET['comment_id']; - } - elseif (strpos(e_QUERY, 'edit.') !== FALSE) - { - $eaction = 'edit'; - $tmp = explode(".", e_QUERY); - $count = 0; - - foreach($tmp as $t) + $itemid = $id; + $ns = new e107table; + if ($action == "reply" && substr($subject, 0, 4) != "Re: ") { - if($t == "edit") - { - $id = $tmp[($count+1)]; - break; - } - $count++; + $subject = COMLAN_325.' '.$subject; } - } - - if(isset($eaction) && $eaction == "edit") - { // Get existing comment - $id=intval($id); - $sql -> db_Select("comments", "*", "comment_id='{$id}' "); - $ecom = $sql -> db_Fetch(); - if (isset($ecom['comment_author'])) - { // Old comment DB format - list($prid, $pname) = explode(".", $ecom['comment_author'],2); + $text = "\n
\n
".COMLAN_324."\n - \n
"; + if ($pref['nested_comments']) + { + $text .= "\n\n\n"; + $text2 = ""; } else { - $prid = $ecom['comment_author_id']; - $pname = $ecom['comment_author_name']; + $text2 = "\n"; } - - if($prid != USERID || !USER) - { // Editing not allowed - echo "
".COMLAN_329."
"; - require_once(FOOTERF); - exit; + if (isset($_GET['comment']) && $_GET['comment'] == 'edit') + { + $eaction = 'edit'; + $id = $_GET['comment_id']; } - - $caption = COMLAN_318; - $comval = $tp -> toForm($ecom['comment_comment']); - $comval = preg_replace("#\[ ".COMLAN_319.".*\]#si", "", $comval); - } - else - { // New comment - blank form - $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 = "\n\n"; - } //end rating area - - if (ANON == TRUE && USER == FALSE) - { // Box for author name (anonymous comments - if allowed) - $text .= "\n\n\n"; - } - $text .= $rate." \n + elseif (strpos(e_QUERY, 'edit.') !== FALSE) + { + $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") + { // Get existing comment + $id = intval($id); + $sql->db_Select("comments", "*", "comment_id='{$id}' "); + $ecom = $sql->db_Fetch(); + if (isset($ecom['comment_author'])) + { // Old comment DB format + list($prid, $pname) = explode(".", $ecom['comment_author'], 2); + } + else + { + $prid = $ecom['comment_author_id']; + $pname = $ecom['comment_author_name']; + } + if ($prid != USERID || !USER) + { // Editing not allowed + echo "
".COMLAN_329."
"; + require_once (FOOTERF); + exit; + } + $caption = COMLAN_318; + $comval = $tp->toForm($ecom['comment_comment']); + $comval = preg_replace("#\[ ".COMLAN_319.".*\]#si", "", $comval); + } + else + { // New comment - blank form + $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 = "\n\n"; + } //end rating area + if (ANON == TRUE && USER == FALSE) + { // Box for author name (anonymous comments - if allowed) + $text .= "\n\n\n"; + } + $text .= $rate." \n \n\n \n\n + ".display_help('helpb', "comment")."\n \n\n \n\n
".COMLAN_324."\n + \n
".COMLAN_327.":".$rate."
".COMLAN_16."\n\n
".COMLAN_327.":".$rate."
".COMLAN_16."\n\n
".COMLAN_8.":\n\n
- ".display_help('helpb',"comment")."
".$text2."
".$text2."\n - ". (isset($action) && $action == "reply" ? "" : '').(isset($eaction) && $eaction == "edit" ? "" : "").(isset($content_type) && $content_type ? "" : ''). "\n
\n
"; - - if($tablerender) - { - $text = $ns->tablerender($caption, $text, '', TRUE); - } - - if($return) - { - return $text; - } - else - { - echo $text; - } + ".(isset($action) && $action == "reply" ? "" : '').(isset($eaction) && $eaction == "edit" ? "" : "").(isset($content_type) && $content_type ? "" : '')."\n\n\n\n"; + if ($tablerender) + { + $text = $ns->tablerender($caption, $text, '', TRUE); + } + if ($return) + { + return $text; + } + else + { + echo $text; + } } else - { // Comment entry not allowed - point to signup link - echo "
".COMLAN_6." ".COMLAN_321." ".COMLAN_322."
"; + { // Comment entry not allowed - point to signup link + echo "
".COMLAN_6." ".COMLAN_321." ".COMLAN_322."
"; } } - /** * Enter description here... * @@ -182,135 +174,151 @@ class comment { * @param unknown_type $addrating * @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 - global $sql, $sc_style, $comment_shortcodes, $COMMENTSTYLE, $rater, $gen; - global $pref, $comrow, $tp, $NEWIMAGE, $USERNAME, $RATING, $datestamp; - global $thisaction, $thistable, $thisid, $e107; - - if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) + global $sql,$sc_style,$comment_shortcodes,$COMMENTSTYLE,$rater,$gen; + global $pref,$comrow,$tp,$NEWIMAGE,$USERNAME,$RATING,$datestamp; + global $thisaction,$thistable,$thisid,$e107; + if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) { - return; + return; } - - - $comrow = $row; - $thistable = $table; - $thisid = $id; - $thisaction = $action; - - if($addrating===TRUE){ - require_once(e_HANDLER."rate_class.php"); - if(!$rater || !is_object($rater)){ $rater = new rater; } + $comrow = $row; + $thistable = $table; + $thisid = $id; + $thisaction = $action; + if ($addrating === TRUE) + { + require_once (e_HANDLER."rate_class.php"); + if (!$rater || !is_object($rater)) + { + $rater = new rater; + } } - - require_once(e_HANDLER."level_handler.php"); - if (!$width) { + require_once (e_HANDLER."level_handler.php"); + if (!$width) + { $width = 0; } - if(!defined("IMAGE_nonew_comments")){ + if (!defined("IMAGE_nonew_comments")) + { define("IMAGE_nonew_comments", (file_exists(THEME."images/nonew_comments.png") ? " " : "")); } - if(!defined("IMAGE_new_comments")){ + if (!defined("IMAGE_new_comments")) + { define("IMAGE_new_comments", (file_exists(THEME."images/new_comments.png") ? " " : " ")); } - $ns = new e107table; - if(!$gen || !is_object($gen)){ $gen = new convert; } - $url = e_PAGE."?".e_QUERY; - $unblock = "[".COMLAN_1."] "; - $block = "[".COMLAN_2."] "; - $delete = "[".COMLAN_3."] "; - $userinfo = "[".COMLAN_4."]"; - - if (!$COMMENTSTYLE) + $ns = new e107table; + if (!$gen || !is_object($gen)) + { + $gen = new convert; + } + $url = e_PAGE."?".e_QUERY; + $unblock = "[".COMLAN_1."] "; + $block = "[".COMLAN_2."] "; + $delete = "[".COMLAN_3."] "; + $userinfo = "[".COMLAN_4."]"; + if (!$COMMENTSTYLE) { global $THEMES_DIRECTORY; $COMMENTSTYLE = ""; - if (file_exists(THEME."comment_template.php")) { - require_once(THEME."comment_template.php"); - } else { - require_once(e_BASE.$THEMES_DIRECTORY."templates/comment_template.php"); + if (file_exists(THEME."comment_template.php")) + { + require_once (THEME."comment_template.php"); + } + else + { + require_once (e_BASE.$THEMES_DIRECTORY."templates/comment_template.php"); } } - if ($pref['nested_comments']) + if ($pref['nested_comments']) { $width2 = 100 - $width; $total_width = "95%"; - if($width) + if ($width) { $renderstyle = " -
" .$COMMENTSTYLE. " + ".$COMMENTSTYLE."
"; - }else{ + } + else + { $renderstyle = $COMMENTSTYLE; } - if($pref['comments_icon']) { - if ($comrow['comment_datestamp'] > USERLV ) { + if ($pref['comments_icon']) + { + if ($comrow['comment_datestamp'] > USERLV) + { $NEWIMAGE = IMAGE_new_comments; - } else { + } + else + { $NEWIMAGE = IMAGE_nonew_comments; } - } else { + } + else + { $NEWIMAGE = ""; } - } else { + } + else + { $renderstyle = $COMMENTSTYLE; } - $highlight_search = FALSE; - if (isset($_POST['highlight_search'])) { + if (isset($_POST['highlight_search'])) + { $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']) ? "" : "")); } - 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']) ? "" : "")); } - 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']) ? "" : "")); } - - $RATING = ($addrating==TRUE && $comrow['user_id'] ? $rater->composerating($thistable, $thisid, FALSE, $comrow['user_id']) : ""); - - $text = $tp -> parseTemplate($renderstyle, TRUE, $comment_shortcodes); - - if ($action == "comment" && $pref['nested_comments']) + $RATING = ($addrating == TRUE && $comrow['user_id'] ? $rater->composerating($thistable, $thisid, FALSE, $comrow['user_id']) : ""); + $text = $tp->parseTemplate($renderstyle, TRUE, $comment_shortcodes); + if ($action == "comment" && $pref['nested_comments']) { - $type = $this -> getCommentType($thistable); + $type = $this->getCommentType($thistable); $sub_query = " SELECT c.*, u.*, ue.* FROM #comments AS c 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 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 "; - - $sql_nc = new db; /* a new db must be created here, for nested comment */ - if ($sub_total = $sql_nc->db_Select_gen($sub_query)) + $sql_nc = new db; /* a new db must be created here, for nested comment */ + if ($sub_total = $sql_nc->db_Select_gen($sub_query)) { - while ($row1 = $sql_nc->db_Fetch()) - { - if ($pref['nested_comments']) + while ($row1 = $sql_nc->db_Fetch()) { - $width = min($width + 3, 80); + if ($pref['nested_comments']) + { + $width = min($width + 3, 80); + } + $text .= $this->render_comment($row1, $table, $action, $id, $width, $subject, $addrating); + unset($width); } - $text .= $this->render_comment($row1, $table, $action, $id, $width, $subject, $addrating); - unset($width); - } } - } // End (nested comment handling) + } // End (nested comment handling) return $text; } - /** * Enter description here... * @@ -322,589 +330,554 @@ class comment { * @param unknown_type $subject * @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()) - global $sql, $sql2, $tp, $e107cache, $e_event, $e107, $pref, $rater; - - if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) + global $sql,$sql2,$tp,$e107cache,$e_event,$e107,$pref,$rater; + if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) { - return; + return; } - if (isset($_GET['comment']) && $_GET['comment'] == 'edit') { - $eaction = 'edit'; - $editpid = $_GET['comment_id']; + $eaction = 'edit'; + $editpid = $_GET['comment_id']; } elseif (strstr(e_QUERY, "edit")) { - $eaction = "edit"; - $tmp = explode(".", e_QUERY); - $count = 0; - foreach($tmp as $t) - { - if($t == "edit") + $eaction = "edit"; + $tmp = explode(".", e_QUERY); + $count = 0; + foreach ($tmp as $t) { - $editpid = $tmp[($count+1)]; - break; + if ($t == "edit") + { + $editpid = $tmp[($count + 1)]; + break; + } + $count++; } - $count++; - } } - - $type = $this -> getCommentType($table); - + $type = $this->getCommentType($table); $comment = $tp->toDB($comment); $subject = $tp->toDB($subject); $cuser_id = 0; - $cuser_name = 'Anonymous'; // Preset as an anonymous comment - if (!$sql->db_Select("comments", "*", "comment_comment='".$comment."' AND comment_item_id='".intval($id)."' AND comment_type='".$tp -> toDB($type, true)."' ")) + $cuser_name = 'Anonymous'; // Preset as an anonymous comment + if (!$sql->db_Select("comments", "*", "comment_comment='".$comment."' AND comment_item_id='".intval($id)."' AND comment_type='".$tp->toDB($type, true)."' ")) { - if ($_POST['comment']) - { - if (USER == TRUE) + if ($_POST['comment']) { - $cuser_id = USERID; - $cuser_name = USERNAME; - } - elseif($_POST['author_name'] != '') - { // See if author name is registered user - if ($sql2->db_Select("user", "*", "user_name='".$tp -> toDB($_POST['author_name'])."' ")) - { - if ($sql2->db_Select("user", "*", "user_name='".$tp -> toDB($_POST['author_name'])."' AND user_ip='".$tp -> toDB($ip, true)."' ")) + if (USER == TRUE) { - list($cuser_id, $cuser_name) = $sql2->db_Fetch(); - } - else - { - define("emessage", COMLAN_310); + $cuser_id = USERID; + $cuser_name = USERNAME; + } + elseif ($_POST['author_name'] != '') + { // See if author name is registered user + if ($sql2->db_Select("user", "*", "user_name='".$tp->toDB($_POST['author_name'])."' ")) + { + if ($sql2->db_Select("user", "*", "user_name='".$tp->toDB($_POST['author_name'])."' AND user_ip='".$tp->toDB($ip, true)."' ")) + { + list($cuser_id, $cuser_name) = $sql2->db_Fetch(); + } + else + { + define("emessage", COMLAN_310); + } + } + else + { // User not on-line, so can't be entering comments + $cuser_name = $tp->toDB($author_name); + } + } + if (!defined("emessage")) + { + $ip = $e107->getip(); // Store IP 'in the raw' - could be IPv4 or IPv6. Its always returned in a normalised form + $_t = time(); + if ($editpid) + { + $comment .= "\n[ ".COMLAN_319." [time=short]".time()."[/time] ]"; + $sql->db_Update("comments", "comment_comment='{$comment}' WHERE comment_id='".intval($editpid)."' "); + $e107cache->clear("comment"); + return; + } + $edata_li = array( + // comment_id - auto-assigned + 'comment_pid'=>intval($pid), "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_datestamp"=>$_t, "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", $edata_li)) + { + echo "".COMLAN_323." ".COMLAN_11; + } + else + { + if (USER == TRUE) + { + $sql->db_Update("user", "user_comments=user_comments+1, user_lastpost='".time()."' WHERE user_id='".USERID."' "); + } + // Next item for backward compatibility + $edata_li["comment_nick"] = $cuser_id.'.'.$cuser_name; + $edata_li["comment_time"] = $_t; + unset($edata_li['comment_pid']); + unset($edata_li['comment_author_email']); + 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); + $e_event->trigger("postcomment", $edata_li); + $e107cache->clear("comment"); + if (!$type || $type == "news") + { + $sql->db_Update("news", "news_comment_total=news_comment_total+1 WHERE news_id=".intval($id)); + } + } } - } - else - { // User not on-line, so can't be entering comments - $cuser_name = $tp->toDB($author_name); - } } - - if (!defined("emessage")) - { - $ip = $e107->getip(); // Store IP 'in the raw' - could be IPv4 or IPv6. Its always returned in a normalised form - $_t = time(); - - if($editpid) - { - $comment .= "\n[ ".COMLAN_319." [time=short]".time()."[/time] ]"; - $sql -> db_Update("comments", "comment_comment='{$comment}' WHERE comment_id='".intval($editpid)."' "); - $e107cache->clear("comment"); - return; - } - - $edata_li = array( - // comment_id - auto-assigned - 'comment_pid' => intval($pid), - "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_datestamp" => $_t, - "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", $edata_li)) - { - echo "".COMLAN_323." ".COMLAN_11; - } - else - { - if (USER == TRUE) - { - $sql -> db_Update("user", "user_comments=user_comments+1, user_lastpost='".time()."' WHERE user_id='".USERID."' "); - } - // Next item for backward compatibility - $edata_li["comment_nick"] = $cuser_id.'.'.$cuser_name; - $edata_li["comment_time"] = $_t; - unset($edata_li['comment_pid']); - unset($edata_li['comment_author_email']); - 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); - $e_event->trigger("postcomment", $edata_li); - $e107cache->clear("comment"); - if(!$type || $type == "news") - { - $sql->db_Update("news", "news_comment_total=news_comment_total+1 WHERE news_id=".intval($id)); - } - } - } - } } else { define("emessage", COMLAN_312); } //if rateindex is posted, enter the rating from this user - if($rateindex){ - $rater -> enterrating($rateindex); + if ($rateindex) + { + $rater->enterrating($rateindex); } - - if(defined("emessage")) + if (defined("emessage")) { message_handler("ALERT", emessage); } } - /** * Enter description here... * * @param unknown_type $table * @return unknown */ + + function getCommentType($table) { - if(is_numeric($table)) { return $table; } - - switch($table) - { - case "news" : $type = 0; break; - case "content" : $type = 1; break; - case "download" : $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; + if (is_numeric($table)) + { + return $table; + } + switch ($table) + { + case "news": + $type = 0; + break; + case "content": + $type = 1; + break; + case "download": + $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 ... - case "your_comment_type"; $type = your_type_id; break; - ****************************************/ + Add your comment type here in same format as above, ie ... + case "your_comment_type"; $type = your_type_id; break; + ****************************************/ } return $type; - } - - /** - * Enter description here... - * - * @param unknown_type $table - * @param unknown_type $id - * @return unknown - */ - function count_comments($table, $id) - { - global $sql, $tp; - $type = $this -> getCommentType($table); - $count_comments = $sql -> db_Count("comments", "(*)", "WHERE comment_item_id='".intval($id)."' AND comment_type='".$tp -> toDB($type, true)."' "); - return $count_comments; - } - - - /** - * Enter description here... - * - * @param unknown_type $table - the source table for the associated item - * @param unknown_type $action - usually 'comment' or 'reply' - * @param unknown_type $id - ID of item associated with comments (e.g. news ID) - * @param unknown_type $width - appears to not be used - * @param unknown_type $subject - * @param unknown_type $rate - */ - 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 - //rate : boolean, to show/hide rating system in comment, default FALSE - global $pref, $sql, $ns, $e107cache, $tp, $totcc; - - if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) - { - return; } + /** + * Enter description here... + * + * @param unknown_type $table + * @param unknown_type $id + * @return unknown + */ -// Query no longer used -// $count_comments = $this -> count_comments($table, $id, $pid=FALSE); - $type = $this -> getCommentType($table); - - $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_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" - : - "SELECT c.*, u.*, ue.* FROM #comments AS c - 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($id)."' AND c.comment_type='".$tp -> toDB($type, true)."' ORDER BY c.comment_datestamp"; - - $text = ""; - $comment = ''; - $modcomment = ''; - $lock = ''; - $ret['comment'] = ''; - - if ($comment_total = $sql->db_Select_gen($query)) + function count_comments($table, $id) { - $width = 0; - while ($row = $sql->db_Fetch()) - { - $lock = $row['comment_lock']; - // $subject = $tp->toHTML($subject); - if ($pref['nested_comments']) + global $sql,$tp; + $type = $this->getCommentType($table); + $count_comments = $sql->db_Count("comments", "(*)", "WHERE comment_item_id='".intval($id)."' AND comment_type='".$tp->toDB($type, true)."' "); + return $count_comments; + } + /** + * Enter description here... + * + * @param unknown_type $table - the source table for the associated item + * @param unknown_type $action - usually 'comment' or 'reply' + * @param unknown_type $id - ID of item associated with comments (e.g. news ID) + * @param unknown_type $width - appears to not be used + * @param unknown_type $subject + * @param unknown_type $rate + */ + + + 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 + //rate : boolean, to show/hide rating system in comment, default FALSE + global $pref,$sql,$ns,$e107cache,$tp,$totcc; + if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) { - $text .= $this->render_comment($row, $table , $action, $id, $width, $tp->toHTML($subject), $rate); + return; + } + // Query no longer used + // $count_comments = $this -> count_comments($table, $id, $pid=FALSE); + $type = $this->getCommentType($table); + $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_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" : "SELECT c.*, u.*, ue.* FROM #comments AS c + 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($id)."' AND c.comment_type='".$tp->toDB($type, true)."' ORDER BY c.comment_datestamp"; + $text = ""; + $comment = ''; + $modcomment = ''; + $lock = ''; + $ret['comment'] = ''; + if ($comment_total = $sql->db_Select_gen($query)) + { + $width = 0; + while ($row = $sql->db_Fetch()) + { + $lock = $row['comment_lock']; + // $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); + } + } + if ($tablerender) + { + $text = $ns->tablerender(COMLAN_99, $text, '', TRUE); + } + if (!$return) + { + echo $text; + } + else + { + $ret['comment'] = $text; + } + if (ADMIN && getperms("B")) + { + $modcomment = "
".COMLAN_314."

"; + } + } + if ($lock != "1") + { + $comment = $this->form_comment($action, $table, $id, $subject, "", TRUE, $rate, $tablerender); } else { - $text .= $this->render_comment($row, $table , $action, $id, $width, $tp->toHTML($subject), $rate); + $comment = "
".COMLAN_328."
"; } - } - - if ($tablerender) - { - $text = $ns->tablerender(COMLAN_99, $text, '', TRUE); - } - - if (!$return) - { - echo $text; - } - else - { - $ret['comment'] = $text; - } - - if (ADMIN && getperms("B")) - { - $modcomment = "
".COMLAN_314."

"; - } + if (!$return) + { + echo $modcomment.$comment; + } + $ret['comment'] .= $modcomment; + $ret['comment_form'] = $comment; + $ret['caption'] = COMLAN_99; + return (!$return) ? "" : $ret; } - if ($lock != "1") + + function recalc_user_comments($id) { - $comment = $this->form_comment($action, $table, $id, $subject, "", TRUE, $rate, $tablerender); - } - else - { - $comment = "
".COMLAN_328."
"; - } - - if (!$return) - { - echo $modcomment.$comment; - } - - $ret['comment'] .= $modcomment; - $ret['comment_form'] = $comment; - $ret['caption'] = COMLAN_99; - - return (!$return) ? "" : $ret; - } - - - - - function recalc_user_comments($id) - { - global $sql; - - if(is_array($id)) - { - foreach($id as $_id) - { - $this->recalc_user_comments($_id); - } - return; - } - $qry = " + global $sql; + if (is_array($id)) + { + foreach ($id as $_id) + { + $this->recalc_user_comments($_id); + } + return; + } + $qry = " SELECT COUNT(*) AS count FROM #comments WHERE comment_author_id = '{$id}' "; - if($sql->db_Select_gen($qry)) - { - $row = $sql->db_Fetch(); - $sql->db_Update("user","user_comments = '{$row['count']}' WHERE user_id = '{$id}'"); - } - } + if ($sql->db_Select_gen($qry)) + { + $row = $sql->db_Fetch(); + $sql->db_Update("user", "user_comments = '{$row['count']}' WHERE user_id = '{$id}'"); + } + } - - function get_author_list($id, $comment_type) - { - global $sql; - $authors = array(); - $qry = " + + function get_author_list($id, $comment_type) + { + global $sql; + $authors = array(); + $qry = " SELECT DISTINCT(comment_author_id) AS author FROM #comments WHERE comment_item_id='{$id}' AND comment_type='{$comment_type}' GROUP BY author "; - if($sql->db_Select_gen($qry)) - { - while($row = $sql->db_Fetch()) + if ($sql->db_Select_gen($qry)) { - $authors[] = $row['author']; - } - } - return $authors; - } - - - - function delete_comments($table, $id) - { - global $sql, $tp; - - $type = $this -> getCommentType($table); - $type = $tp -> toDB($type, true); - $id = intval($id); - $author_list = $this->get_author_list($id, $type); - $num_deleted = $sql -> db_Delete("comments", "comment_item_id='{$id}' AND comment_type='{$type}'"); - $this->recalc_user_comments($author_list); - return $num_deleted; - } - - - //1) call function getCommentData(); from file - //2) function-> get number of records from comments db - //3) get all e_comment.php files and collect the variables - //4) interchange the db rows and the e_ vars - //5) return the interchanged data in array - //6) from file: render the returned data - - //get all e_comment.php files and collect the variables - function get_e_comment() - { - $data = getcachedvars('e_comment'); - if($data!==FALSE) - { - return $data; - } - - require_once(e_HANDLER."file_class.php"); - $fl = new e_file; - - $omit = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$','.bak$'); - $files = $fl->get_files(e_PLUGIN, 'e_comment.php', $omit, 1, 0); - - foreach($files as $file){ - unset($e_comment, $key); - include($file['path'].$file['fname']); - if($e_comment && is_array($e_comment)){ - $key = $e_comment['eplug_comment_ids']; - if(isset($key) && $key!=''){ - $data[$key] = $e_comment; - } - }else{ - //convert old method variables into the same array method - $key = $e_plug_table; - if(isset($key) && $key!=''){ - $e_comment['eplug_comment_ids'] = $e_plug_table; - $e_comment['plugin_name'] = $plugin_name; - $e_comment['plugin_path'] = $plugin_path; - $e_comment['reply_location'] = $reply_location; - $e_comment['db_title'] = $link_name; - $e_comment['db_id'] = $db_id; - $e_comment['db_table'] = $db_table; - $e_comment['qry'] = ''; - $data[$key] = $e_comment; + while ($row = $sql->db_Fetch()) + { + $authors[] = $row['author']; } } + return $authors; } - cachevars('e_comment', $data); - return $data; - } - /* - * get number of records from comments db - * interchange the db rows and the e_comment vars - * return the interchanged data in array - * - * @param int $amount : holds numeric value for number of comments to ge - * @param int $from : holds numeric value from where to start retrieving - * @param string $qry : holds custom query to add in the comment retrieval - * next two parms are only used in iterating loop if less valid records are found - * @param int $cdvalid : number of valid records found - * @param array $cdreta : current data set - */ + function delete_comments($table, $id) + { + global $sql,$tp; + $type = $this->getCommentType($table); + $type = $tp->toDB($type, true); + $id = intval($id); + $author_list = $this->get_author_list($id, $type); + $num_deleted = $sql->db_Delete("comments", "comment_item_id='{$id}' AND comment_type='{$type}'"); + $this->recalc_user_comments($author_list); + return $num_deleted; + } + //1) call function getCommentData(); from file + //2) function-> get number of records from comments db + //3) get all e_comment.php files and collect the variables + //4) interchange the db rows and the e_ vars + //5) return the interchanged data in array + //6) from file: render the returned data + //get all e_comment.php files and collect the variables - function getCommentData($amount='', $from='', $qry='', $cdvalid=FALSE, $cdreta=FALSE) - { - global $pref, $menu_pref, $sql, $sql2, $tp; - $from1 = ($from ? $from : '0'); - $amount1 = ($amount ? $amount : '10'); - $valid = ($cdvalid ? $cdvalid : '0'); - $reta = ($cdreta ? $cdreta : array()); - - //get all e_comment data - $e_comment = $this->get_e_comment(); - - $qry1 = ($qry ? " AND ".$qry : ""); - - //get 'amount' of records from comment db + function get_e_comment() + { + $data = getcachedvars('e_comment'); + if ($data !== FALSE) + { + return $data; + } + + $files = e107::getPref('e_comment_list'); + + foreach ($files as $file=>$perms) + { + unset($e_comment, $key); + include (e_PLUGIN.$file."/e_comment.php"); + if ($e_comment && is_array($e_comment)) + { + $key = $e_comment['eplug_comment_ids']; + if (isset($key) && $key != '') + { + $data[$key] = $e_comment; + } + } + else + { + //convert old method variables into the same array method + $key = $e_plug_table; + if (isset($key) && $key != '') + { + $e_comment['eplug_comment_ids'] = $e_plug_table; + $e_comment['plugin_name'] = $plugin_name; + $e_comment['plugin_path'] = $plugin_path; + $e_comment['reply_location'] = $reply_location; + $e_comment['db_title'] = $link_name; + $e_comment['db_id'] = $db_id; + $e_comment['db_table'] = $db_table; + $e_comment['qry'] = ''; + $data[$key] = $e_comment; + } + } + } + cachevars('e_comment', $data); + return $data; + } /* - $query = $pref['nested_comments'] ? - "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_pid='0' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." " - : - "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_id!='' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." "; - */ + * get number of records from comments db + * interchange the db rows and the e_comment vars + * return the interchanged data in array + * + * @param int $amount : holds numeric value for number of comments to ge + * @param int $from : holds numeric value from where to start retrieving + * @param string $qry : holds custom query to add in the comment retrieval + * next two parms are only used in iterating loop if less valid records are found + * @param int $cdvalid : number of valid records found + * @param array $cdreta : current data set + */ - $query = " + + function getCommentData($amount = '', $from = '', $qry = '', $cdvalid = FALSE, $cdreta = FALSE) + { + global $pref,$menu_pref,$sql,$sql2,$tp; + $from1 = ($from ? $from : '0'); + $amount1 = ($amount ? $amount : '10'); + $valid = ($cdvalid ? $cdvalid : '0'); + $reta = ($cdreta ? $cdreta : array()); + //get all e_comment data + $e_comment = $this->get_e_comment(); + $qry1 = ($qry ? " AND ".$qry : ""); + //get 'amount' of records from comment db + /* + $query = $pref['nested_comments'] ? + "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_pid='0' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." " + : + "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_id!='' ".$qry1." ORDER BY c.comment_datestamp DESC LIMIT ".intval($from1).",".intval($amount1)." "; + */ + $query = " SELECT c.*, u.*, ue.* FROM #comments AS c 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_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)) - { - $width = 0; - while ($row = $sql->db_Fetch()) - { - $ret = array(); - - //date - $ret['comment_datestamp'] = $row['comment_datestamp']; - - //author - no ned to split now - $comment_author_id = $row['comment_author_id']; - $comment_author_name = $row['comment_author_name']; - $ret['comment_author'] = (USERID ? "".$comment_author_name."" : $comment_author_name); - - //comment text - $comment = strip_tags(preg_replace("/\[.*\]/", "", $row['comment_comment'])); // remove bbcode - $ret['comment_comment'] = $tp->toHTML($comment, FALSE, "", "", $pref['main_wordwrap']); - - //subject - $ret['comment_subject'] = $tp->toHTML($row['comment_subject'], TRUE); - - switch ($row['comment_type']) + if ($comment_total = $sql->db_Select_gen($query)) { - case '0' : // news - if($sql2 -> db_Select("news", "*", "news_id='".$row['comment_item_id']."' AND news_class REGEXP '".e_CLASS_REGEXP."' ")) + $width = 0; + while ($row = $sql->db_Fetch()) + { + $ret = array(); + //date + $ret['comment_datestamp'] = $row['comment_datestamp']; + //author - no ned to split now + $comment_author_id = $row['comment_author_id']; + $comment_author_name = $row['comment_author_name']; + $ret['comment_author'] = (USERID ? "".$comment_author_name."" : $comment_author_name); + //comment text + $comment = strip_tags(preg_replace("/\[.*\]/", "", $row['comment_comment'])); // remove bbcode + $ret['comment_comment'] = $tp->toHTML($comment, FALSE, "", "", $pref['main_wordwrap']); + //subject + $ret['comment_subject'] = $tp->toHTML($row['comment_subject'], TRUE); + switch ($row['comment_type']) { - $row2 = $sql2 -> db_Fetch(); - - $ret['comment_type'] = COMLAN_TYPE_1; - $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_category_heading'] = COMLAN_TYPE_1; - $ret['comment_category_url'] = e_HTTP."news.php"; - } - break; - - case '1' : // article, review or content page - defunct category, but filter them out - break; - - 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."' "; - if($sql2->db_Select_gen($qryd)) - { - $row2 = $sql2->db_Fetch(); - - $ret['comment_type'] = COMLAN_TYPE_2; - $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_category_heading'] = $row2['download_category_name']; - $ret['comment_category_url'] = e_HTTP."download.php?list.".$row2['download_category_id']; - } - break; - // '3' was FAQ - case '4' : // poll - if($sql2 -> db_Select("polls", "*", "poll_id='".$row['comment_item_id']."' ")) - { - $row2 = $sql2 -> db_Fetch(); - - $ret['comment_type'] = COMLAN_TYPE_4; - $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_category_url'] = e_PLUGIN_ABS.'poll/poll.php'; - } - break; - - // '5' was docs - // '6' was bugtracker - // 'ideas' was implemented - - case 'profile' : // userprofile - if(USER) - { - $ret['comment_type'] = COMLAN_TYPE_8; - $ret['comment_title'] = $comment_author_name; - $ret['comment_url'] = e_HTTP."user.php?id.".$row['comment_item_id']; - } - break; - - case 'page' : // Custom Page - $ret['comment_type'] = COMLAN_TYPE_PAGE; - $ret['comment_title'] = $ret['comment_subject'] ? $ret['comment_subject'] : $ret['comment_comment']; - $ret['comment_url'] = e_HTTP."page.php?".$row['comment_item_id']; - break; - - default : - if(isset($e_comment[$row['comment_type']]) && is_array($e_comment[$row['comment_type']])) - { - $var = $e_comment[$row['comment_type']]; - $qryp=''; - //new method must use the 'qry' variable - if(isset($var) && $var['qry']!='') - { - if ($installed = isset($pref['plug_installed'][$var['plugin_path']])) - { - $qryp = str_replace("{NID}", $row['comment_item_id'], $var['qry']); - if($sql2 -> db_Select_gen($qryp)) + case '0': // news + if ($sql2->db_Select("news", "*", "news_id='".$row['comment_item_id']."' AND news_class REGEXP '".e_CLASS_REGEXP."' ")) { - $row2 = $sql2 -> db_Fetch(); - $ret['comment_type'] = $var['plugin_name']; - $ret['comment_title'] = $tp -> toHTML($row2[$var['db_title']], TRUE,'emotes_off, no_make_clickable'); - $ret['comment_url'] = str_replace("{NID}", $row['comment_item_id'], $var['reply_location']); - $ret['comment_category_heading'] = $var['plugin_name']; - $ret['comment_category_url'] = e_PLUGIN_ABS.$var['plugin_name'].'/'.$var['plugin_name'].'.php'; + $row2 = $sql2->db_Fetch(); + $ret['comment_type'] = COMLAN_TYPE_1; + $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_category_heading'] = COMLAN_TYPE_1; + $ret['comment_category_url'] = e_HTTP."news.php"; } - } - //old method - } - else - { - if($sql2 -> db_Select($var['db_table'], $var['db_title'], $var['db_id']." = '".$row['comment_item_id']."' ")) + break; + case '1': // article, review or content page - defunct category, but filter them out + break; + 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."' "; + if ($sql2->db_Select_gen($qryd)) + { + $row2 = $sql2->db_Fetch(); + $ret['comment_type'] = COMLAN_TYPE_2; + $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_category_heading'] = $row2['download_category_name']; + $ret['comment_category_url'] = e_HTTP."download.php?list.".$row2['download_category_id']; + } + break; + // '3' was FAQ + case '4': // poll + if ($sql2->db_Select("polls", "*", "poll_id='".$row['comment_item_id']."' ")) + { + $row2 = $sql2->db_Fetch(); + $ret['comment_type'] = COMLAN_TYPE_4; + $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_category_url'] = e_PLUGIN_ABS.'poll/poll.php'; + } + break; + // '5' was docs + // '6' was bugtracker + // 'ideas' was implemented + case 'profile': // userprofile + if (USER) + { + $ret['comment_type'] = COMLAN_TYPE_8; + $ret['comment_title'] = $comment_author_name; + $ret['comment_url'] = e_HTTP."user.php?id.".$row['comment_item_id']; + } + break; + case 'page': // Custom Page + $ret['comment_type'] = COMLAN_TYPE_PAGE; + $ret['comment_title'] = $ret['comment_subject'] ? $ret['comment_subject']: + $ret['comment_comment']; + $ret['comment_url'] = e_HTTP."page.php?".$row['comment_item_id']; + break; + default: + if (isset($e_comment[$row['comment_type']]) && is_array($e_comment[$row['comment_type']])) + { + $var = $e_comment[$row['comment_type']]; + $qryp = ''; + //new method must use the 'qry' variable + if (isset($var) && $var['qry'] != '') + { + if ($installed = isset($pref['plug_installed'][$var['plugin_path']])) + { + $qryp = str_replace("{NID}", $row['comment_item_id'], $var['qry']); + if ($sql2->db_Select_gen($qryp)) + { + $row2 = $sql2->db_Fetch(); + $ret['comment_type'] = $var['plugin_name']; + $ret['comment_title'] = $tp->toHTML($row2[$var['db_title']], TRUE, 'emotes_off, no_make_clickable'); + $ret['comment_url'] = str_replace("{NID}", $row['comment_item_id'], $var['reply_location']); + $ret['comment_category_heading'] = $var['plugin_name']; + $ret['comment_category_url'] = e_PLUGIN_ABS.$var['plugin_name'].'/'.$var['plugin_name'].'.php'; + } + } + //old method + } + else + { + if ($sql2->db_Select($var['db_table'], $var['db_title'], $var['db_id']." = '".$row['comment_item_id']."' ")) + { + $row2 = $sql2->db_Fetch(); + $ret['comment_type'] = $var['plugin_name']; + $ret['comment_title'] = $tp->toHTML($row2[$var['db_title']], TRUE, 'emotes_off, no_make_clickable'); + $ret['comment_url'] = str_replace("{NID}", $row['comment_item_id'], $var['reply_location']); + $ret['comment_category_heading'] = $var['plugin_name']; + $ret['comment_category_url'] = e_PLUGIN_ABS.$var['plugin_name'].'/'.$var['plugin_name'].'.php'; + } + } + } + } // End Switch + if ($ret['comment_title']) { - $row2 = $sql2 -> db_Fetch(); - $ret['comment_type'] = $var['plugin_name']; - $ret['comment_title'] = $tp -> toHTML($row2[$var['db_title']], TRUE,'emotes_off, no_make_clickable'); - $ret['comment_url'] = str_replace("{NID}", $row['comment_item_id'], $var['reply_location']); - $ret['comment_category_heading'] = $var['plugin_name']; - $ret['comment_category_url'] = e_PLUGIN_ABS.$var['plugin_name'].'/'.$var['plugin_name'].'.php'; + $reta[] = $ret; + $valid++; + } + if ($amount && $valid >= $amount) + { + return $reta; } - } } - } // End Switch - if($ret['comment_title']) - { - $reta[] = $ret; - $valid++; + //loop if less records found than given $amount - probably because we discarded some + if ($amount && ($valid < $amount)) + { + $reta = $this->getCommentData($amount, $from + $amount, $qry, $valid, $reta); + } + } + return $reta; } - if($amount && $valid>=$amount) - { - return $reta; - } - } - //loop if less records found than given $amount - probably because we discarded some - if($amount && ($valid<$amount)) - { - $reta = $this->getCommentData($amount, $from+$amount, $qry, $valid, $reta); - } - } - return $reta; - } - -} //end class - -?> \ No newline at end of file + } //end class + +?>