function uc_file_user_form_validate in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_file/uc_file.module \uc_file_user_form_validate()
Validation handler for per-user file download administration.
See also
File
- uc_file/
uc_file.module, line 262 - Allows products to be associated with downloadable files.
Code
function uc_file_user_form_validate($form, &$form_state) {
$edit = $form_state['values'];
// Determine if any downloads were modified.
if (isset($edit['file_download'])) {
foreach ((array) $edit['file_download'] as $key => $download_modification) {
// We don't care... it's about to be deleted.
if ($download_modification['remove']) {
continue;
}
if ($download_modification['download_limit'] < 0) {
form_set_error('file_download][' . $key . '][download_limit', t('A negative download limit does not make sense. Please enter a positive integer, or leave empty for no limit.'));
}
if ($download_modification['address_limit'] < 0) {
form_set_error('file_download][' . $key . '][address_limit', t('A negative address limit does not make sense. Please enter a positive integer, or leave empty for no limit.'));
}
// Some expirations don't need any validation...
if ($download_modification['time_granularity'] == 'never' || !$download_modification['time_quantity']) {
continue;
}
// Either use the current expiration, or if there's none,
// start from right now.
$new_expiration = _uc_file_expiration_date($download_modification, $download_modification['expiration']);
if ($new_expiration <= REQUEST_TIME) {
form_set_error('file_download][' . $key . '][time_quantity', t('The date %date has already occurred.', array(
'%date' => format_date($new_expiration, 'short'),
)));
}
if ($download_modification['time_quantity'] < 0) {
form_set_error('file_download][' . $key . '][time_quantity', t('A negative expiration quantity does not make sense. Use the polarity control to determine if the time should be added or subtracted.'));
}
}
}
}