function brilliant_gallery_admin_validate in Brilliant Gallery 6.4
Same name and namespace in other branches
- 7.2 brilliant_gallery_config.inc \brilliant_gallery_admin_validate()
- 7 brilliant_gallery.module \brilliant_gallery_admin_validate()
File
- ./
brilliant_gallery.module, line 297
Code
function brilliant_gallery_admin_validate($form, &$form_state) {
$brilliant_gallery_folder = $form_state['values']['brilliant_gallery_folder'];
if (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 a slash.');
}
$dir = realpath(file_directory_path()) . '/' . $brilliant_gallery_folder;
if (!file_exists($dir) or !is_dir($dir)) {
form_set_error('brilliant_gallery_folder', 'Directory ' . $brilliant_gallery_folder . ' does not exist in ' . file_directory_path() . '/');
}
$brilliant_gallery_pcache = $form_state['values']['brilliant_gallery_pcache'];
if (trim($brilliant_gallery_pcache) == '') {
$brilliant_gallery_pcache = BRILLIANT_GALLERY_DEFAULT_CACHE_DIR;
}
if (substr($brilliant_gallery_pcache, 0, 1) == "/" or substr($brilliant_gallery_pcache, -1, 1) == "/") {
form_set_error('brilliant_gallery_pcache', 'The path should not start or end with a slash.');
}
else {
// The directory either exists or we attempt to create it now.
$path = file_create_path($brilliant_gallery_pcache);
if (file_check_directory($path, FILE_CREATE_DIRECTORY)) {
// All OK, the directory exists or was just created.
//variable_set('brilliant_gallery_pcache', $brilliant_gallery_pcache);
$form_state['values']['brilliant_gallery_pcache'] = $brilliant_gallery_pcache;
// Why not set it as well.
//$tst = variable_get('brilliant_gallery_pcache', BRILLIANT_GALLERY_DEFAULT_CACHE_DIR);
//return $default_dir;
}
else {
form_set_error('brilliant_gallery_pcache', "Directory " . $brilliant_gallery_pcache . " in your /files folder either could not be created or is not writable.");
}
}
/*
function brilliant_gallery_check_or_create_dir($default_dir) {
$path = file_create_path($default_dir);
if (file_check_directory($path, FILE_CREATE_DIRECTORY)) {
return $default_dir;
} else {
$errmsg = "Directory ".$default_dir." in your /files folder either could not be created or is not writable.";
drupal_set_message($errmsg);
watchdog('Brilliant Gal',$errmsg);
}
}
*/
}