public function initializeAdmin()
	{
		$quantity = 1;

		if (isset($GLOBAL['var_orders'])) {
			$quantity = $GLOBAL['var_orders'];
		}

		// If we're using a cart quantity drop down, load that
		if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
			$GLOBALS['SelectId'] = "orders";
			$GLOBALS['Qty0'] = Interspire_Template::getInstance('admin')->render('Snippets/DiscountItemQtySelect.html');
		// Otherwise, load the textbox
		} else {
			$GLOBALS['SelectId'] = "orders";
			$GLOBALS['Qty0'] = Interspire_Template::getInstance('admin')->render('Snippets/DiscountItemQtyText.html');
		}

		if (!isset($GLOBALS['var_ps'])) {
			$GLOBALS['var_ps'] = GetLang('ChooseAProduct');
		}

		$currency = GetDefaultCurrency();
		if ($currency['currencystringposition'] == "LEFT") {
			$GLOBALS['CurrencyLeft'] = $currency['currencystring'];
		}
		else {
			$GLOBALS['CurrencyRight'] =  $currency['currencystring'];
		}
	}
Beispiel #2
0
		public function GetPropertiesSheet($tab_id)
		{
			parent::PreparePropertiesSheet($tab_id, 'ShipperId', 'NotificationJavaScript', 'notification_selected');

			$query = sprintf("select count(variableid) as is_setup from [|PREFIX|]module_vars where modulename='%s' and variablename='is_setup' and variableval='1'", $GLOBALS['ISC_CLASS_DB']->Quote($this->GetId()));
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);

			// Add the test notification link
			if($this->_showtestlink) {
				if($row['is_setup'] > 0) {
					$GLOBALS['PropertyBox'] = sprintf("<a href='javascript:void(0)' onclick='openwin(\"index.php?ToDo=testNotificationMethodSettings&module=%s\", \"%s\", 500, %s)'>%s</a>", $this->GetId(), $this->GetId(), $this->getheight(), GetLang('TestNotificationMethod'));
				}
				else {
					$GLOBALS['PropertyBox'] = sprintf("<a href='javascript:void(0)' onclick='alert(\"%s\")'>%s</a>", GetLang('NotificationProviderNotSetup'), GetLang('TestNotificationMethod'));
				}

				$help_id = rand(1000,100000);
				$GLOBALS['PropertyName'] = "";
				$GLOBALS['Required'] = "";
				$GLOBALS['PanelBottom'] = "PanelBottom";
				$GLOBALS['HelpTip'] = sprintf("<img onmouseout=\"HideHelp('d%d')\" onmouseover=\"ShowHelp('d%d', '%s', '%s')\" src=\"images/help.gif\" width=\"24\" height=\"16\" border=\"0\"><div style=\"display:none\" id=\"d%d\"></div>", $help_id, $help_id, GetLang('TestNotificationMethod'), GetLang('TestNotificationProviderHelp'), $help_id);

				$GLOBALS['Properties'] .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
			}

			return Interspire_Template::getInstance('admin')->render('module.propertysheet.tpl');
		}
Beispiel #3
0
	public function __construct()
	{
		/**
		 * Convert the input character set from the hard coded UTF-8 to their
		 * selected character set
		 */
		convertRequestInput();

		$this->template = Interspire_Template::getInstance('admin');
		$this->db = $GLOBALS['ISC_CLASS_DB'];
		$this->auth = getClass('ISC_ADMIN_AUTH');
		$this->engine = getClass('ISC_ADMIN_ENGINE');
		parent::__construct();
	}
Beispiel #4
0
	public function __construct()
	{
		if(defined('ISC_ADMIN_CP')) {
			$this->template = Interspire_Template::getInstance('admin');
			$this->auth = getClass('ISC_ADMIN_AUTH');
			$this->engine = getClass('ISC_ADMIN_ENGINE');
		}

		$this->db = $GLOBALS['ISC_CLASS_DB'];

		if (isset($GLOBALS['ISC_CLASS_LOG'])) {
			// the logging global isn't available during installation
			$this->log = $GLOBALS['ISC_CLASS_LOG'];
		}
	}
Beispiel #5
0
	function initBuildTemplateInstance($templatePath)
	{
		$template = Interspire_Template::getInstance('admin', $templatePath, array(
			'charset' => getConfig('CharacterSet'),
			'cache' => getAdminTwigTemplateCacheDirectory(),
			'auto_reload' => true,
			'trim_blocks' => true
		));
		$template->assign('language', getConfig('Language'));
		$template->assign('lang', new Interspire_Template_Lang);
		$template->assign('config', new Interspire_Template_Config);
		if(getLang('RTL')) {
			$template->assign('rtl', true);
		}
	}
Beispiel #6
0
	public function __construct()
	{
		$this->template = Interspire_Template::getInstance('admin');
		$this->auth = getClass('ISC_ADMIN_AUTH');
		$this->engine = getClass('ISC_ADMIN_ENGINE');

		$this->templateDirectories = array(
			ISC_BASE_PATH.'/templates/__master/',
			ISC_BASE_PATH.'/templates/'.GetConfig('template').'/',
		);

		$this->directoryTypes = array(
			'StyleSheet' => 'Styles',
			'Layout' => '',
			'Snippet' => 'Snippets',
			'Panel' => 'Panels'
		);
	}
