Commit 062a8abd authored by Dries's avatar Dries

- Patch #10990 by TDobes: adds a "create new blog entry" link at the top of...

- 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.
parent 30110a87
......@@ -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)) {
......
......@@ -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)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment