Skip to content

Commit

Permalink
Merge pull request #231 from bugfolder/230_save_rule_import_from_file
Browse files Browse the repository at this point in the history
Issue #230: Properly save rules imported from files.
  • Loading branch information
argiepiano authored Jun 5, 2024
2 parents dff1b55 + 0af14e7 commit 1c484e8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/ui.forms.inc
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,16 @@ function rules_ui_import_file_form_validate($form, &$form_state)
*/
function rules_ui_import_file_form_submit($form, &$form_state) {
$rules_config = $form_state['rules_config'];

if ($existing_config = rules_config_load($rules_config->name)) {
// Copy DB id and remove the new indicator to overwrite the existing record.
$rules_config->id = $existing_config->id;
// Set the ENTITY_CUSTOM bit in the status bitmask, because the
// configuration has now been customized by the import.
$rules_config->status = $existing_config->status | ENTITY_CUSTOM;
unset($rules_config->is_new);
}
$rules_config->save();
$vars = array('@entity' => t('Rules configuration'), '%label' => $rules_config->label());
watchdog('rules_config', 'Imported @entity %label.', $vars);
backdrop_set_message(t('Imported @entity %label.', $vars));
Expand Down

0 comments on commit 1c484e8

Please sign in to comment.