Beispiel #7
0
	public function initializeAdmin()
	{
		$quantity = 1;
		$quantity_free = 1;

		if (isset($GLOBAL['var_amount'])) {
			$quantity = $GLOBAL['var_amount'];
		}
		if (isset($GLOBAL['var_amount_free'])) {
			$quantity_free = $GLOBAL['var_amount_free'];
		}

		// If we're using a cart quantity drop down, load that
		if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
			$GLOBALS['SelectId'] = "amount";
			$GLOBALS['Qty0'] = Interspire_Template::getInstance('admin')->render('Snippets/DiscountItemQtySelect.html');
		// Otherwise, load the textbox
		} else {
			$GLOBALS['SelectId'] = "amount";
			$GLOBALS['Qty0'] = Interspire_Template::getInstance('admin')->render('Snippets/DiscountItemQtyText.html');
		}

		if (!isset($GLOBALS['var_ps'])) {
			$GLOBALS['var_ps'] = GetLang('ChooseAProduct');
		}

		// If we're using a cart quantity drop down, load that
		if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
			$GLOBALS['SelectId'] = "amount_free";
			$GLOBALS['Qty1'] = Interspire_Template::getInstance('admin')->render('Snippets/DiscountItemQtySelect.html');
		// Otherwise, load the textbox
		} else {
			$GLOBALS['SelectId'] = "amount_free";
			$GLOBALS['Qty1'] = Interspire_Template::getInstance('admin')->render('Snippets/DiscountItemQtyText.html');
		}

		if (!isset($GLOBALS['var_ps_free'])) {
			$GLOBALS['var_ps_free'] = GetLang('ChooseAProduct');
		}
	}
