You are here

function download_field_presave in Download 7

Same name and namespace in other branches
  1. 7.2 download.module \download_field_presave()

File

./download.module, line 168
Handles module administration and download link

Code

function download_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  foreach ($items as $key => $item) {
    if (isset($item['download_fields'])) {
      $fields = '';
      foreach ($item['download_fields'] as $fieldname => $value) {
        if ($value != '0') {
          $fields .= $fieldname . ';';
        }
      }
      if ($fields == '') {
        unset($items[$key]);
      }
      else {
        $items[$key]['download_fields'] = $fields;
      }
    }
  }
}