function dynamic_banner_admin_form_validate in Dynamic Banner 7.2
Same name and namespace in other branches
- 6 includes/callbacks.inc \dynamic_banner_admin_form_validate()
- 7 includes/callbacks.inc \dynamic_banner_admin_form_validate()
- 8.x dynamic_banner.module \dynamic_banner_admin_form_validate()
Verify that the Banner being submitted by the user is valid.
File
- ./
dynamic_banner.module, line 744 - Distributed under GNU GPL version 3
Code
function dynamic_banner_admin_form_validate($form, &$form_state) {
// For a banner to exist it needs a path and an image (either just uploaded or set manually).
if (isset($form_state['values']['path']) && (isset($form_state['values']['image']) || isset($form_state['values']['imgurl']))) {
$path = $form_state['values']['path'];
if ($path != 'DEFAULT') {
// Unique path check.
if (db_query('SELECT COUNT(path) FROM {dynamic_banner} WHERE path = :path', array(
':path' => $path,
))
->fetchField() > 1) {
form_set_error('path', t('The path %path is already in use.', array(
'%path' => $path,
)));
}
// Path is not clean at this point because of wildcard and random must chop those characters off.
// Find the * or wildcard.
$wild_position = strrpos($path, '*');
if ($wild_position !== FALSE) {
$path = drupal_substr($path, 0, $wild_position);
}
// Find the ! or random
$rand_position = strrpos($path, '!');
if ($rand_position !== FALSE) {
$path = drupal_substr($path, 0, $rand_position);
}
if (drupal_valid_path($path)) {
// We are making a new banner previous checks should be enough to deal with validation
$dbid = arg(4);
if ($dbid != 0) {
return;
}
}
else {
form_set_error('path', t('The path %path is not known by drupal.', array(
'%path' => $path,
)));
return;
}
}
}
else {
form_set_error('path', t('There was a problem with the required fields please check the form and try again.'));
return;
}
}