You are here

function rules_admin_sets_overview in Rules 6

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

File

rules_admin/rules_admin.sets.inc, line 10

Code

function rules_admin_sets_overview() {
  $sets = rules_get_configured_items('rule_sets');
  $sets = array_filter($sets, 'rules_admin_element_filter');
  ksort($sets);
  $header = array(
    t('Label'),
    t('Name'),
    t('Category'),
    t('Status'),
    t('Operations'),
  );
  $rows = array();
  foreach ($sets as $name => $set_info) {
    $set_info += array(
      'status' => 'default',
    );
    $path = RULES_ADMIN_SET_PATH . '/' . $name;
    $ops = array();
    if ($set_info['status'] == 'custom') {
      $ops[] = l(t('delete'), $path . '/delete', array(
        'query' => drupal_get_destination(),
      ));
    }
    else {
      if ($set_info['status'] == 'altered') {
        $ops[] = l(t('revert'), $path . '/revert', array(
          'query' => drupal_get_destination(),
        ));
      }
    }
    $categories = isset($set_info['categories']) ? array_map('check_plain', $set_info['categories']) : array();
    $rows[] = array(
      l($set_info['label'], $path . '/edit'),
      check_plain($name),
      implode(', ', $categories),
      theme('rules_admin_configuration_status', $set_info['status']),
      implode(' ', $ops),
    );
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no rule sets.'),
        'colspan' => 6,
      ),
    );
  }
  return theme('table', $header, $rows, array(
    'class' => 'rules-sets-configurations',
  ));
}