You are here

function theme_webform_protected_downloads_mail_token_file_list in Webform Protected Downloads 7

Same name and namespace in other branches
  1. 6 webform_protected_downloads.module \theme_webform_protected_downloads_mail_token_file_list()

Theme function for the file list that may be included in the confirmation mail which is send to the user.

Parameters

array $files:

boolean $checksum:

Return value

string

File

./webform_protected_downloads.module, line 1179
This file contains hook declarations and functions for the Webform Protected Downloads module.

Code

function theme_webform_protected_downloads_mail_token_file_list($variables) {
  $files = $variables['files'];
  $checksum = $variables['checksum'];
  $rendered_files = array();
  foreach ($files as $file) {
    if (!webform_protected_downloads_file_is_protected($file->nid, $file->fid)) {
      continue;
    }
    $args = array(
      '!filename' => $file->filename,
      '!size' => format_size($file->filesize),
      '!type' => $file->filemime,
    );
    if ($checksum === FALSE) {
      $rendered_files[] = t('!filename (!size, !type)', $args);
    }
    else {
      $args['!checksum'] = md5_file(drupal_realpath($file->uri));
      $rendered_files[] = t('!filename (!size, !type, checksum: !checksum)', $args);
    }
  }
  return count($rendered_files) ? implode("\n", $rendered_files) : '';
}