[development] Overriding node_db_rewrite_sql()
Ron Parker
sysop at scbbs.com
Thu Jul 26 17:48:17 UTC 2007
Dave Cohen wrote:
>You should write your own hook_db_rewrite_sql and not muck with what's in
>node.module. You should not have to muck with it.
>
>
>
This entire effort is to that end. I have written my own
hook_db_rewrite_sql. I have tested it *in* the node module, and am now
trying to put it into a separate module, and the node module back to
it's original code.
>As far as your user #1 issues are concerned, remember that user_access()
>always returns true for user #1. So that user generally has unrestricted
>access to everything.
>
>
I understand this perfectly. But, if I create a group view, and as user
#1 look at that view, I should see all nodes IN THAT GROUP. What I am
saying is that once I implement my new hook_db_rewrite_sql in a separate
module, and return the node.module to its default, unmodified state, as
user #1 when I look at that view, I see every node in the database. I
understand that user #1 can see everthing, but aparently there is
something about the implementation of my hook_db_rewrite_sql that
corrupts the normal view restrictions and causes every node in the
database to be listed no matter what the view.
Again, here is my hook_db_rewrite_sql() code:
function og_user_roles_db_rewrite_sql($query, $primary_table,
$primary_field) {
if ($primary_field == 'nid' && !node_access_view_all_nodes()) {
$return['join'] = og_user_roles_node_access_join_sql($primary_table);
$return['where'] = og_user_roles_node_access_where_sql();
$return['distinct'] = 1;
return $return;
}
}
Further along:
<>function og_user_roles_node_access_join_sql($node_alias = 'n',
$node_access_alias = 'naa') {
if (user_access('administer nodes')) {
return '';
}
$return = 'INNER JOIN {node_access} '. $node_access_alias .' ON
'. $node_access_alias .'.nid = '. $node_alias .'.nid ';
...my own custom modifications
// I use node_access_alias = "naa" instead of "na". This is to avoid
the "duplicate table alias" error.
So, my question is: Why is this hook_db_rewrite_sql code in a custom
module creating a circumstance where views no longer work as user #1
when the same code does NOT create this problem when replacing the
node_db_rewrite_sql function in the node.module?
I'm ThisClose to making this all work after several months of banging my
head against the wall, so any suggestions are much appreciated. Thanks!
-ron
--
Ron Parker
Software Creations http://www.scbbs.com
Self-Administration Web Site http://saw.scbbs.com
SDSS Subscription Mgmt Service http://sdss.scbbs.com
Central Ave Dance Ensemble http://www.centralavedance.com
R & B Salsa http://www.randbsalsa.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070726/ea7b1645/attachment.htm
More information about the development
mailing list