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
5f2af42d
There was an error fetching the commit references. Please try again later.
Commit
5f2af42d
authored
14 years ago
by
Stefan Borchert
Browse files
Options
Downloads
Patches
Plain Diff
Changes for 7.x release. Adding new event for triggering 'Save as draft'.
parent
019baba3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
webform_rules.info
+3
-1
3 additions, 1 deletion
webform_rules.info
webform_rules.module
+18
-4
18 additions, 4 deletions
webform_rules.module
webform_rules.rules.inc
+31
-16
31 additions, 16 deletions
webform_rules.rules.inc
with
52 additions
and
21 deletions
webform_rules.info
+
3
−
1
View file @
5f2af42d
; $Id$
name = Webform Rules
core =
6
.x
core =
7
.x
description = "Adds rules integration for webform submissions."
package = Webform
files[] = webform_rules.module
files[] = webform_rules.rules.inc
dependencies[] = webform
dependencies[] = rules
This diff is collapsed.
Click to expand it.
webform_rules.module
+
18
−
4
View file @
5f2af42d
...
...
@@ -7,7 +7,7 @@
*/
/**
* Implement
ation
of hook_form_alter().
* Implement
s
of hook_form_alter().
*/
function
webform_rules_form_alter
(
&
$form
,
$form_state
,
$form_id
)
{
if
(
strpos
(
$form_id
,
'webform_client_form_'
)
!==
FALSE
)
{
...
...
@@ -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
+
31
−
16
View file @
5f2af42d
...
...
@@ -7,28 +7,43 @@
*/
/**
* Implement
ation
of hook_rules_event_info().
* Implement
s
of hook_rules_event_info().
* @ingroup rules
*/
function
webform_rules_rules_event_info
()
{
return
array
(
'webform_rules_submit_as_draft'
=>
array
(
'label'
=>
t
(
'After a webform has been saved as draft'
),
'group'
=>
t
(
'Webform'
),
'variables'
=>
_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'
),
),
),
'group'
=>
t
(
'Webform'
),
'variables'
=>
_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