function photos_admin_settings_validate in Album Photos 6.2
Same name and namespace in other branches
- 7.3 inc/photos.admin.inc \photos_admin_settings_validate()
1 string reference to 'photos_admin_settings_validate'
File
- inc/
photos.admin.inc, line 456
Code
function photos_admin_settings_validate($form, &$form_state) {
$title = array();
if ($form_state['values']['photos_thumb_create_time'] && !$form_state['values']['photos_access_photos']) {
form_set_error('photos_thumb_create_time', t('Album privacy settings must be enabled: !url', array(
'!url' => '<a href="#edit-photos-thumb-create-time-0-wrapper">#</a>',
)));
return;
}
for ($i = 0; $i < $form_state['values']['photos_thumb_count']; $i++) {
if ($form_state['values']['photos_title_' . $i]) {
if (!$form_state['values']['photos_size_' . $i]) {
form_set_error('photos_size_' . $i, t('May not be empty'));
return;
}
$array = array(
'%uid',
'%username',
'%Y',
'%m',
'%d',
);
$topdir = current(explode('/', $form_state['values']['photos_path']));
if (preg_match('/%uid|%username|%Y|%m|%d/i', $topdir)) {
form_set_error('photos_path', t('Variables(%uid, %username, %Y, %m, %d) can not be on the top floor'));
return;
}
if (preg_match('/[^a-zA-z0-9]/i', $form_state['values']['photos_title_' . $i])) {
form_set_error('photos_title_' . $i, t('Allow only letters and numbers'));
return;
}
if (preg_match('/[^0-9x]/i', $form_state['values']['photos_size_' . $i])) {
form_set_error('photos_size_' . $i, t('Formats such as: 100x100'));
return;
}
if (in_array($form_state['values']['photos_title_' . $i], $title)) {
form_set_error('photos_title_' . $i, t('Not allowed to repeat'));
return;
}
$title[] = $form_state['values']['photos_title_' . $i];
if (strstr($form_state['values']['photos_title_' . $i], '_')) {
form_set_error('photos_title_' . $i, t('Not allowed to use "_"'));
return;
}
}
else {
if ($form_state['values']['photos_size_' . $i]) {
form_set_error('photos_title_' . $i, t('May not be empty'));
return;
}
}
}
}