You are here

function rules_admin_form_overview in Rules 6

Lists the available rules.

1 string reference to 'rules_admin_form_overview'
rules_admin_menu in rules_admin/rules_admin.module
Implementation of hook_menu().

File

rules_admin/rules_admin.rule_forms.inc, line 14

Code

function rules_admin_form_overview(&$form_state) {

  // Check if token module is present.
  rules_admin_check_token();
  $form['filter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Filter'),
    '#collapsible' => TRUE,
    '#collapsed' => isset($form_state['values']) || count(rules_get_configured_items('rules')) < 20,
  );
  $form['filter']['set'] = array(
    '#type' => 'select',
    '#title' => t('Filter by event'),
    '#options' => array(
      0 => '<All>',
    ) + rules_admin_get_grouped_labels(rules_get_events()),
    '#default_value' => isset($form_state['values']['set']) ? $form_state['values']['set'] : 0,
  );
  $form['filter']['category'] = array(
    '#type' => 'select',
    '#title' => t('Filter by category'),
    '#options' => array(
      0 => '<All>',
    ) + rules_admin_get_categories('rules'),
    '#default_value' => isset($form_state['values']['category']) ? $form_state['values']['category'] : 0,
  );
  $form['filter']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Filter'),
  );
  $category = !empty($form_state['values']['category']) ? $form_state['values']['category'] : FALSE;
  $set = !empty($form_state['values']['set']) ? 'event_' . $form_state['values']['set'] : FALSE;
  $form['active_header'] = array(
    '#value' => '<h3>' . t('Active rules') . '</h3>',
  );
  $form['active'] = rules_admin_overview_table(array(
    'category' => $category,
    'set' => $set,
    'active' => TRUE,
  ));
  $form['active']['#suffix'] = '<br />';
  $form['inactive_header'] = array(
    '#value' => '<h3>' . t('Inactive rules') . '</h3>',
  );
  $form['inactive'] = rules_admin_overview_table(array(
    'category' => $category,
    'set' => $set,
    'active' => FALSE,
  ));
  if (variable_get('rules_show_fixed', FALSE)) {
    $form['fixed_header'] = array(
      '#value' => '<h3>' . t('Fixed rules') . '</h3>',
    );
    $form['fixed'] = rules_admin_overview_table(array(
      'category' => $category,
      'set' => $set,
      'active' => TRUE,
      'fixed' => TRUE,
    ));
  }
  return $form;
}