function rules_ui_delete_element
Delete elements.
1 string reference to 'rules_ui_delete_element'
- RulesUIController::config_menu in ui/
ui.controller.inc - Generates menu items to manipulate rules configurations.
File
-
ui/
ui.forms.inc, line 338
Code
function rules_ui_delete_element($form, &$form_state, $rules_config, $rules_element, $base_path) {
RulesPluginUI::$basePath = $base_path;
if (empty($form_state['rules_config'])) {
// Before modifying the rules config we have to clone it, so any
// modifications won't appear in the static cache of the loading controller.
$rules_config = clone $rules_config;
// Also get the element from the cloned config.
$rules_element = $rules_config->elementMap()
->lookup($rules_element->elementId());
$form_state['rules_config'] = $rules_config;
$form_state['rules_element'] = $rules_element;
$form_state['element_parent'] = $rules_element->parentElement();
}
// Try deleting the element and warn the user if something breaks, but
// save the parent for determining the right redirect target on submit.
$removed_plugin = $form_state['rules_element']->plugin();
$rules_element->delete();
if (empty($rules_config->dirty) && empty($form_state['input'])) {
try {
$rules_config->integrityCheck();
} catch (RulesIntegrityException $e) {
$args = array(
'@plugin' => $e->element
->plugin(),
'%label' => $e->element
->label(),
'@removed-plugin' => $removed_plugin,
'!url' => url(RulesPluginUI::path($form_state['rules_config']->name, 'edit', $e->element)),
);
drupal_set_message(t('Deleting this @removed-plugin would break your configuration as some of its provided variables are utilized by the @plugin <a href="!url">%label</a>.', $args), 'warning');
}
}
$confirm_question = t('Are you sure you want to delete the %element_plugin %element_name?', array(
'%element_plugin' => $rules_element->plugin(),
'%element_name' => $rules_element->label(),
));
return confirm_form($form, $confirm_question, RulesPluginUI::path($rules_config->name), t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}