You are here

function customfilter_filter_add in Custom filter 7.2

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

Return the form to add a new filter.

Create the form used at admin/settings/customfilter/add

Return value

array Return an array with the form

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

File

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

Code

function customfilter_filter_add() {
  $fid = (int) db_query("SELECT MAX(fid) FROM {customfilter_filter}")
    ->fetchField() + 1;
  if ($fid > 128) {
    drupal_set_message(t('It is not possible to add further filters; the limit of 128 filters has been reached.'), 'error');
    return $form;
  }
  $item = array(
    'fid' => $fid,
    'type' => "filter_{$fid}",
    'name' => t('Filter #!fid', array(
      '!fid' => $fid,
    )),
    'cache' => 1,
    'description' => '',
    'shorttip' => '',
    'longtip' => '',
  );
  _customfilter_filter_add_edit_fields($form, $item);
  return $form;
}