class webform_rules_data_type_webform_data in Webform Rules 6
Defines the webform_data type
Hierarchy
- class \rules_data_type
Expanded class hierarchy of webform_rules_data_type_webform_data
1 string reference to 'webform_rules_data_type_webform_data'
- webform_rules_data_type_info in ./
webform_rules.rules.inc - Implementation of hook_rules_data_type_info().
File
- ./
webform_rules.rules.inc, line 144 - Functions for rules integration.
View source
class webform_rules_data_type_webform_data extends rules_data_type {
function save() {
$changed = FALSE;
// Get eventually modified data.
$submission =& $this
->get();
if (!$submission || !is_array($submission)) {
// No data found.
return FALSE;
}
$sid = $submission['sid'];
// Load saved submission data.
$saved_submission = $this
->load($sid);
if (count($saved_submission) != 1) {
// No submission found with given id.
return FALSE;
}
$new_submission = $saved_submission[$sid];
$node = node_load($new_submission->nid);
if (!$node) {
// Webform could not be loaded.
return FALSE;
}
// Replace saved submission data with modified values.
foreach ($submission['components'] as $key => $value) {
$cid = $value['component']['cid'];
$new_val = is_array($value['value']) ? $value['value'] : array(
$value['value'],
);
if ($new_val != $new_submission->data[$cid]['value']) {
$changed = TRUE;
}
$new_submission->data[$cid]['value'] = $new_val;
}
// Update submission data if necessary.
if ($changed) {
module_load_include('inc', 'webform', 'includes/webform.submissions');
// TODO: changed is always TRUE atm?
webform_submission_update($node, $new_submission);
}
return TRUE;
}
function load($sid) {
module_load_include('inc', 'webform', 'includes/webform.submissions');
return webform_get_submissions(array(
'sid' => $sid,
));
}
function get_identifier() {
$submission =& $this
->get();
if (is_array($submission)) {
$submission = (object) $submission;
}
return $submission->sid;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
rules_data_type:: |
property | |||
rules_data_type:: |
property | |||
rules_data_type:: |
property | |||
rules_data_type:: |
function | Checks the value of your data type. E.g. the number data type uses this to make sure the value is a number. | 3 | |
rules_data_type:: |
function | Constructor | ||
rules_data_type:: |
function | Returns whether the input evaluator should be used for this data | ||
rules_data_type:: |
function | Gets the data | ||
rules_data_type:: |
function | Gets an input form for creating an instance of your data type. Implement it, if your data type has set use_input_form to TRUE. | 1 | |
rules_data_type:: |
function | Gets the information about this data type. | ||
rules_data_type:: |
function | Inititate the data | ||
rules_data_type:: |
function | Returns whether this data is identifiable | ||
rules_data_type:: |
function | Returns whether this data is savable | ||
rules_data_type:: |
function | Replaces the data with the new one | ||
rules_data_type:: |
function | Returns whether this data makes use of an input form for creating an instance on the fly. | ||
webform_rules_data_type_webform_data:: |
function |
Gets the identifier of this data, which can be of every php data type - even an array.
Implement it, if your data type is identifiable. Overrides rules_data_type:: |
||
webform_rules_data_type_webform_data:: |
function |
Loads the data identified with an identifier as returned by get_identifier().
Just return the data or FALSE if loading the data failed. Overrides rules_data_type:: |
||
webform_rules_data_type_webform_data:: |
function |
Makes changes to the data permanent.
Implement it, if your data type is savable. Overrides rules_data_type:: |