function protected_node_access_callback in Protected Node 1.0.x
Same name and namespace in other branches
- 6 protected_node.module \protected_node_access_callback()
- 7 protected_node.module \protected_node_access_callback()
Callback function to determine who can enter a password.
1 string reference to 'protected_node_access_callback'
- protected_node_menu_array in ./
protected_node.settings.inc - Actual implementation of the protected_node_menu() function.
File
- ./
protected_node.module, line 126 - Protected Node module.
Code
function protected_node_access_callback() {
global $user;
// Super user?
if ($user->uid == 1) {
return TRUE;
}
if (!user_access('access protected node password form')) {
return FALSE;
}
// Is $nid properly defined?
if (empty($_GET['protected_page']) || !is_numeric($_GET['protected_page'])) {
return FALSE;
}
// Valid node?
$node = node_load($_GET['protected_page']);
if (!$node) {
return FALSE;
}
// Editing/deleting? user has edit right?
if (substr($_GET['destination'], 0, 5) == 'node/') {
if (substr($_GET['destination'], -5) == '/edit') {
if (!node_access('update', $node)) {
return FALSE;
}
}
elseif (substr($_GET['destination'], -7) == '/delete') {
if (!node_access('delete', $node)) {
return FALSE;
}
}
}
return TRUE;
}