From 23ca7a2d8832aa16107cf7002c35170ae2b87a1c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 1 Nov 2001 17:04:20 +0000 Subject: - Another batch of updates/improvements: + introduced basic node permissions ("create", "delete", "update" and "view") at the node level: it's up to the "<$node->type>_module" to hide gory details (if any). + made the "blog it"-feature in the blog and import module work with the new node system, in specific with the new centralized forms. + made it possible to update blogs. + made the page module work with the new node system. + various smaller improvements. --- modules/blog.module | 64 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'modules/blog.module') diff --git a/modules/blog.module b/modules/blog.module index 97c9a8559..a0489928b 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -1,6 +1,35 @@ "personal blog"); + + return $info[$field]; +} + +function blog_access($op, $node) { + global $user; + + if ($op == "view") { + return $node->nid && $node->status && !$node->moderate; + } + + if ($op == "create") { + return $user->uid; + } + + if ($op == "update") { + return user_access("administer nodes") || ($user->uid == $node->uid); + } + + if ($op == "delete") { + return user_access("administer nodes") || ($user->uid == $node->uid); + } + +} + function blog_help() { ?>

Drupal's blog module allows registered users to maintain an online blog or diary. It provides easy-to-write and easy-to-read online diaries or journals that can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.

@@ -94,7 +123,7 @@ function blog_page_user($uid = 0, $date = 0) { } if ($user->uid && user_access("post blogs")) { - $links[] = "nid\">". t("blog it") .""; + $links[] = "nid\">". t("blog it") .""; } if ($blog->comment) { @@ -131,7 +160,7 @@ function blog_page_last() { } if ($user->uid && user_access("post blogs")) { - $links[] = "nid\">". t("blog it") .""; + $links[] = "nid\">". t("blog it") .""; } if ($blog->comment) { @@ -150,6 +179,17 @@ function blog_page_last() { } function blog_form($edit) { + global $nid, $iid; + + if (!$edit->body) { + if ($nid && $blog = node_load(array("nid" => $nid))) { + $edit->body = "". $blog->body ." [uid&date=$blog->created\">$blog->name]"; + } + + if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($iid) ."' AND i.fid = f.fid"))) { + $edit->body = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; + } + } $output = form_textarea(t("Body"), "body", $edit->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); @@ -157,30 +197,14 @@ function blog_form($edit) { } function blog_save($node) { - global $user; if ($node->nid) { - - /* - ** Load the original blog from the database to make sure that only - ** original author can update his blog. - */ - - $blog = node_load(array("nid" => $node->nid)); - - if ($user->uid && $user->uid == $node->uid && $user->uid == $blog->uid) { - return array(); - } - else if (user_access("adminster nodes")) { - return array(); - } - else { - return 0; - } + return array(); } else { return array("promote" => 0, "moderate" => 0, "status" => 1); } + } function blog_page() { -- cgit v1.2.3