diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-01-17 19:00:03 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-01-17 19:00:03 +0000 |
commit | e7edb55d63f78559972646af07107193c8c26a52 (patch) | |
tree | 22ad499230298328f20b8df6afe1f7e5fea590aa /modules/node.module | |
parent | a1579a3aee36faee9bd78111a3de0997e59b8f2e (diff) | |
download | brdo-e7edb55d63f78559972646af07107193c8c26a52.tar.gz brdo-e7edb55d63f78559972646af07107193c8c26a52.tar.bz2 |
- The real code fixes ;)
Diffstat (limited to 'modules/node.module')
-rw-r--r-- | modules/node.module | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/modules/node.module b/modules/node.module index c1fb09108..1107618ac 100644 --- a/modules/node.module +++ b/modules/node.module @@ -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; } |