Beispiel #8
0
		/**
		 * _CheckPermissions
		 * Create the database and perform other install-orientated tasks
		 *
		 * @param none
		 *
		 * @return void
		 */
		private function RunInstall()
		{
			
				$lk = '';
				if(isset($_POST['LK'])) {
					$lk = ech0($_POST['LK']);
				}

				if(!$lk) {
					$installMessage = GetLang('LKBad');
					$installCode = "badLicenseKey";
				}

			if(!isset($_POST['StoreCountryLocationId']) || !isId($_POST['StoreCountryLocationId'])) {
				$_POST['StoreCountryLocationId'] = 227; // United States
			}

			if(!isset($_POST['StoreCurrencyCode']) || $_POST['StoreCurrencyCode'] == '') {
				$_POST['StoreCurrencyCode'] = 'USD';
			}

			if(!isset($_POST['ShopPath']) || $_POST['ShopPath'] == '') {
				$installMessage = GetLang('InstallMissingShopPath');
				$installCode = "missingShopPath";
			}
			else if (isc_strlen($_POST['StoreCurrencyCode']) > 3) {
				$installMessage = GetLang('InstallInvalidStoreCurrencyCode');
				$installCode = "invalidStoreCurrencyCode";
			}
			else if(!isset($_POST['ShopPath']) || $_POST['ShopPath'] == '') {
				$installMessage = GetLang('InstallMissingShopPath');
				$installCode = "missingShopPath";
			}
			else if(!isset($_POST['UserEmail']) || $_POST['UserEmail'] == '') {
				$installMessage = GetLang('InstallMissingUserEmail');
				$installCode = "missingUserEmail";
			}
			else if(!isset($_POST['UserPass']) || $_POST['UserPass'] == '') {
				$installMessage = GetLang('InstallMissingUserPass');
				$installCode = "missingUserPass";
			}
			else if(!isset($_POST['dbServer']) || $_POST['dbServer'] == '') {
				$installMessage = GetLang('InstallMissingDbServer');
				$installCode = "missingDbServer";
			}
			else if(!isset($_POST['dbUser']) || $_POST['dbUser'] == '') {
				$installMessage = GetLang('InstallMissingDbUser');
				$installCode = "missingDbUser";
			}
			else if(!isset($_POST['dbPass'])) {
				$installMessage = GetLang('InstallMissingDbPass');
				$installCode = "missingDbPass";
			}
			else if(!isset($_POST['dbDatabase']) || $_POST['dbDatabase'] == '') {
				$installMessage = GetLang('InstallMissingDbDatabase');
				$installCode = "missingDbDatabase";
			}

			if(!isset($_POST['tablePrefix'])) {
				$_POST['tablePrefix'] = '';
			}

			// One or more error messages were detected
			if(isset($installMessage)) {
				$errors = array(
					0 => array(
						"code" => $installCode,
						"message" => $installMessage
					)
				);
				$this->ShowInstallErrors($installMessage, $errors, false, true);
				return;
			}

			// Try to connect to the database
			$db_type = GetConfig("dbType") . 'Db';
			$db = new $db_type();

			if(isset($GLOBALS['ISC_CFG']["dbEncoding"])) {
				$db->charset = $GLOBALS['ISC_CFG']["dbEncoding"];
			}

			$connection = $db->Connect($_POST['dbServer'], $_POST['dbUser'], $_POST['dbPass'], $_POST['dbDatabase']);
			$db->TablePrefix = $_POST['tablePrefix'];

			if($connection) {
				$GLOBALS["ISC_CLASS_DB"] = &$db;

				// Are we running the required version of MySQL?
				$ver = $GLOBALS["ISC_CLASS_DB"]->FetchOne("select version() as ver");

				$mysql_check = version_compare($ver, MYSQL_VERSION_REQUIRED);

				if($mysql_check < 0) {
					$message = sprintf(GetLang("MySQLV4Message"), MYSQL_VERSION_REQUIRED, $ver);
					$errors = array(
						0 => array(
							"code" => "mysqlVersion",
							"extra" => $ver,
							"message" => $message
						)
					);
					$this->ShowInstallErrors($message, $errors, false, true);
					return;
				}
				else {
					// Run the database commands
					$queries = $this->template->render('install.schema.tpl');
					$queries = str_replace("\r", "\n", str_replace("\r\n", "\n", $queries));
					$queries = explode(";\n", $queries);
					$GLOBALS["ISC_CLASS_DB"]->Query("start transaction");

					// Initialize the admin auth class to get the list of permissions
					$auth = new ISC_ADMIN_AUTH();

					require_once(dirname(__FILE__) . "/class.user.php");
					$userManager = GetClass('ISC_ADMIN_USER');
					$pass = $_POST['UserPass'];
					$token = $userManager->_GenerateUserToken();

					foreach($queries as $query) {
						$query = str_replace("%%PREFIX%%", $_POST['tablePrefix'], $query);
						$query = str_replace("%%EMAIL%%", $GLOBALS["ISC_CLASS_DB"]->Quote($_POST['UserEmail']), $query);
						$query = str_replace("%%TOKEN%%", $GLOBALS["ISC_CLASS_DB"]->Quote($token), $query);

						if(trim($query) != "") {
							$GLOBALS["ISC_CLASS_DB"]->Query($query);
						}
					}

					// update admin user password
					$user_id = $userManager->getUserByField('username', 'admin');
					$userManager->updatePassword($user_id, $pass);

					// Give the admin user permissions
					$constants = get_defined_constants();

					foreach($constants as $constant => $val) {
						if(is_numeric(strpos($constant, "AUTH_")) && strpos($constant, "AUTH_") == 0) {
							$newPermission = array(
								"permuserid" => $user_id,
								"permpermissionid" => $val
							);
							$GLOBALS['ISC_CLASS_DB']->InsertQuery("permissions", $newPermission);
						}
					}

					// Set the version
					$db_version = array(
						'database_version' => PRODUCT_VERSION_CODE
					);
					$GLOBALS['ISC_CLASS_DB']->InsertQuery('config', $db_version);

					// Install our default currency. We need to do it here as it also needs to be in the config file
					$GLOBALS['ISC_CLASS_DB']->Query("DELETE FROM [|PREFIX|]currencies");
					$GLOBALS['ISC_CLASS_DB']->Query("ALTER TABLE [|PREFIX|]currencies AUTO_INCREMENT=1");
					$currency = array(
						'currencycountryid'			=> $_POST['StoreCountryLocationId'],
						'currencycode'				=> isc_strtoupper($_POST['StoreCurrencyCode']),
						'currencyname'				=> GetLang('InstallDefaultCurrencyName'),
						'currencyexchangerate'		=> GetConfig('DefaultCurrencyRate'),
						'currencystring'			=> html_entity_decode(GetLang('InstallDefaultCurrencyString')),
						'currencystringposition'	=> isc_strtolower(GetLang('InstallDefaultCurrencyStringPosition')),
						'currencydecimalstring'		=> GetLang('InstallDefaultCurrencyDecimalString'),
						'currencythousandstring'	=> GetLang('InstallDefaultCurrencyThousandString'),
						'currencydecimalplace'		=> GetLang('InstallDefaultCurrencyDecimalPlace'),
						'currencylastupdated'		=> time(),
						'currencyisdefault'			=> 1,
						'currencystatus'			=> 1
					);
					$defaultCurrencyId = $GLOBALS['ISC_CLASS_DB']->InsertQuery('currencies', $currency);

					// Insert the default/master shipping zone
					$GLOBALS['ISC_CLASS_DB']->Query("DELETE FROM [|PREFIX|]shipping_zones");
					$GLOBALS['ISC_CLASS_DB']->Query("ALTER TABLE [|PREFIX|]shipping_zones AUTO_INCREMENT=1");
					$masterZone = array(
						'zonename' => 'Default Zone',
						'zonetype' => 'country',
						'zonefreeshipping' => 0,
						'zonefreeshippingtotal' => 0,
						'zonehandlingtype' => 'none',
						'zonehandlingfee' => 0,
						'zonehandlingseparate' => 1,
						'zoneenabled' => 1,
						'zonedefault' => 1
					);
					$GLOBALS['ISC_CLASS_DB']->InsertQuery('shipping_zones', $masterZone);

					// Is there a custom SQL file to include?
					$customPath = ISC_BASE_PATH.'/custom';
					if(file_exists($customPath.'/install.schema.tpl')) {
						$template = Interspire_Template::getInstance('custominstall', $customPath, array(
							'cache' => getAdminTwigTemplateCacheDirectory(),
							'auto_reload' => true
						));
						$queries = $template->render('install.schema.tpl');
						$queries = str_replace("\r", "\n", str_replace("\r\n", "\n", $queries));
						$queries = explode(";\n", $queries);
						$GLOBALS['ISC_CLASS_DB']->StartTransaction();
						foreach($queries as $query) {
							$query = str_replace("%%PREFIX%%", $_POST['tablePrefix'], $query);
							if(trim($query)) {
								$GLOBALS['ISC_CLASS_DB']->Query($query);
							}
						}
						$GLOBALS['ISC_CLASS_DB']->CommitTransaction();
					}

					// Was there an error?
					if($GLOBALS["ISC_CLASS_DB"]->Error() == "") {
						$GLOBALS["ISC_CLASS_DB"]->Query("commit");

						// Save the config file
						foreach($_POST as $k => $v) {
							$GLOBALS['ISC_NEW_CFG'][$k] = $v;
						}

						// Set the email address for this user as the store admin/order email address
						$GLOBALS['ISC_NEW_CFG']['AdminEmail'] = $_POST['UserEmail'];
						$GLOBALS['ISC_NEW_CFG']['OrderEmail'] = $_POST['UserEmail'];

						$GLOBALS['ISC_NEW_CFG']['serverStamp'] = $_POST['LK'];
						$GLOBALS['ISC_CFG']['serverStamp'] = $_POST['LK'];

						$settings = GetClass('ISC_ADMIN_SETTINGS');

						$GLOBALS['ISC_NEW_CFG']['HostingProvider'] = "";


						// Can we send server details back to Interspire?
						// If we can, the HostingProvider global will also be set
						if(isset($_POST['sendServerDetails'])) {
							$this->SendServerDetails();
							if(isset($GLOBALS['InfoImage'])) {
								$GLOBALS['HiddenImage'] = $GLOBALS['InfoImage'];
							}
						}


						$GLOBALS['ISC_NEW_CFG']['ShopPath'] = $_POST['ShopPath'];
						$GLOBALS['ISC_NEW_CFG']['DefaultCurrencyID'] = $defaultCurrencyId;

						if (isset($GLOBALS['ISC_NEW_CFG']['StoreCountryLocationId'])) {
							unset($GLOBALS['ISC_NEW_CFG']['StoreCountryLocationId']);
						}
						if (isset($GLOBALS['ISC_NEW_CFG']['StoreCurrencyCode'])) {
							unset($GLOBALS['ISC_NEW_CFG']['StoreCurrencyCode']);
						}

						// set up the product images sizes
						// load the product image class to get the constants
						GetClass('ISC_PRODUCT_IMAGE');
						$GLOBALS['ISC_NEW_CFG']['ProductImagesStorewideThumbnail_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesStorewideThumbnail_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesProductPageImage_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesProductPageImage_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesGalleryThumbnail_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesGalleryThumbnail_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesZoomImage_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_ZOOM;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesZoomImage_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_ZOOM;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesTinyThumbnailsEnabled'] = 1;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesImageZoomEnabled'] = 1;

						// Build the unique encryption token
						$GLOBALS['ISC_NEW_CFG']['EncryptionToken'] = $this->_BuildEncryptionToken();

						// Set the install date
						$GLOBALS['ISC_NEW_CFG']['InstallDate'] = time();

						if ($settings->CommitSettings()) {
							// Calling commit settings a second time to ensure the config.backup.php file
							// Is written with valid data
							$settings->CommitSettings();

							// The installation is complete
							$GLOBALS['Password'] = $pass;

							// Do we need to install the sample product data? Copy that across
							if(isset($_POST['installSampleData']) && $_POST['installSampleData'] == 1) {
								$this->InstallSampleData();
							}

							// The install schemas can't predict the nested set values if custom install scripts arbitrarily add categories or pages
							// Rebuilt any nested sets instead of including their values in the install schema
							$nestedSet = new ISC_NESTEDSET_CATEGORIES();
							$nestedSet->rebuildTree();

							$nestedSet = new ISC_NESTEDSET_PAGES();
							$nestedSet->rebuildTree();

							// Remove any existing cookies
							ISC_UnsetCookie("STORESUITE_CP_TOKEN");

							//Initialize the data store system
							require_once ISC_BASE_PATH."/lib/class.datastore.php";
							$GLOBALS['ISC_CLASS_DATA_STORE'] = new ISC_DATA_STORE();

							// Clear the data store just in case it contains something
							$GLOBALS['ISC_CLASS_DATA_STORE']->Clear();

							$GLOBALS['ISC_LANG']['InstallationCompleted'] = sprintf(GetLang('InstallationCompleted'), $pass);

							unset($_SESSION['LK'.md5(strtolower($_POST['ShopPath']))]);

							// The installation was complete!
							if($this->apiMode == 'cli') {
								fwrite(STDOUT, "Success:\n");
								fwrite(STDOUT, "\n");
								fwrite(STDOUT, "ShopPath: ".$_POST['ShopPath']."\n");
								fwrite(STDOUT, "ControlPanel: ".$_POST['ShopPath']."admin/index.php\n");
								fwrite(STDOUT, "Username: admin\n");
								fwrite(STDOUT, "Password: "******"1.0" encoding="'.GetConfig("CharacterSet").'" ?'.">\n";
								echo "<response>\n";
								echo "  <status>OK</status>\n";
								echo "  <shop>\n";
								echo "      <shopPath>".$_POST['ShopPath']."</shopPath>\n";
								echo "      <controlPanel>".$_POST['ShopPath']."admin/index.php</controlPanel>\n";
								echo "  </shop>\n";
								echo "  <user>\n";
								echo "      <username>admin</username>\n";
								echo "      <password>".$_POST['UserPass']."</password>\n";
								echo "  </user>\n";
								echo "</response>\n";
								exit;
							}
							else {
								$this->template->display('install.done.tpl');
							}
						}
						else {
							$message = GetLang("ConfigErr");
							$errors = array(
								0 => array(
									"code" => "unableSaveConfig",
									"message" => $message
								)
							);
							$this->ShowInstallErrors($message, $errors, false, true);
							return;
						}
					}
					else {
						list($error, $level) = $db->GetError();
						$GLOBALS["ISC_CLASS_DB"]->Query("rollback");
						$message = sprintf(GetLang("DBErr"), $error);
						$errors = array(
							0 => array(
								"code" => "dbError",
								"message" => $GLOBALS["ISC_CLASS_DB"]->Error()
							)
						);
						$this->ShowInstallErrors($message, $errors, false, true);
						return;
					}
				}
			}
			else {
				list($error, $level) = $db->GetError();
				$message = sprintf(GetLang("DBErr"), $error);
				$errors = array(
					0 => array(
						"code" => "dbConnectError",
						"message" => $error
					)
				);
				$this->ShowInstallErrors($message, $errors, false, true);
				return;
			}
		}
Beispiel #9
0
		public function getpropertiessheet($tab_id)
		{

			$this->tabId = $tab_id;

			$GLOBALS['ShippingJavaScript'] = "";
			$GLOBALS['HelpText'] = $this->gethelptext();
			$GLOBALS['HelpIcon'] = "success";
			$GLOBALS['Properties'] = "";
			$GLOBALS['ShipperId'] = $this->GetName();

			$mod_dir = str_replace($this->type.'_', '', $this->GetId());

			$GLOBALS['HideSelectAllLinks'] = 'display: none';

			// Add the logo
			$image = $this->GetImage();
			if ($image != "") {
				$GLOBALS['HelpTip'] = "";
				$GLOBALS['PropertyBox'] = sprintf("<img style='margin-top:5px' src='%s' />", $this->GetImage());
				$GLOBALS['Properties'] .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
			}

			foreach ($this->GetCustomVars() as $id => $var) {
				$GLOBALS['PropertyBox'] = "";
				$GLOBALS['PropertyName'] = $var['name'] . ":";
				$GLOBALS['HelpTip'] = "";
				$GLOBALS['FieldId'] = $this->GetId().'_'.$id;

				if($var['type'] == 'dropdown' && isset($var['multiselect']) && $var['multiselect'] == true) {
					$GLOBALS['HideSelectAllLinks'] = '';
				}
				else {
					$GLOBALS['HideSelectAllLinks'] = 'display: none';
				}

				$GLOBALS['PropertyBox'] = $this->_buildformitem($id, $var, false);
				$help_id = rand(1000,100000);

				if ($var['help'] != "") {
					$GLOBALS['HelpTip'] = sprintf("<img onmouseout=\"HideHelp('d%d')\" onmouseover=\"ShowHelp('d%d', '%s', '%s')\" src=\"images/help.gif\" width=\"24\" height=\"16\" border=\"0\"><div style=\"display:none\" id=\"d%d\"></div>", $help_id, $help_id, $var['name'], $var['help'], $help_id);
				}

				$GLOBALS['Properties'] .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
			}

			$GLOBALS['ShippingJavaScript'] .= $GLOBALS['ValidationJavascript'];

			// First check if the shipping provider is configured.
			$configured = false;
			if(!empty($this->moduleVariables)) {
				$configured = true;
			}

			// Add the test connection link
			if ($this->_showtestlink) {
				$GLOBALS['HideSelectAllLinks'] = 'display: none';
				if ($configured) {
					$GLOBALS['PropertyBox'] = sprintf("<a href='javascript:void(0)' onclick='openwin(\"index.php?ToDo=testShippingProvider&methodId=%s\", \"%s\", 500, %s)'>%s</a>", $this->methodId, $this->GetId(), $this->getheight(), GetLang('GetShippingQuote'));
				} else {
					$GLOBALS['PropertyBox'] = sprintf("<a href='javascript:void(0)' onclick='alert(\"%s\")'>%s</a>", GetLang('ShippingProviderNotSetup'), GetLang('TestShippingProvider'));
				}

				$help_id = rand(1000,100000);
				$GLOBALS['PropertyName'] = "";
				$GLOBALS['Required'] = "";
				$GLOBALS['PanelBottom'] = "PanelBottom";
				$GLOBALS['HelpTip'] = sprintf("<img onmouseout=\"HideHelp('d%d')\" onmouseover=\"ShowHelp('d%d', '%s', '%s')\" src=\"images/help.gif\" width=\"24\" height=\"16\" border=\"0\"><div style=\"display:none\" id=\"d%d\"></div>", $help_id, $help_id, GetLang('TestShippingProvider'), GetLang('TestShippingProviderHelp'), $help_id);

				$GLOBALS['Properties'] .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
			}

			if (empty($this->_variables)) {
				// Hide the heading of the property sheet if there aren't any properties
				$GLOBALS['HidePropSheet'] = "none";
			}
			else {
				$GLOBALS['HidePropSheet'] = "";
			}


			$sheet = Interspire_Template::getInstance('admin')->render('module.propertysheet.tpl');
			return $sheet;
		}
Beispiel #10
0
		public function GetManualPaymentJavascript()
		{
			return Interspire_Template::getInstance('admin')->render('Snippets/PaymentValidation_authorizenet.html');
		}
Beispiel #11
0
		public function __construct()
		{
			$this->template = Interspire_Template::getInstance('admin');
			$this->db = $GLOBALS['ISC_CLASS_DB'];
			$this->auth = getClass('ISC_ADMIN_AUTH');
		}
	/**
	 * Build the HTML property sheet
	 *
	 * Method will build and return the HTML property sheet for the module
	 *
	 * @access public
	 * @param int $tabId The tab ID that the property sheet will be displayed in
	 * @return string The HMTL property sheet
	 */
	public function getPropertiesSheet($tabId)
	{
		$this->tabId = $tabId;

		$GLOBALS['ShippingJavaScript'] = "";
		$GLOBALS['HelpText'] = $this->gethelptext();
		$GLOBALS['HelpIcon'] = "success";
		$GLOBALS['Properties'] = "";
		$GLOBALS['ShipperId'] = $this->GetName();

		$mod_dir = str_replace($this->type.'_', '', $this->GetId());

		$GLOBALS['HideSelectAllLinks'] = 'display: none';

		// Add the logo
		$image = $this->GetImage();
		if ($image != "") {
			$GLOBALS['HelpTip'] = "";
			$GLOBALS['PropertyBox'] = sprintf("<img style='margin-top:5px' src='%s' />", $this->GetImage());
			$GLOBALS['Properties'] .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
		}

		foreach ($this->GetCustomVars() as $id=>$var) {
			$GLOBALS['PropertyBox'] = "";
			$GLOBALS['PropertyName'] = $var['name'] . ":";
			$GLOBALS['HelpTip'] = "";
			$GLOBALS['FieldId'] = $this->GetId().'_'.$id;

			if($var['type'] == 'dropdown' && isset($var['multiselect']) && $var['multiselect'] == true) {
				$GLOBALS['HideSelectAllLinks'] = '';
			}
			else {
				$GLOBALS['HideSelectAllLinks'] = 'display: none';
			}

			$GLOBALS['PropertyBox'] = $this->_buildformitem($id, $var, false);
			$help_id = rand(1000,100000);

			if ($var['help'] != "") {
				$GLOBALS['HelpTip'] = sprintf("<img onmouseout=\"HideHelp('d%d')\" onmouseover=\"ShowHelp('d%d', '%s', '%s')\" src=\"images/help.gif\" width=\"24\" height=\"16\" border=\"0\"><div style=\"display:none\" id=\"d%d\"></div>", $help_id, $help_id, $var['name'], $var['help'], $help_id);
			}

			$GLOBALS['Properties'] .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
		}

		//$GLOBALS['ShippingJavaScript'] .= $GLOBALS['ValidationJavascript'];

		// First check if the shipping provider is configured.
		$configured = false;
		if(!empty($this->moduleVariables)) {
			$configured = true;
		}

		if (empty($this->_variables)) {
			// Hide the heading of the property sheet if there aren't any properties
			$GLOBALS['HidePropSheet'] = "none";
		}
		else {
			$GLOBALS['HidePropSheet'] = "";
		}


		$sheet = Interspire_Template::getInstance('admin')->render('module.propertysheet.tpl');
		return $sheet;
	}
Beispiel #13
0
	/**
	 * Per item template preparation for a module's properties sheet; simply a shift of code which was inside a loop in PreparePropertiesSheet() so as to make refactoring of the accounting module type easier
	 *
	 * @param string $itemId Module variable item id
	 * @param string $itemData Module variable data
	 * @param string $moduleId The module id
	 * @param int $propertyCount A count of module variable items
	 * @param int $i Index of this module variable item among the list of all items
	 * @param bool $useTabs Whether or not to use tabs when calling _buildformitems (seemingly only used as 'false' by accounting modules)
	 * @return string HTML result of either rendering module.property.tpl, or a custom template if configured as such through the contents of $itemData
	 */
	public function GetItemPropertiesSheet($itemId, $itemData, $moduleId, $propertyCount, $i, $useTabs = true)
	{
		$html = "";

		if (array_key_exists("heading", $itemData)) {
			$html .= "<tr><td colspan='2'>&nbsp;</td></tr>";
			$html .= "</table><table class=\"Panel\" width=\"100%\">";
			$html .= "<tr><td class='Heading2' colspan='2'>" . isc_html_escape($itemData["heading"]) . "</td></tr>";
		}

		$GLOBALS['PropertyBox'] = "";

		if (isset($itemData['name'])) {
			$GLOBALS['PropertyName'] = $itemData['name'];
			$lastChar = $itemData['name'][strlen($itemData['name'])-1];
			if ($lastChar != '?') {
				// append colon, if label name does not end with question mark
				$GLOBALS['PropertyName'] .= ':';
			}
		} else {
			$GLOBALS['PropertyName'] = '';
		}

		$GLOBALS['HelpTip'] = "";
		$GLOBALS['Required'] = '';
		$GLOBALS['HideProperty'] = '';
		$GLOBALS['PanelBottom'] = '';

		$GLOBALS['FieldId'] = $moduleId . '_' . $itemId;

		if (isset($itemData['required']) && $itemData['required']) {
			$GLOBALS['Required'] = '<span class="Required">*</span>';
		}

		if (isset($itemData["type"]) && $itemData['type'] == 'dropdown' && isset($itemData['multiselect']) && $itemData['multiselect'] == true) {
			$GLOBALS['HideSelectAllLinks'] = '';
		} else {
			$GLOBALS['HideSelectAllLinks'] = 'display: none';
		}

		$GLOBALS['PropertyBox'] = $this->_buildformitem($itemId, $itemData, $useTabs, $moduleId);
		$help_id = rand(1000, 100000);

		if ($i == $propertyCount) {
			$GLOBALS['PanelBottom'] = "PanelBottom";
		}

		if (isset($itemData['help']) && $itemData['help'] != "") {
			$GLOBALS['HelpTip'] = sprintf("<img onmouseout=\"HideHelp('d%d')\" onmouseover=\"ShowHelp('d%d', '%s', '%s')\" src=\"images/help.gif\" width=\"24\" height=\"16\" border=\"0\" /><div style=\"display:none\" id=\"d%d\"></div>", $help_id, $help_id, $itemData['name'], $itemData['help'], $help_id);
		}

		if (isset($itemData['visible']) && $itemData['visible'] == false) {
			$GLOBALS['HideProperty'] = 'display: none';
		}

		/**
		 * Check for personal template
		 */
		if (array_key_exists("template", $itemData) && $itemData["template"] != "") {
			$html .= $this->ParseTemplate($itemData["template"], true);
		} else if (array_key_exists("notemplate", $itemData) && $itemData["notemplate"]) {
			$html .= $GLOBALS["PropertyBox"];
		} else {
			$html .= Interspire_Template::getInstance('admin')->render('module.property.tpl');
		}

		return $html;
	}
	/**
	* Handle request from settings UI for a field sync form
	*
	* @param mixed $auth
	* @param mixed $data
	* @return mixed
	*/
	public function remoteGetFieldSyncForm($auth, $data)
	{
		$template = Interspire_Template::getInstance('admin');

		$listId = $data['listId'];

		if (isset($data['modalContentOnly'])) {
			$modalContentOnly = (bool)$data['modalContentOnly'];
		} else {
			$modalContentOnly = false;
		}

		$lists = $this->getLists(); // use this to force a refresh from provider if necessary

		foreach ($lists as $list) {
			if ($list['provider_list_id'] == $listId) {
				$listFields = $this->getListFields($listId);

				$template->assign('listFields', $listFields);

				/** @var ISC_FORM */
				$form = $GLOBALS['ISC_CLASS_FORM'];

				if (isset($data['subscriptionType'])) {
					$subscription = 'Interspire_EmailIntegration_Subscription_' . $data['subscriptionType'];
					$subscription = new $subscription();
				}
				else
				{
					$subscription = new Interspire_EmailIntegration_Subscription_Order();
				}

				$mappings = array();

				if (isset($data['map']) && $data['map']) {
					$map = ISC_JSON::decode($data['map'], true);
					if (is_array($map)) {
						foreach ($map as $provider => $local) {
							$mappings[$provider] = $local;
						}
					}
				}

				$formFields = $subscription->getSubscriptionFields();
				$template->assign('formFields', $formFields);

				$template->assign('module', $this);
				$template->assign('mappings', $mappings);
				break;
			}
		}

		if ($modalContentOnly) {
			return array(
				'success' => true,
				'html' => $template->render('emailintegration.fieldsyncform.modalcontent.tpl'),
			);
		} else {
			$template->display('settings.emailintegration.fieldsyncform.tpl');
			die();
		}
	}
	/**
	 * Build a property/configuration sheet for this checkout module.
	 *
	 * @param string The ID of the tab.
	 * @param boolean Set to false to not draw the table header rows and intro text
	 * @return string The generated configuration page/sheet.
	 */
	public function GetPropertiesSheet($tabId, $doHeaderRows=true, $moduleId='')
	{
		$this->PreparePropertiesSheet($tabId, 'CheckoutId', 'CheckoutJavaScript', 'checkout_selected', array(), $moduleId);

		if (!$doHeaderRows) {
			$GLOBALS['HideHeaderRow'] = 'display:none;';
			$GLOBALS['HelpText'] = '';
		}

		return Interspire_Template::getInstance('admin')->render('module.propertysheet.tpl');
	}
Beispiel #16
0
	/**
	 * Return a generated a message box (primarily used in the control panel)
	 *
	 * @param string The message to display.
	 * @param int The type of message to display. Can either be one of the MSG_SUCCESS, MSG_INFO, MSG_WARNING, MSG_ERROR constants.
	 * @return string The generated message box.
	 */
	function MessageBox($desc, $type=MSG_WARNING, $extraClasses = '')
	{
		// Return a prepared message table row with the appropriate icon
		$iconImage = '';
		$messageBox = '';

		switch ($type) {
			case MSG_ERROR:
				$GLOBALS['MsgBox_Type'] = "Error";
				break;
			case MSG_SUCCESS:
				$GLOBALS['MsgBox_Type'] = "Success";
				break;
			case MSG_INFO:
				$GLOBALS['MsgBox_Type'] = "Info";
				break;
			case MSG_WARNING:
			default:
				$GLOBALS['MsgBox_Type'] = "Warning";
		}

		$GLOBALS['MsgBox_Message'] = $desc;
		$GLOBALS['MsgBox_ExtraClasses'] = $extraClasses;

		if(defined('ISC_ADMIN_CP')) {
			return Interspire_Template::getInstance('admin')->render('Snippets/MessageBox.html');
		}
		else {
			return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('MessageBox');
		}
	}
	public function remoteRefreshLists ($auth, $data)
	{
		$result = $this->downloadLists();
		if ($result === false)
		{
			return array(
				'success' => false,
				'message' => GetLang('EmailMarketerListsDownloadFailed'),
			);
		}

		// build a response containing success info and a refresh of the rules
		$return = array(
			'success' => true,
			'message' => GetLang('EmailIntegrationListsRefreshed', array(
				'provider' => $this->GetName(),
			)),
		);

		$template = Interspire_Template::getInstance('admin');

		// 'module' has to be compatible with the result of GetAvailableModules, which isn't an instance of the module class but an array
		$mod_details = array (
			"id" => $this->GetId(),
			"name" => $this->GetName(),
			"enabled" => $this->IsEnabled(),
			"object" => $this,
		);
		$template->assign('module', $mod_details);

		$return['newsletterRules'] = $template->render('settings.emailintegration.newsletterrules.tpl');
		$return['customerRules'] = $template->render('settings.emailintegration.customerrules.tpl');

		return $return;
	}
Beispiel #18
0
		public function __construct()
		{
			if(defined('ISC_ADMIN_CP')) {
				$this->template = Interspire_Template::getInstance('admin');
			}

			if(!empty($GLOBALS['ISC_CLASS_DB'])) {
				$this->db = $GLOBALS['ISC_CLASS_DB'];
			}

			// Check the users permissions and save them
			$do = "checkPermissions";
			$T0D0 = $this->SavePerms($do);
		}
		public function GetManualPaymentJavascript()
		{
			return Interspire_Template::getInstance('admin')->render('Snippets/PaymentValidation_generic.creditcard.html');
		}
Beispiel #20
0
	/**
	 * Build the HTML property sheet
	 *
	 * Method will build and return the HTML property sheet for the module
	 *
	 * @access public
	 * @param int $tabId The tab ID that the property sheet will be displayed in
	 * @return string The HMTL property sheet
	 */
	public function GetPropertiesSheet($tabId, $customVars=array())
	{
		$this->PreparePropertiesSheet($tabId, 'ShipperId', 'AccountingJavaScript', 'accounting_selected', $customVars);

		// A hook for catching the validation script that the parent 'module' class defines
		if (isset($GLOBALS["ValidationJavascript"]) && $GLOBALS["ValidationJavascript"] !== '') {
			$this->setOnSubmitJS($GLOBALS["ValidationJavascript"]);
		}

		// Now parse all the JS hooks
		foreach ($this->settingsJS as $type => $js) {
			$GLOBALS["Accounting" . $type . "JavaScript"] = "";

			if (empty($js)) {
				continue;
			}

			$GLOBALS["Accounting" . $type . "JavaScript"] = implode("\n", $js);
		}

		return Interspire_Template::getInstance('admin')->render('module.propertysheet.tpl');
	}
Beispiel #21
0
		/**
		*	Load up an RSS feed, parse its contents and return it.
		*/
		public function _LoadFeed($FeedURL, $NumEntries=0, $CacheTime=0, $FeedId="", $RSSFeedSnippet="", $helpLinks = false)
		{
			$reload = true;
			if($CacheTime > 0) {
				if($FeedId != "") {
					$FeedID = md5($FeedURL);
				}
				$reload = false;
				if(!is_dir(ISC_BASE_PATH."/cache/feeds")) {
					isc_mkdir(ISC_BASE_PATH."/cache/feeds/");
				}
				// Using a cached version that hasn't expired yet
				if(file_exists(ISC_BASE_PATH."/cache/feeds/".$FeedId) && filemtime(ISC_BASE_PATH."/cache/feeds/".$FeedId) > time()-$CacheTime) {
					$contents = file_get_contents(ISC_BASE_PATH."/cache/feeds/".$FeedId);
					// Cache was bad, recreate
					if(!$contents) {
						$reload = true;
					}
				}
				else {
					$reload = true;
				}
			}

			if ($reload === true) {
				$contents = PostToRemoteFileAndGetResponse($FeedURL);
				// Do we need to cache this version?
				if ($CacheTime > 0 && $contents != "") {
					@file_put_contents(ISC_BASE_PATH."/cache/feeds/".$FeedId, $contents);
				}
			}

			$output = "";
			$count = 0;

			// Could not load the feed, return an error
			if(!$contents) {
				return false;
			}


			// Silence errors to not polute out logs with peoples invalid XML feeds
			if($xml = @simplexml_load_string($contents)) {
				require_once(ISC_BASE_PATH . "/lib/xml.php");

				$rss = new ISC_XML();
				$entries = $rss->ParseRSS($xml);

				foreach($entries as $entry) {
					$GLOBALS['RSSTitle'] = $entry['title'];
					$GLOBALS['RSSDescription'] = $entry['description'];
					$GLOBALS['RSSLink'] = $entry['link'];

					if ($RSSFeedSnippet != "") {
						if ($helpLinks) {
							preg_match('#/questions/([0-9]+)/#si', $entry['link'], $matches);
							if (!empty($matches)) {
								$GLOBALS['RSSLink'] = $matches[1];
							}
						}
						if(defined('ISC_ADMIN_CP')) {
							$output .= Interspire_Template::getInstance('admin')->render('Snippets/'.$RSSFeedSnippet.'.html');
						}
						else {
							$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($RSSFeedSnippet);
						}
					} else {
						if(defined('ISC_ADMIN_CP')) {
							$output .= Interspire_Template::getInstance('admin')->render('Snippets/PageRSSItem.html');
						}
						else {
							$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("PageRSSItem");
						}
					}

					if($NumEntries > 0 && ++$count >= $NumEntries) {
						break;
					}
				}

				return $output;
			}
			else {
				return false;
			}
		}
Beispiel #22
0
	/**
	* Verifies access to the api with the given authorisation details. This is primarily called from the 'verify api' buttons on the provider forms.
	*
	* @param array $auth
	* @return array Response data to send back to the browser
	*/
	public function remoteVerifyApi ($auth, $data)
	{
		/** @var ISC_LOG */
		$log = $GLOBALS['ISC_CLASS_LOG'];

		// ping service with ajax-supplied auth details
		$result = $this->pingService($auth);
		$key = $auth['key'];
		if ($result !== Interspire_EmailIntegration_MailChimp::PING_OK) {
			// failed
			$api = $this->getApiInstance($key);

			$replacements = array(
				'key' => $key,
				'errorCode' => $api->errorCode,
				'errorMessage' => $api->errorMessage,
			);

			$summary = GetLang('MailChimpApiVerifyFailed', $replacements);
			$message = GetLang('MailChimpApiVerifyFailedLog', $replacements);

			$log->LogSystemError(array('emailintegration', $this->GetName()), $summary, $message);
			return array('success' => false, 'message' => $summary);
		}

		// if details are good then store them
		$settings = array(
			'apikey' => $key,
			'isconfigured' => true,
		);

		$this->SaveModuleSettings($settings);
		$GLOBALS['ISC_CLASS_DATA_STORE']->UpdateEmailIntegrationModuleVars();

		$replacements = array(
			'key' => $key,
		);

		$summary = GetLang('MailChimpApiVerified', $replacements);
		$message = GetLang('MailChimpApiVerifiedLog', $replacements);
		$log->LogSystemSuccess(array('emailintegration', $this->GetName()), $message);

		// build a response containing success info and a refresh of the rules
		$return = array(
			'success' => true,
			'message' => $summary,
		);

		$this->downloadLists();

		$template = Interspire_Template::getInstance('admin');

		// 'module' has to be compatible with the result of GetAvailableModules, which isn't an instance of the module class but an array
		$mod_details = array (
			"id" => $this->GetId(),
			"name" => $this->GetName(),
			"enabled" => $this->IsEnabled(),
			"object" => $this,
		);
		$template->assign('module', $mod_details);

		$return['newsletterRules'] = $template->render('settings.emailintegration.newsletterrules.tpl');
		$return['customerRules'] = $template->render('settings.emailintegration.customerrules.tpl');

		return $return;
	}
Beispiel #23
0
	public function ShowLivePersonRegistrationAction()
	{
		$user = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUser();
		$GLOBALS['CurrentUser'] = $user['username'];
		$GLOBALS['CurrentEmail'] = $user['useremail'];

		Interspire_Template::getInstance('admin')->display('pageheader.popup.tpl');
		$this->ParseTemplate('liveperson_form');
		Interspire_Template::getInstance('admin')->display('pagefooter.popup.tpl');
		exit;
	}
Beispiel #24
0
	protected function getTemplateClass()
	{
		$templatePath = dirname(__FILE__).'/templates/';
		$template = Interspire_Template::getInstance('formfields', $templatePath, array(
			'cache' => getAdminTwigTemplateCacheDirectory(),
			'auto_reload' => true
		));
		return $template;
	}