From 8d103a08984ac2de72d756eb5c5c8d23061ab028 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 26 Oct 2002 15:17:26 +0000 Subject: - Committed Marco's block rewrite: + Blocks are not longer called if not rendered: major performance improvement. + Fixed some bugs (preview option was broken, path option was broken). + Removed "ascii"-type blocks. + Added permission to for "PHP blocks" + ... NOTES: + You'll want to run "update.php": ALTER TABLE blocks DROP remove; ALTER TABLE blocks DROP name; + You'll want to update your custom modules as well as the modules in the contrib repository. Block function should now read: function *_block($op = "list", $delta = 0) { if ($op == "list") { return array of block infos } else { return subject and content of $delta block } } --- modules/blog/blog.module | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'modules/blog/blog.module') diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 0869fe19e..9d698c44b 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -332,25 +332,24 @@ function blog_link($type, $node = 0, $main) { return $links ? $links : array(); } -function blog_block() { +function blog_block($op = "list", $delta = 0) { global $user; - - $result = db_query("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); - - if (user_access("access content")) { - while ($node = db_fetch_object($result)) { - $output .= l(check_output($node->title), array("id" => $node->nid)) ."
\n"; + if ($op == "list") { + $blocks[0]["info"] = t("User blogs"); + return $blocks; + } + else { + if (user_access("access content")) { + $result = db_query("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); + while ($node = db_fetch_object($result)) { + $output .= l(check_output($node->title), array("id" => $node->nid)) ."
\n"; + } + $output .= "
". lm(t("more"), array("mod" => "blog"), "", array("title" => t("Read the latest blog entries."))) ."
"; + $block["content"] = $output; + $block["subject"] = t("User blogs"); } - $output .= "
".lm(t("more"), array("mod" => "blog"), "", array("title" => t("Read the latest blog entries."))) ."
"; - $block[0]["content"] = $output; + return $block; } - - - $block[0]["subject"] = t("User blogs"); - $block[0]["info"] = t("User blogs"); - $block[0]["link"] = drupal_url(array("mod" => "blog"), "module"); - - return $block; } -?> +?> \ No newline at end of file -- cgit v1.2.3