function comment_block($op = 'list', $delta = 0) { global $user; if ($op == 'list') { $blocks[0]['info'] = t('Forum topics'); } else { if (user_access('access content')) { $result = db_query_range('SELECT c.subject as subject, c.nid as nid, n.nid as spork, n.type as type, n.title as title, c.cid as cid, c.timestamp as timestamp FROM {comments} c,{node} n WHERE c.status = 0 AND c.nid = n.nid ORDER BY c.timestamp DESC', 0, 20); if (empty($comments_per_page)) { $comments_per_page = $user->comments_per_page ? $user->comments_per_page : ($_SESSION['comment_comments_per_page'] ? $_SESSION['comment_comments_per_page'] : variable_get('comment_default_per_page', '50')); } if (empty($order)) { $order = $user->sort ? $user->sort : ($_SESSION['comment_sort'] ? $_SESSION['comment_sort'] : variable_get('comment_default_order', 1)); } $i=0; $bork=null; $items = array(); while ($comment = db_fetch_object($result)) { $all = comment_num_all($comment->nid); $numpages = floor($all/$comments_per_page); $frompage = ($numpages * $comments_per_page); if($frompage == $all){ $frompage = $frompage-10; } if($frompage < 0){ $frompage = 0; } /* jasper end */ if($bork != $comment->subject && $i<10){ $items[] = l( strip_tags($comment->subject), 'node/'. $comment->nid.'?from='.$frompage.'&comments_per_page='.$comments_per_page, NULL, NULL, 'comment-'. $comment->cid) .'
'. t('%time ago', array('%time' => format_interval(time() - $comment->timestamp))); $i++; $bork = $comment->subject; } } $content .= theme('item_list', $items); $blocks['subject'] = t('Recent Comments'); $blocks['content'] = $content; } } return $blocks; }