You are here

function photos_admin_settings_validate in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 inc/photos.admin.inc \photos_admin_settings_validate()

Validate admin form.

1 string reference to 'photos_admin_settings_validate'
photos_admin_settings in inc/photos.admin.inc
@file Admin settings form(s) and submit handler.

File

inc/photos.admin.inc, line 429
Admin settings form(s) and submit handler.

Code

function photos_admin_settings_validate($form, &$form_state) {
  $size = array();
  for ($i = 0; $i < $form_state['values']['photos_thumb_count']; $i++) {
    if (isset($form_state['values']['photos_size_' . $i]) && !empty($form_state['values']['photos_size_' . $i])) {
      $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 (in_array($form_state['values']['photos_size_' . $i], $size)) {
        form_set_error('photos_size_' . $i, t('Not allowed to repeat'));
        return;
      }
      $size[] = $form_state['values']['photos_size_' . $i];
    }
  }
}