function brilliant_gallery_admin_validate in Brilliant Gallery 7.2
Same name and namespace in other branches
- 6.4 brilliant_gallery.module \brilliant_gallery_admin_validate()
- 7 brilliant_gallery.module \brilliant_gallery_admin_validate()
Validating some configuration options.
File
- ./
brilliant_gallery_config.inc, line 34
Code
function brilliant_gallery_admin_validate($form, &$form_state) {
$brilliant_gallery_folder = $form_state['values']['brilliant_gallery_folder'];
$dir = 'public://' . $brilliant_gallery_folder;
if ($brilliant_gallery_folder == "") {
form_set_error('brilliant_gallery_folder', 'Please define a root album folder you (will) have in the files/ folder of this site.');
}
else {
if (substr($brilliant_gallery_folder, 0, 1) == "/" or substr($brilliant_gallery_folder, -1, 1) == "/" or substr($brilliant_gallery_folder, 0, 1) == " " or substr($brilliant_gallery_folder, -1, 1) == " ") {
form_set_error('brilliant_gallery_folder', 'The path should not start or end with spaces or slashes.');
}
else {
if (!file_exists($dir) or !is_dir($dir)) {
// If the dir does not exist, attempt to create it or throw an error.
if (!mkdir($dir)) {
form_set_error('brilliant_gallery_folder', 'Directory ' . $brilliant_gallery_folder . ' does not exist in ' . 'public://' . ' and it was not possible to create it automatically.');
}
}
}
}
}