Skip to content
Snippets Groups Projects
Commit 019baba3 authored by Stefan Borchert's avatar Stefan Borchert
Browse files

Adding files of webform_rules to repository.

parents
No related branches found
Tags 6.x-1.0
No related merge requests found
/* $Id$ */
This module provides a basic rules integration for webform.
-- REQUIREMENTS --
You need the following modules for a working feature:
* Webform (http://drupal.org/project/webform)
* Rules (http://drupal.org/project/rules)
-- 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
a new rule.
-- HINTS --
If you have a field called 'name' in your webform you can access its submitted
value by using <code>$data['name']</code> in you rule (requires 'PHP Filter' to
be installed).
-- AUTHOR --
Stefan Borchert
http://drupal.org/user/36942
http://www.undpaul.de
; $Id$
name = Webform Rules
core = 6.x
description = "Adds rules integration for webform submissions."
package = Webform
dependencies[] = webform
dependencies[] = rules
<?php
// $Id$
/**
* @file
* Adds rules integration for webform submissions.
*/
/**
* Implementation of hook_form_alter().
*/
function webform_rules_form_alter(&$form, $form_state, $form_id) {
if (strpos($form_id, 'webform_client_form_') !== FALSE) {
// Add custom submit handler to webform form.
$form['#submit'][] = 'webform_rules_client_form_submit';
}
}
/**
* Custom submit handler for webform submissions.
*/
function webform_rules_client_form_submit($form, &$form_state) {
global $user;
// Get webform node.
$node = isset($form['#node']) ? $form['#node'] : new stdClass();
// Get submitted data from webform.
$data = isset($form['#post']['submitted']) ? $form['#post']['submitted'] : array();
// Invoke the rules event.
rules_invoke_event('webform_rules_submit', $user, $node, $data);
}
<?php
// $Id$
/**
* @file
* Functions for rules integration.
*/
/**
* Implementation of hook_rules_event_info().
* @ingroup rules
*/
function webform_rules_rules_event_info() {
return array(
'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'),
),
),
),
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment