You are here

function customfilter_filter_delete in Custom filter 5

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

Delete a filter.

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

File

./customfilter.module, line 563

Code

function customfilter_filter_delete($fid) {
  $filter = db_fetch_object(db_query("SELECT * FROM {customfilter_filter} WHERE fid = %d", $fid));
  $subfilter = db_fetch_object(db_query("SELECT * FROM {customfilter_filter} WHERE parentid = %d", $fid));
  $form['fid'] = array(
    '#type' => 'value',
    '#value' => $fid,
  );
  $form['sid'] = array(
    '#type' => 'value',
    '#value' => $filter->sid,
  );
  $message = t('Are you sure you want to delete this custom filter?');
  $msg_text = ($filter->parentid == 0 ? "<h3>{$filter->name}</h3>" : "") . "<p>{$filter->description}</p>" . "<h3>Pattern</h3>" . "<pre>{$filter->pattern}</pre>" . "<h3>Replacer</h3>" . "<pre>{$filter->replacer}</pre>";
  if ($subfilter) {
    $msg_text .= "<p>" . t('This filter has subfilters. If you delete this, they will be deleted too.') . "</p>" . customfilter_filter_render_table($filter->sid, $fid, FALSE);
  }
  $msg_text .= "<p>" . t('This action cannot be undone.') . "</p>";
  return confirm_form($form, $message, "admin/settings/customfilter/{$filter->sid}", $msg_text, t('Delete'));
}