summaryrefslogtreecommitdiff
path: root/modules/blog/blog.pages.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/blog/blog.pages.inc')
-rw-r--r--modules/blog/blog.pages.inc62
1 files changed, 48 insertions, 14 deletions
diff --git a/modules/blog/blog.pages.inc b/modules/blog/blog.pages.inc
index 320fd6921..943e5491f 100644
--- a/modules/blog/blog.pages.inc
+++ b/modules/blog/blog.pages.inc
@@ -29,7 +29,19 @@ function blog_page_user($account) {
'#weight' => -1,
);
- $nids = 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)->fetchCol();
+ $query = db_select('node', 'n')->extend('PagerDefault');
+ $nids = $query
+ ->fields('n', array('nid', 'sticky', 'created'))
+ ->condition('type', 'blog')
+ ->condition('uid', $account->uid)
+ ->condition('status', 1)
+ ->orderBy('sticky', 'DESC')
+ ->orderBy('created', 'DESC')
+ ->limit(variable_get('default_nodes_main', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
$build += node_build_multiple($nodes);
@@ -67,7 +79,17 @@ function blog_page_last() {
);
}
- $nids = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, 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))->fetchCol();
+ $query = db_select('node', 'n')->extend('PagerDefault');
+ $nids = $query
+ ->fields('n', array('nid', 'sticky', 'created'))
+ ->condition('type', 'blog')
+ ->condition('status', 1)
+ ->orderBy('sticky', 'DESC')
+ ->orderBy('created', 'DESC')
+ ->limit(variable_get('default_nodes_main', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
@@ -89,28 +111,40 @@ function blog_page_last() {
* Menu callback; displays an RSS feed containing recent blog entries of a given user.
*/
function blog_feed_user($account) {
- $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));
+
+ $nids = db_select('node', 'n')
+ ->fields('n', array('nid', 'created'))
+ ->condition('type', 'blog')
+ ->condition('uid', $account->uid)
+ ->condition('status', 1)
+ ->orderBy('created', 'DESC')
+ ->range(0, variable_get('feed_default_items', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
$channel['title'] = $account->name . "'s blog";
$channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
- $items = array();
- while ($row = db_fetch_object($result)) {
- $items[] = $row->nid;
- }
- node_feed($items, $channel);
+ node_feed($nids, $channel);
}
/**
* Menu callback; displays an RSS feed containing recent blog entries of all users.
*/
function blog_feed_last() {
- $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));
+ $nids = db_select('node', 'n')
+ ->fields('n', array('nid', 'created'))
+ ->condition('type', 'blog')
+ ->condition('status', 1)
+ ->orderBy('created', 'DESC')
+ ->range(0, variable_get('feed_default_items', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
$channel['title'] = variable_get('site_name', 'Drupal') . ' blogs';
$channel['link'] = url('blog', array('absolute' => TRUE));
- $items = array();
- while ($row = db_fetch_object($result)) {
- $items[] = $row->nid;
- }
- node_feed($items, $channel);
+ node_feed($nids, $channel);
}