summaryrefslogtreecommitdiff
path: root/modules/story/story.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/story/story.module')
-rw-r--r--modules/story/story.module27
1 files changed, 25 insertions, 2 deletions
diff --git a/modules/story/story.module b/modules/story/story.module
index 42707168c..27317440e 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -1,6 +1,29 @@
<?
-$module = array("admin" => "story_admin");
+$module = array("block" => "story_block",
+ "admin" => "story_admin");
+
+function story_block() {
+ $result = db_query("select s.id, COUNT(s.id) as comments, s.subject from stories s left join comments c on s.id = c.sid WHERE s.status = 2 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
+ while ($story = db_fetch_object($result)) {
+ $content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
+ }
+
+ $blocks[0]["subject"] = "Top 10:<BR>all stories";
+ $blocks[0]["content"] = $content;
+ $blocks[0]["info"] = "Top 10: all stories";
+
+ $result = db_query("select s.id, COUNT(s.id) as comments, s.subject from stories s left join comments c on s.id = c.sid WHERE s.status = 2 AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
+ while ($story = db_fetch_object($result)) {
+ $content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
+ }
+
+ $blocks[1]["subject"] = "Top 10:<BR>recent stories";
+ $blocks[1]["content"] = $content;
+ $blocks[1]["info"] = "Top 10: recent stories";
+
+ return $blocks;
+}
function story_edit($id) {
global $categories;
@@ -124,4 +147,4 @@ function story_admin() {
}
}
-?> \ No newline at end of file
+?>