You are here

function _support_mail_list_attachments in Support Ticketing System 7

Same name and namespace in other branches
  1. 6 support.module \_support_mail_list_attachments()

List all ticket attachments associated with this update, if any.

1 call to _support_mail_list_attachments()
support_mail_tokens in ./support.module
Return an array of token to value mappings for support e-mail messages.

File

./support.module, line 1530
support.module

Code

function _support_mail_list_attachments($node, $comment) {
  $attachments = array();
  $field = variable_get('support_mail_upload_field', 'support_ticket_upload');

  // If there isn't a comment, look at the node for attachments.
  if (empty($comment)) {
    if (is_object($node)) {

      // Try using the defined upload field first.
      if (!empty($node->{$field}[LANGUAGE_NONE])) {
        foreach ($node->{$field}[LANGUAGE_NONE] as $file) {
          $attachments[] = file_create_url($file['uri']);
        }
      }
      elseif (!empty($node->upload[LANGUAGE_NONE])) {
        foreach ($node->upload[LANGUAGE_NONE] as $file) {
          $attachments[] = file_create_url($file['uri']);
        }
      }
    }
  }
  elseif (!empty($comment->{$field}[LANGUAGE_NONE])) {
    foreach ($comment->{$field}[LANGUAGE_NONE] as $file) {

      // Load full file object.
      $file = file_load($file['fid']);
      $attachments[] = file_create_url($file->uri);
    }
  }
  return !empty($attachments) ? "<br />\n" . t('Attachments:') . "<br />\n" . implode("<br />\n", $attachments) : '';
}