Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webform_rules
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
webform_rules
Commits
e467a689
Commit
e467a689
authored
14 years ago
by
Stefan Borchert
Browse files
Options
Downloads
Patches
Plain Diff
Backporting from 7.x branch. New event for saving a webform as draft.
parent
019baba3
No related branches found
Branches containing commit
Tags
7.x-1.11
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.txt
+1
-1
1 addition, 1 deletion
README.txt
webform_rules.module
+17
-3
17 additions, 3 deletions
webform_rules.module
webform_rules.rules.inc
+30
-15
30 additions, 15 deletions
webform_rules.rules.inc
with
48 additions
and
19 deletions
README.txt
+
1
−
1
View file @
e467a689
...
...
@@ -14,7 +14,7 @@ You need the following modules for a working feature:
-- INSTALLATION --
Copy the module files to you module directory and then enable it on the admin
modules page. After that you'll see
a
new event in the listing while creating
modules page. After that you'll see
two
new event
s
in the listing while creating
a new rule.
...
...
This diff is collapsed.
Click to expand it.
webform_rules.module
+
17
−
3
View file @
e467a689
...
...
@@ -21,10 +21,24 @@ function webform_rules_form_alter(&$form, $form_state, $form_id) {
*/
function
webform_rules_client_form_submit
(
$form
,
&
$form_state
)
{
global
$user
;
// Check if user is submitting as a draft.
$is_draft
=
$form_state
[
'values'
][
'op'
]
==
t
(
'Save Draft'
);
// Get webform node.
$node
=
isset
(
$form
[
'#node'
]
)
?
$form
[
'#node'
]
:
new
stdClass
()
;
$node
=
$form
[
'#node'
];
// Get submitted data from webform.
$data
=
isset
(
$form
[
'#post'
][
'submitted'
])
?
$form
[
'#post'
][
'submitted'
]
:
array
();
$submission_data
=
webform_submission_data
(
$node
,
$form_state
[
'values'
][
'submitted'
]);
$data
=
array
();
// Map values to field names.
foreach
(
$submission_data
as
$cid
=>
$value
)
{
$component
=
$node
->
webform
[
'components'
][
$cid
];
$data
[
$component
[
'form_key'
]][
'name'
]
=
$component
[
'name'
];
$data
[
$component
[
'form_key'
]][
'value'
]
=
$value
[
'value'
];
}
// Invoke the rules event.
rules_invoke_event
(
'webform_rules_submit'
,
$user
,
$node
,
$data
);
if
(
$is_draft
)
{
rules_invoke_event
(
'webform_rules_submit_as_draft'
,
$user
,
$node
,
$data
);
}
else
{
rules_invoke_event
(
'webform_rules_submit'
,
$user
,
$node
,
$data
);
}
}
This diff is collapsed.
Click to expand it.
webform_rules.rules.inc
+
30
−
15
View file @
e467a689
...
...
@@ -12,23 +12,38 @@
*/
function
webform_rules_rules_event_info
()
{
return
array
(
'webform_rules_submit_as_draft'
=>
array
(
'label'
=>
t
(
'After a webform has been saved as draft'
),
'module'
=>
t
(
'Webform'
),
'arguments'
=>
_webform_rules_event_variables
(),
),
'webform_rules_submit'
=>
array
(
'label'
=>
t
(
'After a webform has been submitted'
),
'module'
=>
'Webform'
,
'arguments'
=>
array
(
'user'
=>
array
(
'type'
=>
'user'
,
'label'
=>
t
(
'User, who submitted the webform'
),
),
'node'
=>
array
(
'type'
=>
'node'
,
'label'
=>
t
(
'The webform node'
),
),
'data'
=>
array
(
'type'
=>
'data'
,
'label'
=>
t
(
'The submitted webform data'
),
),
),
'module'
=>
t
(
'Webform'
),
'arguments'
=>
_webform_rules_event_variables
(),
),
);
}
/**
* Helper function for event variables.
*
* @return
* All available variables for the rules events provided by webform_rules.
*/
function
_webform_rules_event_variables
()
{
return
array
(
'user'
=>
array
(
'type'
=>
'user'
,
'label'
=>
t
(
'User, who submitted the webform'
),
),
'node'
=>
array
(
'type'
=>
'node'
,
'label'
=>
t
(
'The webform node'
),
),
'data'
=>
array
(
'type'
=>
'data'
,
'label'
=>
t
(
'The submitted webform data'
),
),
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment