You are here

function customfilter_rule_delete in Custom filter 7

Same name and namespace in other branches
  1. 6 customfilter.admin.inc \customfilter_rule_delete()
  2. 7.2 customfilter.module \customfilter_rule_delete()

Return the replacement rule delete form.

Create the form used at admin/config/content/customfilter/%/%/delete

1 string reference to 'customfilter_rule_delete'
customfilter_menu in ./customfilter.module
Implements hook_menu().

File

./customfilter.module, line 1016
Allows the users with the right permission to define custom filters.

Code

function customfilter_rule_delete($vars, $form_state, $rid) {
  $filters = _customfilter_get_filters();
  $rule = db_query("SELECT * FROM {customfilter_rule} WHERE rid = :rid", array(
    ':rid' => $rid,
  ))
    ->fetchObject();
  $rules_count = db_query("SELECT COUNT(*) FROM {customfilter_rule} WHERE prid = :rid", array(
    ':rid' => $rid,
  ))
    ->fetchField();
  if ($rule === FALSE) {
    drupal_set_message(t('The replacement rule has been deleted.'));
    drupal_goto(isset($_REQUEST['destination']) ? $_REQUEST['destination'] : 'admin/config/content/customfilter');
  }
  if (isset($filters[$rule->fid])) {
    _customfilter_breadcrumb(array(
      l($filters[$rule->fid]['name'], "admin/config/content/customfilter/{$rule->fid}"),
    ));
  }
  $form = array(
    '#fid' => $rule->fid,
    '#rid' => $rid,
  );
  $msg_text = t('This action cannot be undone.');
  if ($rules_count) {
    $msg_text .= " <p>" . t('This rule has subrules. If you delete this rule, they will be deleted too.') . "</p>";
  }
  return confirm_form($form, t('Are you sure you want to delete the replacement rule %name?', array(
    '%name' => $rule->name,
  )), "admin/config/content/customfilter/{$rule->fid}", $msg_text, t('Delete'));
}