function publishcontent_publish_access in Publish Content 7
Determine if a user has publish permission to a given node.
Parameters
node $node: The node object to check.
user $account: The user account to check - defaults to the logged in user.
Return value
bool TRUE if user can publish the node.
4 calls to publishcontent_publish_access()
- publishcontent_form_node_form_alter in ./
publishcontent.module - Implements hook_form_FORM_ID_alter().
- publishcontent_test_nodes in tests/
publishcontent_test.module - Menu callback.
- publishcontent_views_handler_field_node_link::render_link in ./
publishcontent_views_handler_field_node_link.inc - Render the field.
- _publishcontent_publish_access in ./
publishcontent.module - Access callback for publish action.
File
- ./
publishcontent.module, line 129 - Add link to publish or unpublish a node, with access control based on the node type
Code
function publishcontent_publish_access($node, $account = NULL) {
$access = FALSE;
// Variable may be '0' or '1' or not set.
if (!variable_get('publishcontent_' . $node->type, FALSE)) {
return $access;
}
if (empty($account)) {
global $user;
$account = $user;
}
foreach (module_invoke_all('publishcontent_publish_access', $node, $account) as $module_access) {
if (!is_null($module_access)) {
if ($module_access === PUBLISHCONTENT_ACCESS_DENY) {
// Anything denying access gets priority.
return FALSE;
}
elseif ($module_access === PUBLISHCONTENT_ACCESS_ALLOW) {
// Something grants access.
$access = TRUE;
}
}
}
return $access;
}