function background_process_service_access in Background Process 7
Same name and namespace in other branches
- 8 background_process.module \background_process_service_access()
- 6 background_process.module \background_process_service_access()
- 7.2 background_process.module \background_process_service_access()
Access handler for service call.
1 call to background_process_service_access()
- _background_process_queue in ./
background_process.module - Worker callback for processing queued function call.
1 string reference to 'background_process_service_access'
- background_process_menu in ./
background_process.module - Implements hook_menu().
File
- ./
background_process.module, line 250
Code
function background_process_service_access($handle, $token) {
// Setup service.
ignore_user_abort(TRUE);
// Damn those slashes!
$handle = rawurldecode($handle);
$token = rawurldecode($token);
// Ensure no session!
drupal_save_session(FALSE);
unset($_SESSION);
$process = background_process_get_process($handle);
if (!$process) {
watchdog('bg_process', 'Unknown process: %handle', array(
'%handle' => $handle,
));
return FALSE;
}
if ($token !== $process->token) {
watchdog('bg_process', 'Invalid token: %token for handle: %handle', array(
'%token' => $token,
'%handle' => $handle,
));
return FALSE;
}
// Login as the user that requested the call.
global $user;
if ($process->uid) {
$load_user = user_load($process->uid);
if (!$load_user) {
// Invalid user!
watchdog('bg_process', 'Invalid user: %uid for handle: %handle', array(
'%uid' => $process->uid,
'%handle' => $handle,
));
return FALSE;
}
$user = $load_user;
}
else {
$user = drupal_anonymous_user();
}
return TRUE;
}