You are here

function contact_category_list in Drupal 7

Categories/list tab.

1 string reference to 'contact_category_list'
contact_menu in modules/contact/contact.module
Implements hook_menu().

File

modules/contact/contact.admin.inc, line 11
Admin page callbacks for the Contact module.

Code

function contact_category_list() {
  $header = array(
    t('Category'),
    t('Recipients'),
    t('Selected'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();

  // Get all the contact categories from the database.
  $categories = db_select('contact', 'c')
    ->addTag('translatable')
    ->fields('c', array(
    'cid',
    'category',
    'recipients',
    'selected',
  ))
    ->orderBy('weight')
    ->orderBy('category')
    ->execute()
    ->fetchAll();

  // Loop through the categories and add them to the table.
  foreach ($categories as $category) {
    $rows[] = array(
      check_plain($category->category),
      check_plain($category->recipients),
      $category->selected ? t('Yes') : t('No'),
      l(t('Edit'), 'admin/structure/contact/edit/' . $category->cid),
      l(t('Delete'), 'admin/structure/contact/delete/' . $category->cid),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No categories available.'),
        'colspan' => 5,
      ),
    );
  }
  $build['category_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  );
  return $build;
}