You are here

function mailing_list_lists in Mailing List 7

Same name and namespace in other branches
  1. 6 mailing_list.admin.inc \mailing_list_lists()

Menu callback; displays all mailing lists in a table.

1 string reference to 'mailing_list_lists'
mailing_list_menu in ./mailing_list.module
Implement hook_menu().

File

./mailing_list.admin.inc, line 11
Mailing list admin UI.

Code

function mailing_list_lists() {
  $header = array(
    array(
      'data' => t('Name'),
      'field' => 'name',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Operations'),
      'colspan' => '5',
    ),
  );
  $lists = mailing_list_get();
  $rows = array();
  $destination = drupal_get_destination();
  foreach ($lists as $mlid => $list) {
    $row = array(
      l(check_plain($list->name), "admin/structure/mailing-list/{$list->mlid}"),
      l(t('list e-mails'), "admin/structure/mailing-list/{$list->mlid}"),
      l(t('import e-mails'), "admin/structure/mailing-list/{$list->mlid}/import", array(
        'query' => $destination,
      )),
      l(t('export list'), "admin/structure/mailing-list/{$list->mlid}/export", array(
        'query' => $destination,
      )),
      l(t('rename list'), "admin/structure/mailing-list/{$list->mlid}/edit", array(
        'query' => $destination,
      )),
      l(t('delete list'), "admin/structure/mailing-list/{$list->mlid}/delete", array(
        'query' => $destination,
      )),
    );
    $rows[] = $row;
  }
  if (empty($rows)) {
    $empty_message = t('No mailing lists found.');
    $rows[] = array(
      array(
        'data' => $empty_message,
        'colspan' => 6,
      ),
    );
  }

  // @todo: Perhaps change to $build arrays or even table select?
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  return $output;
}