Ejemplo n.º 1
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");
	}