function uc_file_feature_settings_validate in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_file/uc_file.module \uc_file_feature_settings_validate()
- 7.3 uc_file/uc_file.module \uc_file_feature_settings_validate()
Sanity check for feature settings.
See also
uc_file_feature_settings_submit()
1 string reference to 'uc_file_feature_settings_validate'
- uc_file_form_uc_product_feature_settings_form_alter in uc_file/
uc_file.module - Implements hook_form_FORM_ID_alter() for uc_product_feature_settings_form().
File
- uc_file/
uc_file.module, line 1060
Code
function uc_file_feature_settings_validate($form, &$form_state) {
// Make sure our base directory is valid.
if (!empty($form_state['values']['uc_file_base_dir']) && $form_state['values']['op'] == t('Save configuration') && !is_dir($form_state['values']['uc_file_base_dir'])) {
form_set_error('uc_file_base_dir', t('%dir is not a valid file or directory', array(
'%dir' => $form_state['values']['uc_file_base_dir'],
)));
}
// If the user selected a granularity, let's make sure they
// also selected a duration.
if ($form_state['values']['uc_file_download_limit_duration_granularity'] != 'never' && $form_state['values']['uc_file_download_limit_duration_qty'] < 1) {
form_set_error('uc_file_download_limit_duration_qty', t('You set the granularity (%gran), but you did not set how many. Please enter a positive non-zero integer.', array(
'%gran' => $form_state['values']['uc_file_download_limit_duration_granularity'] . '(s)',
)));
}
// Make sure the download limit makes sense.
if ($form_state['values']['uc_file_download_limit_number'] < 0) {
form_set_error('uc_file_download_limit_number', t('A negative download limit does not make sense. Please enter a positive integer, or leave empty for no limit.'));
}
// Make sure the address limit makes sense.
if ($form_state['values']['uc_file_download_limit_addresses'] < 0) {
form_set_error('uc_file_download_limit_addresses', t('A negative IP address limit does not make sense. Please enter a positive integer, or leave empty for no limit.'));
}
}