function publishcontent_unpublish_access in Publish Content 7
Determine if a user has unpublish rights on a node.
Parameters
node $node: The node object to check against
user $account: The user account object to check. Defaults to current user.
Return value
bool TRUE if the user has unpublish rights to the node.
4 calls to publishcontent_unpublish_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_unpublish_access in ./
publishcontent.module - Access callback for unpublish action.
File
- ./
publishcontent.module, line 185 - Add link to publish or unpublish a node, with access control based on the node type
Code
function publishcontent_unpublish_access($node, $account = NULL) {
if (empty($account)) {
global $user;
$account = $user;
}
$access = FALSE;
foreach (module_invoke_all('publishcontent_unpublish_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;
}