comparison modules/blog/blog.module @ 5:2427550111ae 6.2

Drupal 6.2
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:30:08 +0100
parents c1f4ac30525a
children fff6d4c8c043
comparison
equal deleted inserted replaced
4:d94886ac61a0 5:2427550111ae
1 <?php 1 <?php
2 // $Id: blog.module,v 1.297 2008/01/09 09:51:34 goba Exp $ 2 // $Id: blog.module,v 1.297.2.1 2008/04/09 21:11:45 goba Exp $
3 3
4 /** 4 /**
5 * @file 5 * @file
6 * Enables keeping an easily and regularly updated web page or a blog. 6 * Enables keeping an easily and regularly updated web page or a blog.
7 */ 7 */
138 'page callback' => 'blog_page_last', 138 'page callback' => 'blog_page_last',
139 'access arguments' => array('access content'), 139 'access arguments' => array('access content'),
140 'type' => MENU_SUGGESTED_ITEM, 140 'type' => MENU_SUGGESTED_ITEM,
141 'file' => 'blog.pages.inc', 141 'file' => 'blog.pages.inc',
142 ); 142 );
143 $items['blog/%user_current'] = array( 143 $items['blog/%user_uid_optional'] = array(
144 'title' => 'My blog', 144 'title' => 'My blog',
145 'page callback' => 'blog_page_user', 145 'page callback' => 'blog_page_user',
146 'page arguments' => array(1), 146 'page arguments' => array(1),
147 'access callback' => 'user_access', 147 'access callback' => 'blog_page_user_access',
148 'access arguments' => array('create blog entries', 1), 148 'access arguments' => array(1),
149 'file' => 'blog.pages.inc', 149 'file' => 'blog.pages.inc',
150 ); 150 );
151 $items['blog/%user/feed'] = array( 151 $items['blog/%user/feed'] = array(
152 'title' => 'Blogs', 152 'title' => 'Blogs',
153 'page callback' => 'blog_feed_user', 153 'page callback' => 'blog_feed_user',
154 'page arguments' => array(1), 154 'page arguments' => array(1),
155 'access arguments' => array('access content'), 155 'access callback' => 'blog_page_user_access',
156 'access arguments' => array(1),
156 'type' => MENU_CALLBACK, 157 'type' => MENU_CALLBACK,
157 'file' => 'blog.pages.inc', 158 'file' => 'blog.pages.inc',
158 ); 159 );
159 $items['blog/feed'] = array( 160 $items['blog/feed'] = array(
160 'title' => 'Blogs', 161 'title' => 'Blogs',
163 'type' => MENU_CALLBACK, 164 'type' => MENU_CALLBACK,
164 'file' => 'blog.pages.inc', 165 'file' => 'blog.pages.inc',
165 ); 166 );
166 167
167 return $items; 168 return $items;
169 }
170
171 /**
172 * Access callback for user blog pages.
173 */
174 function blog_page_user_access($account) {
175 // The visitor must be able to access the site's content.
176 // For a blog to 'exist' the user must either be able to
177 // create new blog entries, or it must have existing posts.
178 return $account->uid && user_access('access content') && (user_access('create blog entries', $account) || _blog_post_exists($account));
179 }
180
181 /**
182 * Helper function to determine if a user has blog posts already.
183 */
184 function _blog_post_exists($account) {
185 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));
168 } 186 }
169 187
170 /** 188 /**
171 * Implementation of hook_block(). 189 * Implementation of hook_block().
172 * 190 *