You are here

function mail_logger_overview in Mail Logger 6

Same name and namespace in other branches
  1. 5 mail_logger.module \mail_logger_overview()
  2. 7 mail_logger.pages.inc \mail_logger_overview()

Menu callback; displays a listing of log mails.

1 string reference to 'mail_logger_overview'
mail_logger_menu in ./mail_logger.module
Implementation of hook_menu().

File

./mail_logger.module, line 168
Mail Logger module logs all outgoing mail that passes through the drupal_mail function.

Code

function mail_logger_overview() {
  $output = drupal_get_form('mail_logger_form_overview');
  $header = array(
    array(
      'data' => t('Date Sent'),
      'field' => 'ml.date_sent',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Mailkey'),
      'field' => 'ml.mailkey',
    ),
    array(
      'data' => t('Language'),
      'field' => 'ml.language',
    ),
    array(
      'data' => t('To'),
      'field' => 'ml.mail_to',
    ),
    array(
      'data' => t('From'),
      'field' => 'ml.mail_from',
    ),
    array(
      'data' => t('Subject'),
      'field' => 'ml.subject',
    ),
  );
  $tablesort = tablesort_sql($header);
  $sql = "SELECT ml.mlid, ml.mailkey, ml.language, ml.mail_to, ml.mail_from, ml.subject, ml.date_sent FROM {mail_logger} ml";
  $type = $_SESSION['mail_logger_overview_filter'];
  if ($type != 'all') {
    $result = pager_query($sql . " WHERE ml.mailkey = '%s'" . $tablesort, 50, 0, NULL, $type);
  }
  else {
    $result = pager_query($sql . $tablesort, 50);
  }
  $rows = array();
  while ($mail_logger = db_fetch_object($result)) {
    $rows[] = array(
      'data' => array(
        // Cells
        format_date($mail_logger->date_sent, 'small'),
        $mail_logger->mailkey,
        $mail_logger->language,
        $mail_logger->mail_to,
        $mail_logger->mail_from,
        l(truncate_utf8($mail_logger->subject, 56, TRUE, TRUE), 'admin/reports/mail-logger/mail/' . $mail_logger->mlid),
      ),
    );
  }
  if (!count($rows)) {
    $rows[] = array(
      array(
        'data' => t('No log messages available.'),
        'colspan' => 6,
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, 50, 0);
  return $output;
}