- The real code fixes ;)
parent
a1579a3aee
commit
e7edb55d63
|
@ -270,7 +270,7 @@ function aggregator_remove($feed) {
|
|||
}
|
||||
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
|
||||
db_query("UPDATE {aggregator_feed} SET checked = 0, etag = '', modified = 0 WHERE fid = %d", $feed['fid']);
|
||||
drupal_set_message(t('Removed news items from %site.', array('%site' => '<em>'.$feed['title'] .'</em>')));
|
||||
drupal_set_message(t('Removed news items from %site.', array('%site' => '<em>'. $feed['title'] .'</em>')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -270,7 +270,7 @@ function aggregator_remove($feed) {
|
|||
}
|
||||
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
|
||||
db_query("UPDATE {aggregator_feed} SET checked = 0, etag = '', modified = 0 WHERE fid = %d", $feed['fid']);
|
||||
drupal_set_message(t('Removed news items from %site.', array('%site' => '<em>'.$feed['title'] .'</em>')));
|
||||
drupal_set_message(t('Removed news items from %site.', array('%site' => '<em>'. $feed['title'] .'</em>')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -241,7 +241,7 @@ function archive_page($year = 0, $month = 0, $day = 0) {
|
|||
|
||||
if ($year && $month && $day) {
|
||||
// Fetch nodes for the selected date, if one was specified.
|
||||
$sql = 'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created';
|
||||
$sql = 'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created';
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$result = db_query_range($sql, $date, $date_end, 0, 20);
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ function archive_page($year = 0, $month = 0, $day = 0) {
|
|||
|
||||
if ($year && $month && $day) {
|
||||
// Fetch nodes for the selected date, if one was specified.
|
||||
$sql = 'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created';
|
||||
$sql = 'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created';
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$result = db_query_range($sql, $date, $date_end, 0, 20);
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ function book_menu($may_cache) {
|
|||
// We don't want to cache these menu items because they could change whenever
|
||||
// a book page or outline node is edited.
|
||||
if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'book') {
|
||||
$result = db_query(node_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title"));
|
||||
$result = db_query(node_rewrite_sql('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title'));
|
||||
while ($book = db_fetch_object($result)) {
|
||||
$items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ function book_block($op = 'list', $delta = 0) {
|
|||
else if ($op == 'view') {
|
||||
// Only display this block when the user is browsing a book:
|
||||
if (arg(0) == 'node' && is_numeric(arg(1))) {
|
||||
$result = db_query(node_rewrite_sql("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d"), arg(1));
|
||||
$result = db_query(node_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d'), arg(1));
|
||||
if (db_num_rows($result) > 0) {
|
||||
$node = db_fetch_object($result);
|
||||
|
||||
|
@ -320,7 +320,7 @@ function book_revision_load($page, $conditions = array()) {
|
|||
* Return the path (call stack) to a certain book page.
|
||||
*/
|
||||
function book_location($node, $nodes = array()) {
|
||||
$parent = db_fetch_object(db_query(node_rewrite_sql("SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d"), $node->parent));
|
||||
$parent = db_fetch_object(db_query(node_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d'), $node->parent));
|
||||
if ($parent->title) {
|
||||
$nodes = book_location($parent, $nodes);
|
||||
array_push($nodes, $parent);
|
||||
|
@ -356,7 +356,7 @@ function book_prev($node) {
|
|||
}
|
||||
else {
|
||||
// Direct parent:
|
||||
$prev = db_fetch_object(db_query(node_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d AND n.status = 1 AND n.moderate = 0"), $node->parent));
|
||||
$prev = db_fetch_object(db_query(node_rewrite_sql('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d AND n.status = 1 AND n.moderate = 0'), $node->parent));
|
||||
return $prev;
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ function book_prev($node) {
|
|||
*/
|
||||
function book_next($node) {
|
||||
// get first direct child
|
||||
$child = db_fetch_object(db_query(node_rewrite_sql("SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight ASC, n.title ASC"), $node->nid));
|
||||
$child = db_fetch_object(db_query(node_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight ASC, n.title ASC'), $node->nid));
|
||||
if ($child) {
|
||||
return $child;
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ function book_print($nid = 0, $depth = 1) {
|
|||
}
|
||||
|
||||
function book_print_recurse($parent = '', $depth = 1) {
|
||||
$result = db_query(node_rewrite_sql("SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = '$parent' AND n.moderate = 0 ORDER BY b.weight, n.title"));
|
||||
$result = db_query(node_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title', $parent));
|
||||
|
||||
while ($page = db_fetch_object($result)) {
|
||||
// Load the node:
|
||||
|
|
|
@ -106,7 +106,7 @@ function book_menu($may_cache) {
|
|||
// We don't want to cache these menu items because they could change whenever
|
||||
// a book page or outline node is edited.
|
||||
if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'book') {
|
||||
$result = db_query(node_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title"));
|
||||
$result = db_query(node_rewrite_sql('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title'));
|
||||
while ($book = db_fetch_object($result)) {
|
||||
$items[] = array('path' => 'admin/node/book/'. $book->nid, 'title' => t('"%title" book', array('%title' => $book->title)));
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ function book_block($op = 'list', $delta = 0) {
|
|||
else if ($op == 'view') {
|
||||
// Only display this block when the user is browsing a book:
|
||||
if (arg(0) == 'node' && is_numeric(arg(1))) {
|
||||
$result = db_query(node_rewrite_sql("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d"), arg(1));
|
||||
$result = db_query(node_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d'), arg(1));
|
||||
if (db_num_rows($result) > 0) {
|
||||
$node = db_fetch_object($result);
|
||||
|
||||
|
@ -320,7 +320,7 @@ function book_revision_load($page, $conditions = array()) {
|
|||
* Return the path (call stack) to a certain book page.
|
||||
*/
|
||||
function book_location($node, $nodes = array()) {
|
||||
$parent = db_fetch_object(db_query(node_rewrite_sql("SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d"), $node->parent));
|
||||
$parent = db_fetch_object(db_query(node_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d'), $node->parent));
|
||||
if ($parent->title) {
|
||||
$nodes = book_location($parent, $nodes);
|
||||
array_push($nodes, $parent);
|
||||
|
@ -356,7 +356,7 @@ function book_prev($node) {
|
|||
}
|
||||
else {
|
||||
// Direct parent:
|
||||
$prev = db_fetch_object(db_query(node_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d AND n.status = 1 AND n.moderate = 0"), $node->parent));
|
||||
$prev = db_fetch_object(db_query(node_rewrite_sql('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d AND n.status = 1 AND n.moderate = 0'), $node->parent));
|
||||
return $prev;
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ function book_prev($node) {
|
|||
*/
|
||||
function book_next($node) {
|
||||
// get first direct child
|
||||
$child = db_fetch_object(db_query(node_rewrite_sql("SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight ASC, n.title ASC"), $node->nid));
|
||||
$child = db_fetch_object(db_query(node_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight ASC, n.title ASC'), $node->nid));
|
||||
if ($child) {
|
||||
return $child;
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ function book_print($nid = 0, $depth = 1) {
|
|||
}
|
||||
|
||||
function book_print_recurse($parent = '', $depth = 1) {
|
||||
$result = db_query(node_rewrite_sql("SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = '$parent' AND n.moderate = 0 ORDER BY b.weight, n.title"));
|
||||
$result = db_query(node_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title', $parent));
|
||||
|
||||
while ($page = db_fetch_object($result)) {
|
||||
// Load the node:
|
||||
|
|
|
@ -157,7 +157,7 @@ function comment_block($op = 'list', $delta = 0) {
|
|||
return $blocks;
|
||||
}
|
||||
else if ($op == 'view' && user_access('access comments')) {
|
||||
$result = db_query_range(node_rewrite_sql('SELECT c.nid,c.* FROM {comments} c WHERE status = 0 ORDER BY timestamp DESC', 'c'), 0, 10);
|
||||
$result = db_query_range(node_rewrite_sql('SELECT c.nid, c.* FROM {comments} c WHERE status = 0 ORDER BY timestamp DESC', 'c'), 0, 10);
|
||||
$items = array();
|
||||
while ($comment = db_fetch_object($result)) {
|
||||
$items[] = l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'<br />'. t('%time ago', array('%time' => format_interval(time() - $comment->timestamp)));
|
||||
|
|
|
@ -157,7 +157,7 @@ function comment_block($op = 'list', $delta = 0) {
|
|||
return $blocks;
|
||||
}
|
||||
else if ($op == 'view' && user_access('access comments')) {
|
||||
$result = db_query_range(node_rewrite_sql('SELECT c.nid,c.* FROM {comments} c WHERE status = 0 ORDER BY timestamp DESC', 'c'), 0, 10);
|
||||
$result = db_query_range(node_rewrite_sql('SELECT c.nid, c.* FROM {comments} c WHERE status = 0 ORDER BY timestamp DESC', 'c'), 0, 10);
|
||||
$items = array();
|
||||
while ($comment = db_fetch_object($result)) {
|
||||
$items[] = l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'<br />'. t('%time ago', array('%time' => format_interval(time() - $comment->timestamp)));
|
||||
|
|
|
@ -166,7 +166,7 @@ function forum_link($type, $node = 0, $main = 0) {
|
|||
if (!$main && $type == 'node' && $node->type == 'forum') {
|
||||
// get previous and next topic
|
||||
|
||||
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type='forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
|
||||
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$result = db_query($sql, $node->tid);
|
||||
|
||||
|
@ -436,14 +436,13 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
|
|||
}
|
||||
|
||||
$term = taxonomy_get_term($tid);
|
||||
$check_tid = $tid ? "'". db_escape_string($tid) ."'" : 'NULL';
|
||||
|
||||
$sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) as last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = $check_tid AND n.uid = u.uid AND n.nid = f.nid");
|
||||
$sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = '%s' AND n.uid = u.uid AND n.nid = f.nid");
|
||||
$sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,');
|
||||
|
||||
$sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = $check_tid WHERE n.status = 1 AND n.type = 'forum'");
|
||||
$sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = '%s' WHERE n.status = 1 AND n.type = 'forum'");
|
||||
|
||||
$result = pager_query($sql, $forum_per_page, 0, $sql_count);
|
||||
$result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid);
|
||||
|
||||
while ($topic = db_fetch_object($result)) {
|
||||
if ($user->uid) {
|
||||
|
|
|
@ -166,7 +166,7 @@ function forum_link($type, $node = 0, $main = 0) {
|
|||
if (!$main && $type == 'node' && $node->type == 'forum') {
|
||||
// get previous and next topic
|
||||
|
||||
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type='forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
|
||||
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$result = db_query($sql, $node->tid);
|
||||
|
||||
|
@ -436,14 +436,13 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
|
|||
}
|
||||
|
||||
$term = taxonomy_get_term($tid);
|
||||
$check_tid = $tid ? "'". db_escape_string($tid) ."'" : 'NULL';
|
||||
|
||||
$sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) as last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = $check_tid AND n.uid = u.uid AND n.nid = f.nid");
|
||||
$sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = '%s' AND n.uid = u.uid AND n.nid = f.nid");
|
||||
$sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,');
|
||||
|
||||
$sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = $check_tid WHERE n.status = 1 AND n.type = 'forum'");
|
||||
$sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = '%s' WHERE n.status = 1 AND n.type = 'forum'");
|
||||
|
||||
$result = pager_query($sql, $forum_per_page, 0, $sql_count);
|
||||
$result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid);
|
||||
|
||||
while ($topic = db_fetch_object($result)) {
|
||||
if ($user->uid) {
|
||||
|
|
|
@ -1018,7 +1018,7 @@ function node_feed($nodes = 0, $channel = array()) {
|
|||
global $base_url, $locale;
|
||||
|
||||
if (!$nodes) {
|
||||
$nodes = db_query_range(node_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, 15);
|
||||
$nodes = db_query_range(node_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, 15);
|
||||
}
|
||||
|
||||
while ($node = db_fetch_object($nodes)) {
|
||||
|
@ -1725,7 +1725,7 @@ function node_access($op, $node = NULL, $uid = NULL) {
|
|||
* An SQL join clause.
|
||||
*/
|
||||
function node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
|
||||
if (module_implements('access_grants')==array('node') || user_access('administer nodes')) {
|
||||
if (module_implements('access_grants') == array('node') || user_access('administer nodes')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1746,7 @@ function node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
|
|||
* An SQL where clause.
|
||||
*/
|
||||
function node_access_where_sql($op = 'view', $node_access_alias = 'na', $uid = NULL) {
|
||||
if (module_implements('access_grants')==array('node') || user_access('administer nodes')) {
|
||||
if (module_implements('access_grants') == array('node') || user_access('administer nodes')) {
|
||||
// This number is being used in a SQL query as a boolean.
|
||||
// It is "'1'" instead of "1" for database compatibility, as both
|
||||
// PostgreSQL and MySQL treat it as boolean in this case.
|
||||
|
@ -1799,14 +1799,14 @@ function node_access_grants($op, $uid = NULL) {
|
|||
/**
|
||||
* Implementation of hook_node_rewrite_sql
|
||||
*/
|
||||
function node_node_rewrite_sql () {
|
||||
function node_node_rewrite_sql() {
|
||||
$return['join'] = node_access_join_sql();
|
||||
$return['where'] = node_access_where_sql();
|
||||
$return['distinct'] = !empty($return['join']);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helper function for node_rewrite_sql.
|
||||
*
|
||||
* Collects JOIN and WHERE statements via hook_sql.
|
||||
|
@ -1822,7 +1822,6 @@ function node_node_rewrite_sql () {
|
|||
* An associative array: join => join statements, where => where statements, nid_to_select => nid or DISTINCT(nid)
|
||||
*/
|
||||
function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
|
||||
|
||||
$where = array();
|
||||
$join = array();
|
||||
$distinct = FALSE;
|
||||
|
@ -1844,13 +1843,13 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
|
|||
}
|
||||
}
|
||||
|
||||
$swhere = empty($where) ? '' : '('. implode(') AND (',$where).')';
|
||||
$sjoin = empty($join) ? '' : implode(' ',$join);
|
||||
$where = empty($where) ? '' : '('. implode(') AND (',$where).')';
|
||||
$join = empty($join) ? '' : implode(' ',$join);
|
||||
|
||||
return array($sjoin, $swhere, $distinct ? 'DISTINCT('.$nid_alias.'.nid)' : $nid_alias.'.nid');
|
||||
return array($join, $where, $distinct ? 'DISTINCT('. $nid_alias .'.nid)' : $nid_alias .'.nid');
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Rewrites node queries.
|
||||
*
|
||||
* @param $query
|
||||
|
@ -1863,10 +1862,9 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
|
|||
* The original query with JOIN and WHERE statements inserted from hook_node_rewrite_sql implementations. nid is rewritten if needed.
|
||||
*/
|
||||
function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) {
|
||||
|
||||
list($join, $where,$nid_to_select) = _node_rewrite_sql($query, $nid_alias, $args);
|
||||
|
||||
$query = preg_replace('/(SELECT.*)('.$nid_alias.'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query);
|
||||
$query = preg_replace('/(SELECT.*)('. $nid_alias .'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query);
|
||||
|
||||
$query = preg_replace('|FROM[^[:upper:]/,]+|','\0 '.$join.' ', $query);
|
||||
if (strpos($query, 'WHERE')) {
|
||||
|
@ -1885,10 +1883,11 @@ function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) {
|
|||
$replace = 'LIMIT';
|
||||
$add = 'LIMIT';
|
||||
}
|
||||
else
|
||||
else {
|
||||
$query .= ' WHERE '. $where;
|
||||
}
|
||||
if (isset($replace)) {
|
||||
$query = str_replace($replace, 'WHERE '.$where.' '.$add.' ', $query);
|
||||
$query = str_replace($replace, 'WHERE '. $where .' '. $add .' ', $query);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
|
|
@ -1018,7 +1018,7 @@ function node_feed($nodes = 0, $channel = array()) {
|
|||
global $base_url, $locale;
|
||||
|
||||
if (!$nodes) {
|
||||
$nodes = db_query_range(node_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, 15);
|
||||
$nodes = db_query_range(node_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, 15);
|
||||
}
|
||||
|
||||
while ($node = db_fetch_object($nodes)) {
|
||||
|
@ -1725,7 +1725,7 @@ function node_access($op, $node = NULL, $uid = NULL) {
|
|||
* An SQL join clause.
|
||||
*/
|
||||
function node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
|
||||
if (module_implements('access_grants')==array('node') || user_access('administer nodes')) {
|
||||
if (module_implements('access_grants') == array('node') || user_access('administer nodes')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1746,7 @@ function node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
|
|||
* An SQL where clause.
|
||||
*/
|
||||
function node_access_where_sql($op = 'view', $node_access_alias = 'na', $uid = NULL) {
|
||||
if (module_implements('access_grants')==array('node') || user_access('administer nodes')) {
|
||||
if (module_implements('access_grants') == array('node') || user_access('administer nodes')) {
|
||||
// This number is being used in a SQL query as a boolean.
|
||||
// It is "'1'" instead of "1" for database compatibility, as both
|
||||
// PostgreSQL and MySQL treat it as boolean in this case.
|
||||
|
@ -1799,14 +1799,14 @@ function node_access_grants($op, $uid = NULL) {
|
|||
/**
|
||||
* Implementation of hook_node_rewrite_sql
|
||||
*/
|
||||
function node_node_rewrite_sql () {
|
||||
function node_node_rewrite_sql() {
|
||||
$return['join'] = node_access_join_sql();
|
||||
$return['where'] = node_access_where_sql();
|
||||
$return['distinct'] = !empty($return['join']);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Helper function for node_rewrite_sql.
|
||||
*
|
||||
* Collects JOIN and WHERE statements via hook_sql.
|
||||
|
@ -1822,7 +1822,6 @@ function node_node_rewrite_sql () {
|
|||
* An associative array: join => join statements, where => where statements, nid_to_select => nid or DISTINCT(nid)
|
||||
*/
|
||||
function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
|
||||
|
||||
$where = array();
|
||||
$join = array();
|
||||
$distinct = FALSE;
|
||||
|
@ -1844,13 +1843,13 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
|
|||
}
|
||||
}
|
||||
|
||||
$swhere = empty($where) ? '' : '('. implode(') AND (',$where).')';
|
||||
$sjoin = empty($join) ? '' : implode(' ',$join);
|
||||
$where = empty($where) ? '' : '('. implode(') AND (',$where).')';
|
||||
$join = empty($join) ? '' : implode(' ',$join);
|
||||
|
||||
return array($sjoin, $swhere, $distinct ? 'DISTINCT('.$nid_alias.'.nid)' : $nid_alias.'.nid');
|
||||
return array($join, $where, $distinct ? 'DISTINCT('. $nid_alias .'.nid)' : $nid_alias .'.nid');
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Rewrites node queries.
|
||||
*
|
||||
* @param $query
|
||||
|
@ -1863,10 +1862,9 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
|
|||
* The original query with JOIN and WHERE statements inserted from hook_node_rewrite_sql implementations. nid is rewritten if needed.
|
||||
*/
|
||||
function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) {
|
||||
|
||||
list($join, $where,$nid_to_select) = _node_rewrite_sql($query, $nid_alias, $args);
|
||||
|
||||
$query = preg_replace('/(SELECT.*)('.$nid_alias.'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query);
|
||||
$query = preg_replace('/(SELECT.*)('. $nid_alias .'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query);
|
||||
|
||||
$query = preg_replace('|FROM[^[:upper:]/,]+|','\0 '.$join.' ', $query);
|
||||
if (strpos($query, 'WHERE')) {
|
||||
|
@ -1885,10 +1883,11 @@ function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) {
|
|||
$replace = 'LIMIT';
|
||||
$add = 'LIMIT';
|
||||
}
|
||||
else
|
||||
else {
|
||||
$query .= ' WHERE '. $where;
|
||||
}
|
||||
if (isset($replace)) {
|
||||
$query = str_replace($replace, 'WHERE '.$where.' '.$add.' ', $query);
|
||||
$query = str_replace($replace, 'WHERE '. $where .' '. $add .' ', $query);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
|
|
@ -126,9 +126,9 @@ function queue_overview() {
|
|||
$sql = 'SELECT n.nid, n.title, n.type, u.name, u.uid, SUM(IF(q.uid = %d, 1, 0)) AS voted, SUM(q.vote) AS score FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {queue} q ON n.nid = q.nid WHERE n.moderate = 1 GROUP BY n.nid, n.title, n.type, u.name, u.uid, q.uid, q.vote';
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = node_rewrite_sql('SELECT COUNT(n.nid) FROM {node} n INNER JOIN {queue} q ON n.nid = q.nid WHERE n.moderate = 1');
|
||||
$sresult = pager_query($sql, 10, 0,$sql_count , $user->uid);
|
||||
$result = pager_query($sql, 10, 0, $sql_count, $user->uid);
|
||||
|
||||
while ($node = db_fetch_object($sresult)) {
|
||||
while ($node = db_fetch_object($result)) {
|
||||
if ($user->uid == $node->uid || $node->voted) {
|
||||
$rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => $node->score, 'class' => 'score'));
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ function queue_overview() {
|
|||
}
|
||||
|
||||
if ($pager = theme('pager', NULL, 10, 0, tablesort_pager())) {
|
||||
$rows[] = array(array('data' => $pager, 'colspan' => '4'));
|
||||
$rows[] = array(array('data' => $pager, 'colspan' => '4'));
|
||||
}
|
||||
|
||||
if (!$rows) {
|
||||
|
|
|
@ -103,7 +103,7 @@ function taxonomy_block($op = 'list', $delta = 0) {
|
|||
return $blocks;
|
||||
}
|
||||
else if ($op == 'view' && user_access('access content')) {
|
||||
$result = db_query(node_rewrite_sql("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name"));
|
||||
$result = db_query(node_rewrite_sql('SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name'));
|
||||
$items = array();
|
||||
while ($category = db_fetch_object($result)) {
|
||||
$items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid) .'<br />'. t('%time ago', array('%time' => format_interval(time() - $category->updated)));
|
||||
|
@ -839,7 +839,7 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p
|
|||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = node_rewrite_sql($sql_count);
|
||||
if ($pager) {
|
||||
$result = pager_query($sql, variable_get('default_nodes_main', 10) , 0, $sql_count);
|
||||
$result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count);
|
||||
}
|
||||
else {
|
||||
$result = db_query_range($sql, 0, 15);
|
||||
|
|
|
@ -103,7 +103,7 @@ function taxonomy_block($op = 'list', $delta = 0) {
|
|||
return $blocks;
|
||||
}
|
||||
else if ($op == 'view' && user_access('access content')) {
|
||||
$result = db_query(node_rewrite_sql("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name"));
|
||||
$result = db_query(node_rewrite_sql('SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name'));
|
||||
$items = array();
|
||||
while ($category = db_fetch_object($result)) {
|
||||
$items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid) .'<br />'. t('%time ago', array('%time' => format_interval(time() - $category->updated)));
|
||||
|
@ -839,7 +839,7 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p
|
|||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = node_rewrite_sql($sql_count);
|
||||
if ($pager) {
|
||||
$result = pager_query($sql, variable_get('default_nodes_main', 10) , 0, $sql_count);
|
||||
$result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count);
|
||||
}
|
||||
else {
|
||||
$result = db_query_range($sql, 0, 15);
|
||||
|
|
|
@ -77,14 +77,14 @@ function tracker_page($uid = 0) {
|
|||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = 'SELECT n.nid FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND c.status = 0 WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
|
||||
$sql_count = node_rewrite_sql($sql_count);
|
||||
$result = pager_query($sql, 25, 0,$sql_count , $uid, $uid);
|
||||
$result = pager_query($sql, 25, 0, $sql_count, $uid, $uid);
|
||||
}
|
||||
else {
|
||||
$sql = 'SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_post DESC';
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
|
||||
$sql_count = node_rewrite_sql($sql_count);
|
||||
$result = pager_query($sql, 25, 0,$sql_count);
|
||||
$result = pager_query($sql, 25, 0, $sql_count);
|
||||
}
|
||||
|
||||
while ($node = db_fetch_object($result)) {
|
||||
|
|
|
@ -77,14 +77,14 @@ function tracker_page($uid = 0) {
|
|||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = 'SELECT n.nid FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND c.status = 0 WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
|
||||
$sql_count = node_rewrite_sql($sql_count);
|
||||
$result = pager_query($sql, 25, 0,$sql_count , $uid, $uid);
|
||||
$result = pager_query($sql, 25, 0, $sql_count, $uid, $uid);
|
||||
}
|
||||
else {
|
||||
$sql = 'SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_post DESC';
|
||||
$sql = node_rewrite_sql($sql);
|
||||
$sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
|
||||
$sql_count = node_rewrite_sql($sql_count);
|
||||
$result = pager_query($sql, 25, 0,$sql_count);
|
||||
$result = pager_query($sql, 25, 0, $sql_count);
|
||||
}
|
||||
|
||||
while ($node = db_fetch_object($result)) {
|
||||
|
|
Loading…
Reference in New Issue