function gnode_global_node_create_access in Group 7
Determines whether a user could create a node in a site-wide context.
This function does not take Group Node's hook_node_access() implementation into account. It just figures out if a user can create a node outside of any Group entity.
This is mostly useful because in order to have Node behave properly, we need to implement hook_node_access() just a little too permissive, making it hard to find out what rights the user had before we started interfering.
Parameters
string $type: The node type the user is attempting to create.
object $account: (optional) The account of the user.
Return value
bool Whether the user has creation rights.
1 call to gnode_global_node_create_access()
- gnode_form_node_form_alter in modules/
gnode/ gnode.module - Implements hook_form_BASE_FORM_ID_alter().
File
- modules/
gnode/ gnode.module, line 222 - Contains Group's implementation of the Node module hooks and forms.
Code
function gnode_global_node_create_access($type, $account = NULL) {
global $user;
if (!isset($account)) {
$account = $user;
}
// In order to figure out whether the user can create nodes outside of a
// group, we first have to delete the cached node_access entry for this node
// type.
$rights =& drupal_static('node_access', array());
unset($rights[$account->uid][$type]['create']);
// Then we flag gnode_group_node_create_access() to not interfere with the
// results of node_access() and run the latter to get the result we want.
$skip =& drupal_static('gnode_group_node_create_access');
$skip = TRUE;
$return = node_access('create', $type);
// After we have established whether the user has global node creation
// rights, we need to once again unflag gnode_group_node_create_access() and
// remove the node type's (skewed) entry from the node_access() cache.
$skip = FALSE;
unset($rights[$account->uid][$type]['create']);
// After all this, it is safe to return the retrieved result.
return $return;
}