Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #230: Properly save rules imported from files. #231

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ui/ui.forms.inc
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,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
Loading