function rules_upgrade_form_submit
Submit handler for the form.
File
-
includes/
rules.upgrade.inc, line 92
Code
function rules_upgrade_form_submit($form, &$form_state) {
// Load all rules includes and install files so modules may put there upgrade
// information in both locations.
module_load_all_includes('rules.inc');
module_load_all_includes('install');
$configs = array();
try {
foreach ($form_state['values']['rules'] as $name) {
drupal_set_message(t('Converting %plugin %name...', array(
'%plugin' => t('rule'),
'%name' => $name,
)));
$configs[$name] = rules_upgrade_convert_rule($name, _rules_upgrade_fetch_item($name, 'rules_rules'));
}
foreach ($form_state['values']['sets'] as $name) {
drupal_set_message(t('Converting %plugin %name...', array(
'%plugin' => t('rule set'),
'%name' => $name,
)));
$configs[$name] = rules_upgrade_convert_rule_set($name, _rules_upgrade_fetch_item($name, 'rules_sets'));
}
drupal_set_message(t('Completed.'));
if ($form_state['values']['method'] == 'save') {
foreach ($configs as $config) {
$config->save();
}
drupal_set_message(t('Converted configurations have been saved to the database and will appear in the Rules administration interface.'));
}
elseif ($form_state['values']['method'] == 'export') {
$export = array();
foreach ($configs as $name => $config) {
$export[$name] = $config->export();
}
$form_state['export'] = $export;
$form_state['rebuild'] = TRUE;
}
} catch (RulesException $e) {
drupal_set_message($e->getMessage(), 'error');
}
}