function webform_confirmation_page_access in Webform 7.4
Access function for confirmation pages.
Parameters
object $node: The webform node object.
Return value
bool Boolean whether the user has access to the confirmation page.
1 string reference to 'webform_confirmation_page_access'
- webform_menu in ./
webform.module - Implements hook_menu().
File
- ./
webform.module, line 564 - This module provides a simple way to create forms and questionnaires.
Code
function webform_confirmation_page_access($node) {
global $user;
// Make sure SID is a positive integer.
$sid = !empty($_GET['sid']) && (int) $_GET['sid'] > 0 ? (int) $_GET['sid'] : NULL;
if ($sid) {
module_load_include('inc', 'webform', 'includes/webform.submissions');
$submission = webform_get_submission($node->nid, $sid);
}
else {
$submission = NULL;
}
if ($submission) {
// Logged-in users.
if ($user->uid) {
// User's own submission.
if ($submission->uid === $user->uid && node_access('view', $node)) {
return TRUE;
}
elseif (webform_submission_access($node, $submission)) {
return TRUE;
}
}
elseif ((int) $user->uid === 0 && (int) $submission->uid === 0) {
$hash_query = !empty($_GET['token']) ? $_GET['token'] : NULL;
$hash = webform_get_submission_access_token($submission);
if ($hash_query === $hash) {
return TRUE;
}
}
}
else {
// No submission exists (such as auto-deleted by another module, such as
// webform_clear), just ensure that the user has access to view the node
// page.
if (node_access('view', $node)) {
return TRUE;
}
}
return FALSE;
}