blog = $blog; if( !empty($posts) ) $this->posts_per_page = $posts; else $this->posts_per_page = $default_posts_per_page; if( $group_by_post ) $this->request = "SELECT DISTINCT count(*) num_comm, comment_post_ID, max(comment_date) comment_date, ID, post_title "; else $this->request = "SELECT DISTINCT $tablecomments.* "; $this->request .= "FROM (($tablecomments INNER JOIN $tableposts ON comment_post_ID = ID) "; if( !empty( $p ) ) { // Restrict to comments on selected post $this->request .= ") WHERE comment_post_ID = $p AND "; } elseif( $blog > 1 ) { // Restrict to viewable posts/cats on current blog $this->request .= "INNER JOIN $tablepostcats ON ID = postcat_post_ID) INNER JOIN $tablecategories othercats ON postcat_cat_ID = othercats.cat_ID WHERE othercats.cat_blog_ID = $blog AND "; } else { // This is blog 1, we don't care, we can include all comments: $this->request .= ') WHERE '; } $this->request .= "comment_type IN ($comment_types) "; /* * ---------------------------------------------------- * Restrict to the statuses we want to show: * ---------------------------------------------------- */ $this->request .= ' AND '.statuses_where_clause( $show_statuses ); if( $group_by_post ) { $this->request .= " GROUP BY $tablecomments.comment_post_ID "; } // order by stuff if( (!empty($order)) && ((strtoupper($order) != 'ASC') && (strtoupper($order) != 'DESC'))) { $order='DESC'; } if(empty($orderby)) { $orderby='comment_date '.$order; } else { $orderby_array = explode(' ',$orderby); $orderby = $orderby_array[0].' '.$order; if (count($orderby_array)>1) { for($i = 1; $i < (count($orderby_array)); $i++) { $orderby .= ', comment_'.$orderby_array[$i].' '.$order; } } } $this->request .= "ORDER BY $orderby"; if( $this->posts_per_page ) $this->request .= " LIMIT $this->posts_per_page"; // echo $this->request; $this->result = $DB->get_results( $this->request, ARRAY_A ); if( $this->result_num_rows = $DB->num_rows ) { foreach( $this->result as $row ) { $this->Obj[] = & new Comment( $row ); } } } /** * Template function: display message if list is empty * * {@internal Comment::display_if_empty(-) }} * * @param string String to display if list is empty * @return true if empty */ function display_if_empty( $message = '' ) { if( empty($message) ) { // Default message: $message = T_('No comment yet...'); } return parent::display_if_empty( $message ); } } ?>