summaryrefslogtreecommitdiff
path: root/modules/forum/forum.module
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2002-10-28 19:36:37 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2002-10-28 19:36:37 +0000
commit8eed5abd866db72a45a5050d696a48bb7a8be2da (patch)
treefd0a5aae06bd1d9073a2e86545f7e598b509bd75 /modules/forum/forum.module
parentacd0cb0607665a10a3dc2b6183933b6be7835f1f (diff)
downloadbrdo-8eed5abd866db72a45a5050d696a48bb7a8be2da.tar.gz
brdo-8eed5abd866db72a45a5050d696a48bb7a8be2da.tar.bz2
- Fixing blocks for forum, queue and statistics.
Diffstat (limited to 'modules/forum/forum.module')
-rw-r--r--modules/forum/forum.module57
1 files changed, 33 insertions, 24 deletions
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 .= "<b>". t("Active forum topics:") ."</b><br />";
- $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)."...")) ."<br />";
- }
+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 = "<b>". t("Active forum topics:") ."</b><br />";
+ $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)."...")) ."<br />";
+ }
- $content .= "<br />";
- $content .= "<b>". t("New forum topics:") ."</b><br />";
- $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)."...")) ."<br />";
- }
+ $content .= "<br />";
+ $content .= "<b>". t("New forum topics:") ."</b><br />";
+ $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)."...")) ."<br />";
+ }
+
+ if ($content) {
+ $content .= "<div align=\"right\">". lm(t("more"), array("mod" => "forum")) ."</div>";
+ }
+
+ cache_set("forum:block", $content, time() + 60 * 3);
+ }
- if ($content) {
- $content .= "<div align=\"right\">". lm(t("more"), array("mod" => "forum"))."</div>";
+ $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
<?php
}
-?>
+?> \ No newline at end of file