Ejemplo n.º 1
0
 /**
  * Displays the General Settings screen and processes updates
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @return void
  **/
 public function setup()
 {
     if (!current_user_can('shopp_settings')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     // Welcome screen handling
     if (!empty($_POST['setup'])) {
         $_POST['settings']['display_welcome'] = 'off';
         shopp_set_formsettings();
     }
     $country = isset($_POST['settings']) && isset($_POST['settings']['base_operations']) ? $_POST['settings']['base_operations']['country'] : '';
     $countries = array();
     $countrydata = Lookup::countries();
     $country_zones = Lookup::country_zones();
     foreach ($countrydata as $iso => $c) {
         if ($country == $iso) {
             $base_region = $c['region'];
         }
         $countries[$iso] = $c['name'];
     }
     // Save settings
     if (!empty($_POST['save']) && isset($_POST['settings'])) {
         check_admin_referer('shopp-setup');
         if (isset($_POST['settings']['base_operations'])) {
             $baseop =& $_POST['settings']['base_operations'];
             $zone = isset($baseop['zone']) && isset($country_zones[$country]) && isset($country_zones[$country][$baseop['zone']]) ? $baseop['zone'] : false;
             if (isset($countrydata[$country])) {
                 $baseop = $countrydata[$country];
             }
             $baseop['country'] = $country;
             $baseop['zone'] = $zone;
             $baseop['currency']['format'] = scan_money_format($baseop['currency']['format']);
             if (is_array($baseop['currency']['format'])) {
                 $fields = array_keys($baseop['currency']['format']);
                 foreach ($fields as $field) {
                     if (isset($baseop['currency'][$field])) {
                         $baseop['currency']['format'][$field] = $baseop['currency'][$field];
                     }
                 }
             }
             shopp_set_setting('tax_inclusive', in_array($country, Lookup::country_inclusive_taxes()) ? 'on' : 'off');
         }
         if (!isset($_POST['settings']['target_markets'])) {
             asort($_POST['settings']['target_markets']);
         }
         shopp_set_formsettings();
         $updated = __('Shopp settings saved.', 'Shopp');
     }
     $operations = shopp_setting('base_operations');
     if (isset($country_zones[$operations['country']])) {
         $zones = $country_zones[$operations['country']];
     }
     $targets = shopp_setting('target_markets');
     if (is_array($targets)) {
         $targets = array_map('stripslashes', $targets);
     }
     if (!$targets) {
         $targets = array();
     }
     include $this->ui('setup.php');
 }
 /**
  * Settings flow handlers
  **/
 function settings_general()
 {
     global $Shopp;
     if (!current_user_can('manage_options')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $country = isset($_POST['settings']) ? $_POST['settings']['base_operations']['country'] : '';
     $countries = array();
     $countrydata = $Shopp->Settings->get('countries');
     foreach ($countrydata as $iso => $c) {
         if (isset($_POST['settings']) && $_POST['settings']['base_operations']['country'] == $iso) {
             $base_region = $c['region'];
         }
         $countries[$iso] = $c['name'];
     }
     if (!empty($_POST['setup'])) {
         $_POST['settings']['display_welcome'] = "off";
         $this->settings_save();
     }
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-settings-general');
         $vat_countries = $Shopp->Settings->get('vat_countries');
         $zone = $_POST['settings']['base_operations']['zone'];
         $_POST['settings']['base_operations'] = $countrydata[$_POST['settings']['base_operations']['country']];
         $_POST['settings']['base_operations']['country'] = $country;
         $_POST['settings']['base_operations']['zone'] = $zone;
         $_POST['settings']['base_operations']['currency']['format'] = scan_money_format($_POST['settings']['base_operations']['currency']['format']);
         if (in_array($_POST['settings']['base_operations']['country'], $vat_countries)) {
             $_POST['settings']['base_operations']['vat'] = true;
         } else {
             $_POST['settings']['base_operations']['vat'] = false;
         }
         $this->settings_save();
         $updated = __('Shopp settings saved.');
     }
     $operations = $Shopp->Settings->get('base_operations');
     if (!empty($operations['zone'])) {
         $zones = $Shopp->Settings->get('zones');
         $zones = $zones[$operations['country']];
     }
     $targets = $Shopp->Settings->get('target_markets');
     if (!$targets) {
         $targets = array();
     }
     $statusLabels = $Shopp->Settings->get('order_status');
     include SHOPP_ADMINPATH . "/settings/settings.php";
 }
Ejemplo n.º 3
0
	/**
	 * Displays the General Settings screen and processes updates
	 *	 
	 * @since 1.0
	 *
	 * @return void
	 **/
	function general () {
		global $Ecart;
		if ( !(current_user_can('manage_options') && current_user_can('ecart_settings')) )
			wp_die(__('You do not have sufficient permissions to access this page.'));

		$updatekey = $Ecart->Settings->get('updatekey');
		$activated = ($updatekey[0] == "1");
		$type = "text";
		$key = $updatekey[1];
		if (isset($updatekey[2]) && $updatekey[2] == "dev") {
			$type = "password";
			$key = preg_replace('/\w/','?',$key);
		}

		$country = (isset($_POST['settings']))?$_POST['settings']['base_operations']['country']:'';
		$countries = array();
		$countrydata = Lookup::countries();
		foreach ($countrydata as $iso => $c) {
			if (isset($_POST['settings']) && $_POST['settings']['base_operations']['country'] == $iso)
				$base_region = $c['region'];
			$countries[$iso] = $c['name'];
		}

		if (!empty($_POST['setup'])) {
			$_POST['settings']['display_welcome'] = "off";
			$this->settings_save();
		}

		if (!empty($_POST['save'])) {
			check_admin_referer('ecart-settings-general');
			$vat_countries = Lookup::vat_countries();
			$zone = $_POST['settings']['base_operations']['zone'];
			$_POST['settings']['base_operations'] = $countrydata[$_POST['settings']['base_operations']['country']];
			$_POST['settings']['base_operations']['country'] = $country;
			$_POST['settings']['base_operations']['zone'] = $zone;
			$_POST['settings']['base_operations']['currency']['format'] =
				scan_money_format($_POST['settings']['base_operations']['currency']['format']);
			if (in_array($_POST['settings']['base_operations']['country'],$vat_countries))
				$_POST['settings']['base_operations']['vat'] = true;
			else $_POST['settings']['base_operations']['vat'] = false;

			if (!isset($_POST['settings']['target_markets']))
				asort($_POST['settings']['target_markets']);

			$this->settings_save();
			$updated = __('Ecart settings saved.', 'Ecart');
		}

		$operations = $Ecart->Settings->get('base_operations');
		if (!empty($operations['zone'])) {
			$zones = Lookup::country_zones();
			$zones = $zones[$operations['country']];
		}

		$targets = $Ecart->Settings->get('target_markets');
		if (!$targets) $targets = array();

		$statusLabels = $Ecart->Settings->get('order_status');
		include(ECART_ADMIN_PATH."/settings/settings.php");
	}