diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-09-11 04:06:39 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-09-11 04:06:39 +0000 |
commit | a667251eeef24ee5ea65c89537387c8167afc6b1 (patch) | |
tree | 67e57237b90a8d941f50238de43481cce386d21d | |
parent | 3da4e0e0157b62d4aacd8857bd1f09c079718a05 (diff) | |
download | brdo-a667251eeef24ee5ea65c89537387c8167afc6b1.tar.gz brdo-a667251eeef24ee5ea65c89537387c8167afc6b1.tar.bz2 |
#555128 by Dave Reid | moshe weitzman: Return boolean value from node_access() with grant query.
-rw-r--r-- | modules/node/node.module | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index a9128ff88..21c98dfd0 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2185,7 +2185,7 @@ function node_search_validate($form, &$form_state) { * Optional, a user object representing the user for whom the operation is to * be performed. Determines access for a user other than the current user. * @return - * TRUE if the operation may be performed. + * TRUE if the operation may be performed, FALSE otherwise. */ function node_access($op, $node, $account = NULL) { global $user; @@ -2234,13 +2234,14 @@ function node_access($op, $node, $account = NULL) { // node_access table. if ($op != 'create' && $node->nid) { $query = db_select('node_access'); - $query->addExpression('COUNT(*)'); + $query->addExpression('1'); $query->condition('grant_' . $op, 1, '>='); $nids = db_or()->condition('nid', $node->nid); if ($node->status) { $nids->condition('nid', 0); } $query->condition($nids); + $query->range(0, 1); $grants = db_or(); foreach (node_access_grants($op, $account) as $realm => $gids) { @@ -2251,10 +2252,10 @@ function node_access($op, $node, $account = NULL) { ); } } - if (count($grants) > 0 ) { + if (count($grants) > 0) { $query->condition($grants); } - return $query + return (bool) $query ->execute() ->fetchField(); } |