00001 <?php
00002
00003
00012 function blog_page_user($account) {
00013 global $user;
00014
00015 drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
00016
00017 $items = array();
00018
00019 if (($account->uid == $user->uid) && user_access('create blog content')) {
00020 $items[] = l(t('Post new blog entry.'), "node/add/blog");
00021 }
00022 else if ($account->uid == $user->uid) {
00023 $items[] = t('You are not allowed to post a new blog entry.');
00024 }
00025
00026 $output = theme('item_list', $items);
00027
00028 $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
00029 $has_posts = FALSE;
00030
00031 while ($node = db_fetch_object($result)) {
00032 $output .= node_view(node_load($node->nid), 1);
00033 $has_posts = TRUE;
00034 }
00035
00036 if ($has_posts) {
00037 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
00038 }
00039 else {
00040 if ($account->uid == $user->uid) {
00041 drupal_set_message(t('You have not created any blog entries.'));
00042 }
00043 else {
00044 drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', $account))));
00045 }
00046 }
00047 drupal_add_feed(url('blog/' . $account->uid . '/feed'), t('RSS - !title', array('!title' => $title)));
00048
00049 return $output;
00050 }
00051
00055 function blog_page_last() {
00056 global $user;
00057
00058 $output = '';
00059 $items = array();
00060
00061 if (user_access('edit own blog')) {
00062 $items[] = l(t('Create new blog entry.'), "node/add/blog");
00063 }
00064
00065 $output = theme('item_list', $items);
00066
00067 $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10));
00068 $has_posts = FALSE;
00069
00070 while ($node = db_fetch_object($result)) {
00071 $output .= node_view(node_load($node->nid), 1);
00072 $has_posts = TRUE;
00073 }
00074
00075 if ($has_posts) {
00076 $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
00077 }
00078 else {
00079 drupal_set_message(t('No blog entries have been created.'));
00080 }
00081 drupal_add_feed(url('blog/feed'), t('RSS - blogs'));
00082
00083 return $output;
00084 }
00085
00089 function blog_feed_user($account) {
00090 $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
00091 $channel['title'] = $account->name . "'s blog";
00092 $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
00093
00094 $items = array();
00095 while ($row = db_fetch_object($result)) {
00096 $items[] = $row->nid;
00097 }
00098 node_feed($items, $channel);
00099 }
00100
00104 function blog_feed_last() {
00105 $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10));
00106 $channel['title'] = variable_get('site_name', 'Drupal') . ' blogs';
00107 $channel['link'] = url('blog', array('absolute' => TRUE));
00108
00109 $items = array();
00110 while ($row = db_fetch_object($result)) {
00111 $items[] = $row->nid;
00112 }
00113 node_feed($items, $channel);
00114 }