summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJelle Sebreghts2017-05-10 13:46:41 (GMT)
committerJelle Sebreghts2017-05-10 13:46:41 (GMT)
commit1c2fe6430e9f22f61b0f1e574ab4e1ff26386d82 (patch)
tree53ee7e8bc8f5eb4a69dd5885adde9715ffa36abf
parent40f93f74561e009767185708db1e2b7c927d273e (diff)
Fix hook_menu().HEAD7.x-1.67.x-1.x
-rw-r--r--webform_multifile.module24
1 files changed, 22 insertions, 2 deletions
diff --git a/webform_multifile.module b/webform_multifile.module
index 7fe13bc..fed6bde 100644
--- a/webform_multifile.module
+++ b/webform_multifile.module
@@ -11,8 +11,8 @@ 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,
);
@@ -20,6 +20,26 @@ function webform_multifile_menu() {
}
/**
+ * 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().
*/
function webform_multifile_webform_component_info() {