Commit c3af73ef authored by Dries's avatar Dries

- Patch #302268 by Berdir, Dave Reid, tizzo, Ryan Palmer: TableSort and PagerQueries broken.

parent d532753c
......@@ -66,19 +66,18 @@ function comment_admin_overview($type = 'new', $arg) {
'operations' => array('data' => t('Operations')),
);
$query = db_select('comment', 'c');
$query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
$query->join('users', 'u', 'u.uid = c.uid');
$query->join('node', 'n', 'n.nid = c.nid');
$query->addField('u', 'name', 'registered_name');
$query->addField('n', 'title', 'node_title');
$query
$result = $query
->fields('c', array('subject', 'nid', 'cid', 'comment', 'timestamp', 'status', 'name', 'homepage'))
->fields('u', array('uid'))
->condition('c.status', $status)
->extend('PagerDefault')->extend('TableSort')
->limit(50)
->orderByHeader($header);
$result = $query->execute();
->orderByHeader($header)
->execute();
// Build a table listing the appropriate comments.
......
......@@ -51,7 +51,7 @@ function dblog_overview() {
$build['dblog_clear_log_form'] = drupal_get_form('dblog_clear_log_form');
$header = array(
' ',
'', // Icon column.
array('data' => t('Type'), 'field' => 'w.type'),
array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'),
t('Message'),
......@@ -59,26 +59,18 @@ function dblog_overview() {
array('data' => t('Operations')),
);
$query = db_select('watchdog', 'w');
$query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
$query->join('users', 'u', 'w.uid = u.uid');
$query
->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'))
->addField('u', 'name');
if (!empty($filter['where'])) {
$query
->where($filter['where'], $filter['args'])
->extend('PagerDefault')->extend('TableSort')
->limit(50, 0)
->orderByHeader($header);
$result = $query->execute();
}
else {
$query
->extend('PagerDefault')->extend('TableSort')
->limit(50)
->orderByHeader($header);
$result = $query->execute();
$query->where($filter['where'], $filter['args']);
}
$result = $query
->limit(50)
->orderByHeader($header)
->execute();
foreach ($result as $dblog) {
$rows[] = array('data' =>
......@@ -120,16 +112,15 @@ function dblog_top($type) {
$count_query->addExpression('COUNT(DISTINCT(message))');
$count_query->condition('type', $type);
$query = db_select('watchdog', 'w');
$query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
$query->addExpression('COUNT(wid)', 'count');
$query = $query
->fields('w', array('message', 'variables'))
->condition('w.type', $type)
->groupBy('message')
->groupBy('variables')
->extend('PagerDefault')->extend('TableSort')
->limit(30);
$query = $query->orderByHeader($header);
->limit(30)
->orderByHeader($header);
$query->setCountQuery($count_query);
$result = $query->execute();
......
......@@ -58,19 +58,17 @@ function poll_votes($node) {
$header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
$header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc');
$select = db_select('poll_vote', 'pv');
$select = db_select('poll_vote', 'pv')->extend('PagerDefault')->extend('TableSort');
$select->join('poll_choice', 'pc', 'pv.chid = pc.chid');
$select->join('users', 'u', 'pv.uid = u.uid');
$queried_votes = $select->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid'))
$queried_votes = $select
->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid'))
->fields('pc', array('chtext'))
->fields('u', array('name'))
->condition('pv.nid', $node->nid)
->extend('PagerDefault')
->limit($votes_per_page)
->extend('TableSort')
->orderByHeader($header)
->execute()
->fetchAllAssoc('hostname');
->execute();
$rows = array();
foreach ($queried_votes as $vote) {
......
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