summaryrefslogtreecommitdiff
path: root/modules/blog/blog.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-04-23 20:01:56 +0000
committerDries Buytaert <dries@buytaert.net>2008-04-23 20:01:56 +0000
commit21576021bfe440a0a02b0c179440f00e7182d321 (patch)
treeacc3e15e529a4d07827992561dc8053360f61e35 /modules/blog/blog.module
parent63406e5268e564acb83078eb3beb1abdfefee0ec (diff)
downloadbrdo-21576021bfe440a0a02b0c179440f00e7182d321.tar.gz
brdo-21576021bfe440a0a02b0c179440f00e7182d321.tar.bz2
- Patch #249546 by pwolanin: rip menu access inheritance -- was already committed to D6.
Diffstat (limited to 'modules/blog/blog.module')
-rw-r--r--modules/blog/blog.module26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index d483d48f9..884b3745b 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -140,19 +140,20 @@ function blog_menu() {
'type' => MENU_SUGGESTED_ITEM,
'file' => 'blog.pages.inc',
);
- $items['blog/%user_current'] = array(
+ $items['blog/%user_uid_optional'] = array(
'title' => 'My blog',
'page callback' => 'blog_page_user',
'page arguments' => array(1),
- 'access callback' => 'user_access',
- 'access arguments' => array('create blog content', 1),
+ 'access callback' => 'blog_page_user_access',
+ 'access arguments' => array(1),
'file' => 'blog.pages.inc',
);
$items['blog/%user/feed'] = array(
'title' => 'Blogs',
'page callback' => 'blog_feed_user',
'page arguments' => array(1),
- 'access arguments' => array('access content'),
+ 'access callback' => 'blog_page_user_access',
+ 'access arguments' => array(1),
'type' => MENU_CALLBACK,
'file' => 'blog.pages.inc',
);
@@ -168,6 +169,23 @@ function blog_menu() {
}
/**
+ * Access callback for user blog pages.
+ */
+function blog_page_user_access($account) {
+ // The visitor must be able to access the site's content.
+ // For a blog to 'exist' the user must either be able to
+ // create new blog entries, or it must have existing posts.
+ return $account->uid && user_access('access content') && (user_access('create blog entries', $account) || _blog_post_exists($account));
+}
+
+/**
+ * Helper function to determine if a user has blog posts already.
+ */
+function _blog_post_exists($account) {
+ return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1));
+}
+
+/**
* Implementation of hook_block().
*
* Displays the most recent 10 blog titles.