You are here

function hook_mail_safety_table_structure_alter in Mail Safety 7.2

Same name and namespace in other branches
  1. 8 mail_safety.api.php \hook_mail_safety_table_structure_alter()
  2. 7 mail_safety.api.php \hook_mail_safety_table_structure_alter()

Alter the table structure of the mail safety dashboard.

Parameters

array $table_structure: The table structure that will be rendered as table.

File

./mail_safety.api.php, line 74
Hooks provided by the Mail Safety module.

Code

function hook_mail_safety_table_structure_alter($table_structure) {

  // Add a new column.
  $table_structure['header'][] = array(
    'data' => t('Files'),
  );

  // Loop through the mails to add the attachments in the table.
  foreach ($table_structure['rows'] as $mail_id => $row) {
    $mail = mail_safety_load($mail_id);
    if (!empty($mail['mail']['attachments'])) {
      $attachments = array();
      foreach ($mail['mail']['attachments'] as $attachment) {
        $attachments[] = array(
          '#theme' => 'file_link',
          '#file' => $attachment,
        );
      }
    }
    $table_structure['rows'][$mail_id]['data'][] = $attachments;
  }
  return $table_structure;
}