| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
function blog_page_user($account) {
|
| 13 |
global $user;
|
| 14 |
|
| 15 |
drupal_set_title($title = t("@name's blog", array('@name' => $account->name)), PASS_THROUGH);
|
| 16 |
|
| 17 |
$items = array();
|
| 18 |
|
| 19 |
if (($account->uid == $user->uid) && user_access('create blog content')) {
|
| 20 |
$items[] = l(t('Post new blog entry.'), "node/add/blog");
|
| 21 |
}
|
| 22 |
elseif ($account->uid == $user->uid) {
|
| 23 |
$items[] = t('You are not allowed to post a new blog entry.');
|
| 24 |
}
|
| 25 |
|
| 26 |
$build['blog_actions'] = array(
|
| 27 |
'#items' => $items,
|
| 28 |
'#theme' => 'item_list',
|
| 29 |
'#weight' => -1,
|
| 30 |
|
| 31 |
|
| 32 |
$query = db_select('node', 'n')->extend('PagerDefault');
|
| 33 |
|
| 34 |
->fields('n', array('nid', 'sticky', 'created'))
|
| 35 |
->condition('type', 'blog')
|
| 36 |
->condition('uid', $account->uid)
|
| 37 |
->condition('status', 1)
|
| 38 |
->orderBy('sticky', 'DESC')
|
| 39 |
->orderBy('created', 'DESC')
|
| 40 |
->limit(variable_get('default_nodes_main', 10))
|
| 41 |
->addTag('node_access')
|
| 42 |
->execute()
|
| 43 |
->fetchCol();
|
| 44 |
|
| 45 |
if (!empty($nids)) {
|
| 46 |
$nodes = node_load_multiple($nids);
|
| 47 |
$build += node_build_multiple($nodes);
|
| 48 |
$build['pager'] = array(
|
| 49 |
'#theme' => 'pager',
|
| 50 |
'#weight' => 5,
|
| 51 |
|
| 52 |
}
|
| 53 |
|
| 54 |
if ($account->uid == $user->uid) {
|
| 55 |
drupal_set_message(t('You have not created any blog entries.'));
|
| 56 |
}
|
| 57 |
|
| 58 |
drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', $account))));
|
| 59 |
|
| 60 |
|
| 61 |
drupal_add_feed(url('blog/' . $account->uid . '/feed'), t('RSS - !title', array('!title' => $title)));
|
| 62 |
|
| 63 |
return $build;
|
| 64 |
}
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
function blog_page_last() {
|
| 70 |
global $user;
|
| 71 |
$build = array();
|
| 72 |
|
| 73 |
if (user_access('create blog content')) {
|
| 74 |
$items[] = l(t('Create new blog entry.'), "node/add/blog");
|
| 75 |
$build['blog_actions'] = array(
|
| 76 |
'#items' => $items,
|
| 77 |
'#theme' => 'item_list',
|
| 78 |
'#weight' => -1,
|
| 79 |
|
| 80 |
}
|
| 81 |
|
| 82 |
$query = db_select('node', 'n')->extend('PagerDefault');
|
| 83 |
|
| 84 |
->fields('n', array('nid', 'sticky', 'created'))
|
| 85 |
->condition('type', 'blog')
|
| 86 |
->condition('status', 1)
|
| 87 |
->orderBy('sticky', 'DESC')
|
| 88 |
->orderBy('created', 'DESC')
|
| 89 |
->limit(variable_get('default_nodes_main', 10))
|
| 90 |
->addTag('node_access')
|
| 91 |
->execute()
|
| 92 |
->fetchCol();
|
| 93 |
|
| 94 |
if (!empty($nids)) {
|
| 95 |
$nodes = node_load_multiple($nids);
|
| 96 |
$build += node_build_multiple($nodes);
|
| 97 |
$build['pager'] = array(
|
| 98 |
'#theme' => 'pager',
|
| 99 |
'#weight' => 5,
|
| 100 |
|
| 101 |
}
|
| 102 |
|
| 103 |
drupal_set_message(t('No blog entries have been created.'));
|
| 104 |
|
| 105 |
drupal_add_feed(url('blog/feed'), t('RSS - blogs'));
|
| 106 |
|
| 107 |
return $build;
|
| 108 |
}
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
function blog_feed_user($account) {
|
| 114 |
|
| 115 |
$nids = db_select('node', 'n')
|
| 116 |
->fields('n', array('nid', 'created'))
|
| 117 |
->condition('type', 'blog')
|
| 118 |
->condition('uid', $account->uid)
|
| 119 |
->condition('status', 1)
|
| 120 |
->orderBy('created', 'DESC')
|
| 121 |
->range(0, variable_get('feed_default_items', 10))
|
| 122 |
->addTag('node_access')
|
| 123 |
->execute()
|
| 124 |
->fetchCol();
|
| 125 |
|
| 126 |
$channel['title'] = t("!name's blog", array('!name' => $account->name));
|
| 127 |
$channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
|
| 128 |
|
| 129 |
node_feed($nids, $channel);
|
| 130 |
}
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
function blog_feed_last() {
|
| 136 |
$nids = db_select('node', 'n')
|
| 137 |
->fields('n', array('nid', 'created'))
|
| 138 |
->condition('type', 'blog')
|
| 139 |
->condition('status', 1)
|
| 140 |
->orderBy('created', 'DESC')
|
| 141 |
->range(0, variable_get('feed_default_items', 10))
|
| 142 |
->addTag('node_access')
|
| 143 |
->execute()
|
| 144 |
->fetchCol();
|
| 145 |
|
| 146 |
$channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal')));
|
| 147 |
$channel['link'] = url('blog', array('absolute' => TRUE));
|
| 148 |
|
| 149 |
node_feed($nids, $channel);
|
| 150 |
}
|
| 151 |
|