diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-11-24 20:06:10 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-11-24 20:06:10 +0000 |
commit | 062a8abdeae40ab03004f7c11dc21b7a13b57ca1 (patch) | |
tree | 5bf662db67e97866b160f4a17c63e8bb660410c7 | |
parent | 30110a87701149dd23f250354266159ea3e07c35 (diff) | |
download | brdo-062a8abdeae40ab03004f7c11dc21b7a13b57ca1.tar.gz brdo-062a8abdeae40ab03004f7c11dc21b7a13b57ca1.tar.bz2 |
- Patch #10990 by TDobes: adds a "create new blog entry" link at the top of each user's own blog page, similar to the "post new forum topic" link displayed at the top of forum pages. This adds consistency as well as convenience for users.
-rw-r--r-- | modules/blog.module | 17 | ||||
-rw-r--r-- | modules/blog/blog.module | 17 |
2 files changed, 32 insertions, 2 deletions
diff --git a/modules/blog.module b/modules/blog.module index eb95fbf5e..54adb2883 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -136,11 +136,26 @@ function blog_page($uid = 0) { * Displays a Drupal page containing recent blog entries of a given user. */ function blog_page_user($uid) { + global $user; + $account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1)); if ($account->uid) { $title = t("%name's blog", array('%name' => $account->name)); - $output = ''; + + if (($account->uid == $user->uid) && user_access('edit own blog')) { + $output = '<li>'. l(t('Post new blog entry.'), "node/add/blog") .'</li>'; + } + else if ($account->uid == $user->uid) { + $output = '<li>'. t('You are not allowed to post a new blog entry.') .'</li>'; + } + + if ($output) { + $output = '<ul>'. $output .'</ul>'; + } + else { + $output = ''; + } $result = pager_query('SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() ." WHERE type = 'blog' AND n.uid = %d AND n.status = 1 AND ". node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10), 0, NULL, $account->uid); while ($node = db_fetch_object($result)) { diff --git a/modules/blog/blog.module b/modules/blog/blog.module index eb95fbf5e..54adb2883 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -136,11 +136,26 @@ function blog_page($uid = 0) { * Displays a Drupal page containing recent blog entries of a given user. */ function blog_page_user($uid) { + global $user; + $account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1)); if ($account->uid) { $title = t("%name's blog", array('%name' => $account->name)); - $output = ''; + + if (($account->uid == $user->uid) && user_access('edit own blog')) { + $output = '<li>'. l(t('Post new blog entry.'), "node/add/blog") .'</li>'; + } + else if ($account->uid == $user->uid) { + $output = '<li>'. t('You are not allowed to post a new blog entry.') .'</li>'; + } + + if ($output) { + $output = '<ul>'. $output .'</ul>'; + } + else { + $output = ''; + } $result = pager_query('SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() ." WHERE type = 'blog' AND n.uid = %d AND n.status = 1 AND ". node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10), 0, NULL, $account->uid); while ($node = db_fetch_object($result)) { |