You are here

function regcode_og_rules_page in Registration codes 7

Same name and namespace in other branches
  1. 7.2 regcode_og/regcode_og.module \regcode_og_rules_page()

List all of the rules as a HTML table.

1 string reference to 'regcode_og_rules_page'
regcode_og_menu in regcode_og/regcode_og.module
Implements hook_menu().

File

regcode_og/regcode_og.module, line 251
Install, uninstall and scheme functions for the regcode_og module.

Code

function regcode_og_rules_page() {
  $rules = variable_get('regcode_og_settings', array());
  $rows = array();
  foreach ($rules as $row) {
    $actions = array();
    $actions[] = l(t('Edit'), sprintf('admin/config/people/regcode/og/rule/%s', $row['machine_name']));
    $actions[] = l(t('Delete'), sprintf('admin/config/people/regcode/og/rule/%s/delete', $row['machine_name']), array(
      'query' => array(
        'token' => drupal_get_token($row['machine_name']),
      ),
    ));
    $ognames = regcode_og_label($row['ogs']);
    $term = taxonomy_term_load($row['tid']);
    $rows[] = array(
      check_plain($row['name']),
      check_plain(implode(", ", $ognames)),
      $term ? check_plain($term->name) : '-- ' . t('None') . ' --',
      implode(' | ', $actions),
    );
  }
  $header = array(
    t('Name'),
    t('Groups'),
    t('Tag'),
    t('Operations'),
  );
  $table = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No rules defined. <a href="@link">Add rule</a>.', array(
      '@link' => url('admin/config/people/regcode/og/add-rule'),
    )),
  );
  return $table;
}