Commit 8eed5abd authored by Kjartan's avatar Kjartan

- Fixing blocks for forum, queue and statistics.

parent acd0cb06
......@@ -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 @@ function forum_help() {
<?php
}
?>
?>
\ No newline at end of file
......@@ -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 @@ function forum_help() {
<?php
}
?>
?>
\ No newline at end of file
......@@ -178,32 +178,38 @@ function queue_page() {
}
}
function queue_block() {
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;
if ($user->uid) {
$node = node_load(array("nid" => $id));
}
if (($user->uid == $node->uid || field_get($node->users, $user->uid)) && $node->moderate == 1) {
foreach (explode(",", $node->users) as $vote) {
if ($vote) {
$data = explode("=", $vote);
$account = user_load(array("uid" => $data[0]));
$output .= format_name($account) ." voted '$data[1]'.<br />";
}
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()))) {
global $user, $id;
if ($user->uid) {
$node = node_load(array("nid" => $id));
}
if (($user->uid == $node->uid || field_get($node->users, $user->uid)) && $node->moderate == 1) {
foreach (explode(",", $node->users) as $vote) {
if ($vote) {
$data = explode("=", $vote);
$account = user_load(array("uid" => $data[0]));
$output .= format_name($account) ." voted '$data[1]'.<br />";
}
}
$block[0]["subject"] = t("Moderation results");
$block[0]["content"] = $output ? $output : t("This node has not been moderated yet.");
$block[0]["info"] = t("Moderation results");
}
}
elseif ((user_access("access submission queue") || user_access("administer blocks")) && (substr_count(request_uri(), drupal_url(array("mod" => "user"), "module")) || substr_count(request_uri(), drupal_url(array(), "admin")))) {
$block[0]["subject"] = t("Moderation results");
$block[0]["content"] = $output ? $output : t("This node has not been moderated yet.");
$block[0]["info"] = t("Moderation results");
}
}
elseif ((user_access("access submission queue") || user_access("administer blocks")) && (substr_count(request_uri(), drupal_url(array("mod" => "user"), "module")) || substr_count(request_uri(), drupal_url(array(), "admin")))) {
$block[0]["subject"] = t("Moderation results");
$block[0]["info"] = t("Moderation results");
}
return $block;
return $block;
}
}
?>
......@@ -839,17 +839,27 @@ function statistics_get($nid) {
/* Block hook */
function statistics_block() {
$block[0]["subject"] = variable_get("statistics_block_top_title", "Popular content");
$block[0]["content"] = statistics_display_topnodes_block();
$block[0]["info"] = "Top nodes";
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[1]["subject"] = variable_get("statistics_block_online_title", "Who's online");
$block[1]["content"] = statistics_display_online_block();
$block[1]["info"] = "Who's online";
case 1:
$block["subject"] = variable_get("statistics_block_online_title", "Who's online");
$block["content"] = statistics_display_online_block();
break;
}
return $block;
return $block;
}
}
......
......@@ -839,17 +839,27 @@ function statistics_get($nid) {
/* Block hook */
function statistics_block() {
$block[0]["subject"] = variable_get("statistics_block_top_title", "Popular content");
$block[0]["content"] = statistics_display_topnodes_block();
$block[0]["info"] = "Top nodes";
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[1]["subject"] = variable_get("statistics_block_online_title", "Who's online");
$block[1]["content"] = statistics_display_online_block();
$block[1]["info"] = "Who's online";
case 1:
$block["subject"] = variable_get("statistics_block_online_title", "Who's online");
$block["content"] = statistics_display_online_block();
break;
}
return $block;
return $block;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment