Commit 1c2fe643 authored by Jelle_S's avatar Jelle_S

Fix hook_menu().

parent 40f93f74
......@@ -11,14 +11,34 @@ function webform_multifile_menu() {
'load arguments' => array(1),
'page callback' => 'drupal_get_form',
'page arguments' => array('webform_multifile_delete_form', 1, 3, 5, 6),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'edit'),
'access callback' => 'webform_multifile_delete_access',
'access arguments' => array(1, 3, 5, 6),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Access callback.
*/
function webform_multifile_delete_access($node, $submission, $component_id, $file_id) {
$submission_access = webform_submission_access($node, $submission, 'edit')
&& $submission->nid == $node->nid
&& isset($submission->data[$component_id]);
if (!$submission_access) {
return FALSE;
}
$submitted_fids = array();
foreach ($submission->data[$component_id] as $data) {
$decoded = drupal_json_decode($data);
if ($decoded) {
$submitted_fids = array_merge($submitted_fids, $decoded);
}
}
return !empty($submitted_fids) && in_array($file_id, $submitted_fids);
}
/**
* Implements hook_webform_component_info().
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment