- Fixing blocks for forum, queue and statistics.

4.1.x
Kjartan Mannes 2002-10-28 19:36:37 +00:00
parent acd0cb0607
commit 8eed5abd86
5 changed files with 130 additions and 86 deletions

View File

@ -85,9 +85,18 @@ function forum_load($node) {
return $forum; return $forum;
} }
function forum_block() { function forum_block($op = "list", $delta = 0) {
if ($op == "list") {
$blocks[0]["info"] = t("Forum topics");
}
else {
if (user_access("access content")) { if (user_access("access content")) {
$content .= "<b>". t("Active forum topics:") ."</b><br />"; 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")); $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)) { 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 .= "- ". l(check_output($node->title), array("id" => $node->nid), "node", "", array("title" => substr(strip_tags($node->body), 0, 100)."...")) ."<br />";
@ -103,11 +112,14 @@ function forum_block() {
if ($content) { if ($content) {
$content .= "<div align=\"right\">". lm(t("more"), array("mod" => "forum")) ."</div>"; $content .= "<div align=\"right\">". lm(t("more"), array("mod" => "forum")) ."</div>";
} }
cache_set("forum:block", $content, time() + 60 * 3);
} }
$blocks[0][subject] = t("Forum topics"); $blocks["subject"] = t("Forum topics");
$blocks[0][content] = $content; $blocks["content"] = $content;
$blocks[0][info] = t("Forum topics"); }
}
return $blocks; 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(); return $links ? $links : array();
} }
@ -321,6 +329,7 @@ function forum_get_forums($tid = 0) {
} }
if (!$forums) { if (!$forums) {
$forums = array();
taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $_forums, $tid); taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $_forums, $tid);
$n = 0; $n = 0;
foreach ($_forums as $forum) { foreach ($_forums as $forum) {

View File

@ -85,9 +85,18 @@ function forum_load($node) {
return $forum; return $forum;
} }
function forum_block() { function forum_block($op = "list", $delta = 0) {
if ($op == "list") {
$blocks[0]["info"] = t("Forum topics");
}
else {
if (user_access("access content")) { if (user_access("access content")) {
$content .= "<b>". t("Active forum topics:") ."</b><br />"; 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")); $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)) { 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 .= "- ". l(check_output($node->title), array("id" => $node->nid), "node", "", array("title" => substr(strip_tags($node->body), 0, 100)."...")) ."<br />";
@ -103,11 +112,14 @@ function forum_block() {
if ($content) { if ($content) {
$content .= "<div align=\"right\">". lm(t("more"), array("mod" => "forum")) ."</div>"; $content .= "<div align=\"right\">". lm(t("more"), array("mod" => "forum")) ."</div>";
} }
cache_set("forum:block", $content, time() + 60 * 3);
} }
$blocks[0][subject] = t("Forum topics"); $blocks["subject"] = t("Forum topics");
$blocks[0][content] = $content; $blocks["content"] = $content;
$blocks[0][info] = t("Forum topics"); }
}
return $blocks; 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(); return $links ? $links : array();
} }
@ -321,6 +329,7 @@ function forum_get_forums($tid = 0) {
} }
if (!$forums) { if (!$forums) {
$forums = array();
taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $_forums, $tid); taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $_forums, $tid);
$n = 0; $n = 0;
foreach ($_forums as $forum) { foreach ($_forums as $forum) {

View File

@ -178,7 +178,12 @@ function queue_page() {
} }
} }
function queue_block() { function queue_block($op = "list", $delta = 0) {
if ($op == "list") {
$blocks[0]["info"] = t("Moderation results");
return $blocks;
}
else {
if (user_access("access submission queue") && (substr_count(request_uri(), drupal_url(array("mod" => "queue"), "module")) || substr_count(request_uri(), drupal_url()))) { if (user_access("access submission queue") && (substr_count(request_uri(), drupal_url(array("mod" => "queue"), "module")) || substr_count(request_uri(), drupal_url()))) {
global $user, $id; global $user, $id;
if ($user->uid) { if ($user->uid) {
@ -205,5 +210,6 @@ function queue_block() {
return $block; return $block;
} }
}
?> ?>

View File

@ -839,18 +839,28 @@ function statistics_get($nid) {
/* Block hook */ /* Block hook */
function statistics_block() { function statistics_block($op = "list", $delta = 0) {
if ($op == "list") {
$blocks[0]["info"] = t("Top nodes");
$blocks[1]["info"] = t("Who's online");
return $blocks;
}
else {
switch($op) {
case 0:
$block["subject"] = variable_get("statistics_block_top_title", "Popular content");
$block["content"] = statistics_display_topnodes_block();
break;
$block[0]["subject"] = variable_get("statistics_block_top_title", "Popular content"); case 1:
$block[0]["content"] = statistics_display_topnodes_block(); $block["subject"] = variable_get("statistics_block_online_title", "Who's online");
$block[0]["info"] = "Top nodes"; $block["content"] = statistics_display_online_block();
break;
$block[1]["subject"] = variable_get("statistics_block_online_title", "Who's online"); }
$block[1]["content"] = statistics_display_online_block();
$block[1]["info"] = "Who's online";
return $block; return $block;
} }
}
function statistics_page() { function statistics_page() {

View File

@ -839,18 +839,28 @@ function statistics_get($nid) {
/* Block hook */ /* Block hook */
function statistics_block() { function statistics_block($op = "list", $delta = 0) {
if ($op == "list") {
$blocks[0]["info"] = t("Top nodes");
$blocks[1]["info"] = t("Who's online");
return $blocks;
}
else {
switch($op) {
case 0:
$block["subject"] = variable_get("statistics_block_top_title", "Popular content");
$block["content"] = statistics_display_topnodes_block();
break;
$block[0]["subject"] = variable_get("statistics_block_top_title", "Popular content"); case 1:
$block[0]["content"] = statistics_display_topnodes_block(); $block["subject"] = variable_get("statistics_block_online_title", "Who's online");
$block[0]["info"] = "Top nodes"; $block["content"] = statistics_display_online_block();
break;
$block[1]["subject"] = variable_get("statistics_block_online_title", "Who's online"); }
$block[1]["content"] = statistics_display_online_block();
$block[1]["info"] = "Who's online";
return $block; return $block;
} }
}
function statistics_page() { function statistics_page() {