You are here

function skinr_ui_import_form_validate in Skinr 6.2

Same name and namespace in other branches
  1. 7.2 skinr_ui.admin.inc \skinr_ui_import_form_validate()

Validation handler for Skinr settings import form.

File

./skinr_ui.admin.inc, line 733
Admin page callbacks for the skinr module.

Code

function skinr_ui_import_form_validate(&$form, &$form_state) {
  if (empty($form_state['values']['skinr_settings'])) {

    // Error.
    form_error($form['skinr_settings'], t('These are not valid Skinr settings.'));
    return;
  }
  $skinrs = '';
  ob_start();
  eval($form_state['values']['skinr_settings']);
  ob_end_clean();
  foreach ($skinrs as $module => $ignored) {
    if (!is_array($skinrs[$module])) {

      // Error.
      form_error($form['skinr_settings'], t('These are not valid Skinr settings.'));
    }
    foreach ($skinrs[$module] as $sid => $ignored) {
      if (!is_array($skinrs[$module][$sid])) {

        // Error.
        form_error($form['skinr_settings'], t('These are not valid Skinr settings.'));
      }

      // Cast skinr array to object so we can actually use it.
      $skinrs[$module][$sid] = (object) $skinrs[$module][$sid];
      if (!skinr_validate($skinrs[$module][$sid])) {

        // Error.
        form_error($form['skinr_settings'], t('These are not valid Skinr settings.'));
      }
    }
  }
  if (!empty($form_state['values']['theme']) && preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['theme'])) {
    form_error($form['theme'], t('The theme name must be alphanumeric and can contain underscores only.'));
  }
  $form_state['skinrs'] =& $skinrs;
}