From 8eed5abd866db72a45a5050d696a48bb7a8be2da Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Mon, 28 Oct 2002 19:36:37 +0000 Subject: - Fixing blocks for forum, queue and statistics. --- modules/forum/forum.module | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'modules/forum/forum.module') diff --git a/modules/forum/forum.module b/modules/forum/forum.module index c18b13fa0..0d1fbf6f6 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -85,30 +85,42 @@ function forum_load($node) { return $forum; } -function forum_block() { - if (user_access("access content")) { - $content .= "". t("Active forum topics:") ."
"; - $result = db_query("SELECT n.nid, n.title, n.body, GREATEST(n.created, MAX(c.timestamp)) AS sort FROM node n, forum f LEFT JOIN comments c ON c.nid = n.nid WHERE n.type = 'forum' AND n.nid = f.nid AND f.shadow = 0 AND n.status = 1 GROUP BY n.nid ORDER BY sort DESC LIMIT ". variable_get("forum_block_num", "5")); - while ($node = db_fetch_object($result)) { - $content .= "- ".l(check_output($node->title), array("id" => $node->nid), "node", "", array("title" => substr(strip_tags($node->body), 0, 100)."...")) ."
"; - } +function forum_block($op = "list", $delta = 0) { + if ($op == "list") { + $blocks[0]["info"] = t("Forum topics"); + } + else { + if (user_access("access content")) { + if (variable_get("forum_cache", 0)) { + $content = cache_get("forum:block"); + } + + if (!$content) { + $content = "". t("Active forum topics:") ."
"; + $result = db_query("SELECT n.nid, n.title, n.body, GREATEST(n.created, MAX(c.timestamp)) AS sort FROM node n, forum f LEFT JOIN comments c ON c.nid = n.nid WHERE n.type = 'forum' AND n.nid = f.nid AND f.shadow = 0 AND n.status = 1 GROUP BY n.nid ORDER BY sort DESC LIMIT ". variable_get("forum_block_num", "5")); + while ($node = db_fetch_object($result)) { + $content .= "- ". l(check_output($node->title), array("id" => $node->nid), "node", "", array("title" => substr(strip_tags($node->body), 0, 100)."...")) ."
"; + } - $content .= "
"; - $content .= "". t("New forum topics:") ."
"; - $result = db_query("SELECT n.nid, n.title, n.body FROM node n LEFT JOIN forum f ON n.nid = f.nid WHERE n.type = 'forum' ORDER BY n.nid DESC LIMIT ". variable_get("forum_block_num", "5")); - while ($node = db_fetch_object($result)) { - $content .= "- ".l(check_output($node->title), array("id" => $node->nid), "node", "", array("title" => substr(strip_tags($node->body), 0, 100)."...")) ."
"; - } + $content .= "
"; + $content .= "". t("New forum topics:") ."
"; + $result = db_query("SELECT n.nid, n.title, n.body FROM node n LEFT JOIN forum f ON n.nid = f.nid WHERE n.type = 'forum' ORDER BY n.nid DESC LIMIT ". variable_get("forum_block_num", "5")); + while ($node = db_fetch_object($result)) { + $content .= "- ". l(check_output($node->title), array("id" => $node->nid), "node", "", array("title" => substr(strip_tags($node->body), 0, 100)."...")) ."
"; + } + + if ($content) { + $content .= "
". lm(t("more"), array("mod" => "forum")) ."
"; + } + + cache_set("forum:block", $content, time() + 60 * 3); + } - if ($content) { - $content .= "
". lm(t("more"), array("mod" => "forum"))."
"; + $blocks["subject"] = t("Forum topics"); + $blocks["content"] = $content; } } - $blocks[0][subject] = t("Forum topics"); - $blocks[0][content] = $content; - $blocks[0][info] = t("Forum topics"); - return $blocks; } @@ -156,10 +168,6 @@ function forum_link($type, $node) { } } - if ($type == "admin" && user_access("administer site configuration")) { - $links[] = la(t("forum"), array("mod" => "forum")); - } - return $links ? $links : array(); } @@ -321,6 +329,7 @@ function forum_get_forums($tid = 0) { } if (!$forums) { + $forums = array(); taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $_forums, $tid); $n = 0; foreach ($_forums as $forum) { @@ -761,4 +770,4 @@ You may use images of whatever size you wish, but it is customary to use 15x15 o +?> \ No newline at end of file -- cgit v1.2.3