You are here

function uc_repeater_admin_settings_submit in Ubercart 5

File

uc_repeater/uc_repeater.module, line 114
Allows a multisite setup to share changes to the catalog.

Code

function uc_repeater_admin_settings_submit($form_id, $form_values) {
  if ($form_values['op'] == t('Reset to defaults')) {
    variable_del('uc_repeater_slaves');
    variable_del('uc_repeater_masters');
    drupal_set_message(t('The configuration options have been reset to their default values.'));
  }
  else {
    foreach (array(
      'uc_repeater_slaves',
      'uc_repeater_masters',
    ) as $var) {
      $values = array_filter(explode("\n", trim($form_values[$var])));
      foreach ($values as $key => $input) {
        $url = explode(' ', trim($input), 2);
        if ($url[0]) {
          $site = parse_url($url[0]);
          $values[$key] = $site['host'] . (isset($site['port']) ? ':' . $site['port'] : '') . $site['path'];
        }
      }
      variable_set($var, $values);
    }
    drupal_set_message(t('The configuration options have been saved.'));
  }
}