From a2e6910902bfb1263e1b6363e2c29ede68f89918 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 3 Nov 2001 18:38:30 +0000 Subject: - Made the node forms support "help texts": it is not possible to configure Drupal to display submission guidelines, or any other kind of explanation such as "NO TEST POSTS", for example. - Added node versioning: it is possible to create revisions, to view old revisions and to roll-back to older revisions. You'll need to apply a SQL update. I'm going to work on the book module now, so I might be changing a few things to enable collaborative, moderated revisions - but feel free to send some first feedback, if you like. - Added some configuration options which can be used to set the minimum number of words a blog/story should consist of. Hopefully this will be usefull to stop the (almost empty) test blogs. - Various improvements: + Fine-tuned new node permission system. + Fine-tuned the functions in node.inc. + Fine-tuned some forms. + XHTML-ified some code. --- modules/blog.module | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'modules/blog.module') diff --git a/modules/blog.module b/modules/blog.module index 397fb56cf..d4bded863 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -1,6 +1,14 @@ "0 words", 10 => "10 words", 25 => "25 words", 50 => "50 words", 75 => "75 words", 100 => "100 words", 125 => "125 words", 150 => "150 words", 175 => "175 words", 200 => "200 words"), t("The minimum number of words a personal blog entry should consist of. This can be useful to rule out submissions that do not meet the site's standards, such as short test post.")); + + return $output; + +} + function blog_node($field) { global $user; @@ -13,7 +21,7 @@ function blog_access($op, $node) { global $user; if ($op == "view") { - return $node->nid && $node->status && !$node->moderate; + return ($node->nid && $node->status && !$node->moderate); } if ($op == "create") { @@ -21,11 +29,11 @@ function blog_access($op, $node) { } if ($op == "update") { - return user_access("administer nodes") || ($user->uid == $node->uid); + return ($user->uid == $node->uid); } if ($op == "delete") { - return user_access("administer nodes") || ($user->uid == $node->uid); + return ($user->uid == $node->uid); } } @@ -36,10 +44,6 @@ function blog_help() { nid\">". t("edit") .""; } - if ($user->uid && user_access("post blogs")) { + if ($user->uid) { $links[] = "nid\">". t("blog it") .""; } @@ -159,7 +163,7 @@ function blog_page_last() { $links[] = "nid\">". t("edit") .""; } - if ($user->uid && user_access("post blogs")) { + if ($user->uid) { $links[] = "nid\">". t("blog it") .""; } @@ -178,15 +182,33 @@ function blog_page_last() { $theme->box(t("User blogs"), $output, "main"); } -function blog_form($node, $error) { +function blog_form($node, $help, $error) { global $nid, $iid; - if ($node->body) { - if (count(explode(" ", $node->body)) < variable_get("minimum_node_size", 0)) { + + if (isset($node->body)) { + + /* + ** Validate the size of the blog: + */ + + if (count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) { $error["body"] = "
". t("The body of your blog is too short.") ."
"; } } else { + + /* + ** Carry out some explanation or submission guidelines: + */ + + $help = variable_get("blog_help", ""); + + /* + ** If the user clicked a "blog it" link, we load the data from the + ** database and quote it in the blog: + */ + if ($nid && $blog = node_load(array("nid" => $nid))) { $node->body = "". $blog->body ." [uid&date=$blog->created\">$blog->name]"; } @@ -215,7 +237,7 @@ function blog_save($node) { function blog_page() { global $theme, $id, $op, $date; - if (user_access("access blogs")) { + if (user_access("access content")) { switch ($op) { case "feed": if ($id) { @@ -247,11 +269,11 @@ function blog_page() { function blog_link($type, $node = 0) { global $user; - if ($type == "page" && user_access("access blogs")) { + if ($type == "page" && user_access("access content")) { $links[] = "". t("user blogs") .""; } - if ($type == "menu" && user_access("post blogs")) { + if ($type == "menu") { $links[] = "". t("add blog entry") .""; $links[] = "uid\">". t("view your blog") .""; } -- cgit v1.2.3