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

Issue #1940282: add action to fetch webform submissions.


Signed-off-by: default avatarStefan Borchert <stefan.borchert@undpaul.de>
parent 4fe5c183
Branches master
No related tags found
No related merge requests found
......@@ -93,6 +93,10 @@ Condition:
condition you can tell rules to react only on one specific webform by selecting
its title.
Actions:
Webform Rules provides some additional actions to either open or close webforms
or fetch a list of submissions for a webform.
-- AUTHOR --
......
......@@ -104,7 +104,7 @@ function webform_rules_rules_action_info() {
'type' => 'list<text>',
'label' => t('Webforms'),
'options list' => 'webform_rules_get_webforms_as_options',
'description' => t('The name of the webforms to open.'),
'description' => t('List of webforms to open.'),
'restriction' => 'input',
'optional' => TRUE,
),
......@@ -122,6 +122,31 @@ function webform_rules_rules_action_info() {
'label' => t('Close webforms'),
'base' => 'webform_rules_webform_close',
),
'webform_submissions_load' => array(
'label' => t('Fetch webform submissions'),
'base' => t('webform_rules_submissions_load'),
'group' => t('Webform'),
'access callback' => 'rules_node_admin_access',
'parameter' => array(
'nid' => array(
'type' => 'integer',
'label' => t('Node ID'),
'description' => t('The ID of the webform node to load the submission for.'),
),
'sid' => array(
'type' => 'integer',
'label' => t('Submission ID'),
'description' => t('The ID of a webform submission. If omitted all submissions of the specified node ID will be fetched.'),
'optional' => TRUE,
),
),
'provides' => array(
'submissions' => array(
'label' => t('Fetched submissions'),
'type' => 'list<list>',
),
),
),
);
// Modify description of closing action.
......@@ -226,6 +251,32 @@ function _webform_rules_webform_set_status($entity = FALSE, $selected_webforms =
}
}
/**
* Rules action to load a list of webform submissions.
*
* @param int $nid
* ID of node to load the submissions for.
* @param int $sid
* (optional) Submission ID.
*
* @return array
* List of loaded webform submissions.
*/
function webform_rules_submissions_load($nid, $sid = NULL) {
// Make sure the needed functions are available.
module_load_include('inc', 'webform', 'includes/webform.submissions');
$filters = array(
'nid' => $nid,
);
if (!empty($sid)) {
$filters['sid'] = $sid;
}
// Fetch submissions.
$submissions = webform_get_submissions($filters);
return array('submissions' => $submissions);
}
/**
* Helper function for event variables.
*
......
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