function imce_fileop_form_validate in IMCE 6.2
Same name and namespace in other branches
- 6 inc/page.inc \imce_fileop_form_validate()
- 7 inc/imce.page.inc \imce_fileop_form_validate()
Validate file operations form.
File
- inc/
imce.page.inc, line 250 - Implements the file browser.
Code
function imce_fileop_form_validate($form, &$form_state) {
$imce =& $form['#parameters'][2]['imce'];
//check if the filenames is empty
if ($form_state['values']['filenames'] == '') {
return form_error($form['filenames'], t('Please select a file.'));
}
//filenames come separated by colon
$filenames = explode(':', $form_state['values']['filenames']);
$cnt = count($filenames);
//check the number of files.
if ($imce['filenum'] && $cnt > $imce['filenum']) {
return form_error($form['filenames'], t('You are not allowed to operate on more than %num files.', array(
'%num' => $imce['filenum'],
)));
}
//check if there is any illegal choice
for ($i = 0; $i < $cnt; $i++) {
$filenames[$i] = $filename = rawurldecode($filenames[$i]);
if (!isset($imce['files'][$filename])) {
watchdog('imce', 'Illegal choice %choice in !name element.', array(
'%choice' => $filename,
'!name' => t('directory (%dir)', array(
'%dir' => file_directory_path() . ($imce['dir'] == '.' ? '' : '/' . $imce['dir']),
)),
), WATCHDOG_ERROR);
return form_error($form['filenames'], t('An illegal choice has been detected. Please contact the site administrator.'));
}
}
$form_state['values']['filenames'] = $filenames;
}