diff options
-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)) { |