Index: karma.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/karma/karma.module,v retrieving revision 1.20 diff -u -r1.20 karma.module --- karma.module 26 May 2006 21:49:25 -0000 1.20 +++ karma.module 23 Oct 2006 05:05:59 -0000 @@ -366,6 +366,11 @@ function karma_comment_ratings_page($cid) { $comment = db_fetch_object(db_query('SELECT n.nid, c.cid, c.subject, n.title AS node_title FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid WHERE c.cid = %d', $cid)); + if(!$comment->cid) { + drupal_not_found(); + exit; + } + menu_set_location(array( array('path' => 'node/'. $comment->nid, 'title' => $comment->node_title), array('path' => 'karma/'. $comment->cid, 'title' => t('Ratings for %subject', array('%subject' => $comment->subject))), @@ -380,8 +385,8 @@ } $header = array(t('User'), t('Rating')); $output = theme('table', $header, $rows); - - $output .= '
'. t('Average rating: %average', array('%average' => $rating_sum / db_num_rows($ratings))) .'
'; + $rows = db_num_rows($ratings); + $output .= ''. t('Average rating: %average', array('%average' => ($rows ? ($rating_sum / $rows) : '0' ))) .'
'; $output .= theme('links', array(l(t('Back to %title', array('%title' => theme('placeholder', $comment->node_title))), 'node/'. $comment->nid, array(), NULL, 'comment-'. $comment->cid, FALSE, TRUE)));