diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-11-03 18:38:30 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-11-03 18:38:30 +0000 |
commit | a2e6910902bfb1263e1b6363e2c29ede68f89918 (patch) | |
tree | baa89d2d8bcd814f73d5108466024bd13ea7159d /modules/blog.module | |
parent | 4d8b485fad960ea6551111e58f8c59df053b4456 (diff) | |
download | brdo-a2e6910902bfb1263e1b6363e2c29ede68f89918.tar.gz brdo-a2e6910902bfb1263e1b6363e2c29ede68f89918.tar.bz2 |
- 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.
Diffstat (limited to 'modules/blog.module')
-rw-r--r-- | modules/blog.module | 52 |
1 files changed, 37 insertions, 15 deletions
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 @@ <?php // $Id$ +function blog_conf_options() { + $output .= form_textarea("Explanation or submission guidelines", "blog_help", variable_get("blog_help", ""), 55, 4, "This text will be displayed at the top of the blog submission form. Useful for helping or instructing your users."); + $output .= form_select(t("Minimum number of words in a node"), "minimum_blog_size", variable_get("minimum_node_size", 0), array(0 => "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() { <?php } -function blog_perm() { - return array("administer blogs", "access blogs", "post blogs"); -} - function blog_feed_user($uid = 0, $date = 0) { global $user; @@ -122,7 +126,7 @@ function blog_page_user($uid = 0, $date = 0) { $links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } - if ($user->uid && user_access("post blogs")) { + if ($user->uid) { $links[] = "<a href=\"module.php?mod=node&op=add&type=blog&nid=$blog->nid\">". t("blog it") ."</a>"; } @@ -159,7 +163,7 @@ function blog_page_last() { $links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } - if ($user->uid && user_access("post blogs")) { + if ($user->uid) { $links[] = "<a href=\"module.php?mod=node&op=add&type=blog&nid=$blog->nid\">". t("blog it") ."</a>"; } @@ -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"] = "<div style=\"color: red;\">". t("The body of your blog is too short.") ."</div>"; } } 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 = "<i>". $blog->body ."</i> [<a href=\"module.php?mod=blog&id=$blog->uid&date=$blog->created\">$blog->name</a>]"; } @@ -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[] = "<a href=\"module.php?mod=blog\">". t("user blogs") ."</a>"; } - if ($type == "menu" && user_access("post blogs")) { + if ($type == "menu") { $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\">". t("add blog entry") ."</a>"; $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>"; } |