You are here

function mailhandler_list_mailboxes in Mailhandler 6

Same name and namespace in other branches
  1. 7 mailhandler.admin.inc \mailhandler_list_mailboxes()

Displays a list of mailboxes with operations.

Return value

Mailboxes list rendered content.

1 string reference to 'mailhandler_list_mailboxes'
mailhandler_menu in ./mailhandler.module
Implementation of hook_menu().

File

./mailhandler.admin.inc, line 327
Administrator pages for the Mailhandler module.

Code

function mailhandler_list_mailboxes() {
  $rows = array();

  // Define a table header.
  $header = array(
    t('Mailbox'),
    t('Folder'),
    array(
      'data' => t('Operations'),
      'colspan' => 4,
    ),
  );

  // Show all the emails configured.
  foreach (mailhandler_mailbox_load_multiple() as $mid => $mailbox) {
    $rows[] = array(
      '<a href="mailto:' . $mailbox->mail . '">' . $mailbox->mail . '</a>',
      $mailbox->folder ? check_plain($mailbox->folder) : '',
      l(t('Retrieve'), 'admin/content/mailhandler/retrieve/' . $mid, array(
        'attributes' => array(
          'title' => t('Retrieve and process pending e-mails in this mailbox.'),
        ),
      )),
      l(t('Edit'), 'admin/content/mailhandler/edit/' . $mid, array(
        'attributes' => array(
          'title' => t('Edit this mailbox configuration.'),
        ),
      )),
      l(t('Clone'), 'admin/content/mailhandler/clone/' . $mid, array(
        'attributes' => array(
          'title' => t('Add a new mailbox, using this mailbox configuration as a template.'),
        ),
      )),
      l(t('Delete'), 'admin/content/mailhandler/delete/' . $mid, array(
        'attributes' => array(
          'title' => t('Delete this mailbox.'),
        ),
      )),
    );
  }

  // Show the list of mailboxes as a themed table.
  return theme('table', $header, count($rows) ? $rows : array(
    array(
      array(
        'data' => '<em>' . t('No mailboxes have been defined.') . '</em>',
        'colspan' => 4,
      ),
    ),
  ));
}