Пример #1
0
	/**
	* Update the eBay notification URL to hopefully fix pending item issue
	*
	*/
	public function updateEbayNotificationURL()
	{
		// is ebay enabled/configured?
		if (ISC_ADMIN_EBAY::checkEbayConfig()) {
			// lets ensure our notification URL is correct
			ISC_ADMIN_EBAY::resubscribeNotifications();
		}

		return true;
	}
Пример #2
0
		public function CommitSettings(&$messages=array())
		{
			// If the shop path has changed normalize it and set the app path too
			if (isset($GLOBALS['ISC_NEW_CFG']['ShopPath']) && $GLOBALS['ISC_NEW_CFG']['ShopPath'] != GetConfig('ShopPath')) {
				$parsedPath = ParseShopPath($GLOBALS['ISC_NEW_CFG']['ShopPath']);
				$GLOBALS['ISC_NEW_CFG']['ShopPath'] = $parsedPath['shopPath'];

				// add an event to resubscribe to ebay notifications since the notification url will now be different
				if (ISC_ADMIN_EBAY::checkEbayConfig()) {
					Interspire_Event::bind('settings_updated', array('ISC_ADMIN_EBAY', 'resubscribeNotifications'));
				}
			}

			// normalize our shared ssl path
			if (isset($GLOBALS['ISC_NEW_CFG']['SharedSSLPath']) && trim($GLOBALS['ISC_NEW_CFG']['SharedSSLPath'])) {
				$ssl_path_parts = parse_url($GLOBALS['ISC_NEW_CFG']['SharedSSLPath']);

				if (!isset($ssl_path_parts['path'])) {
					$ssl_path_parts['path'] = '';
				}
				$ssl_path_parts['path'] = rtrim($ssl_path_parts['path'], '/');

				// Workout the Shop Path
				$GLOBALS['ISC_NEW_CFG']['SharedSSLPath'] = 'https://' . $ssl_path_parts['host'];
				if (isset($ssl_path_parts['port']) && $ssl_path_parts['port'] != '443') {
					$GLOBALS['ISC_NEW_CFG']['SharedSSLPath'] .= ':'.$ssl_path_parts['port'];
				}
				$GLOBALS['ISC_NEW_CFG']['SharedSSLPath'] .= $ssl_path_parts['path'];
			}

			// normalize our subdomain ssl path
			if (isset($GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath']) && trim($GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'])) {
				$ssl_path_parts = parse_url($GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath']);

				if (!isset($ssl_path_parts['path'])) {
					$ssl_path_parts['path'] = '';
				}
				$ssl_path_parts['path'] = rtrim($ssl_path_parts['path'], '/');

				// Workout the Shop Path
				$GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'] = 'https://' . $ssl_path_parts['host'];
				if (isset($ssl_path_parts['port']) && $ssl_path_parts['port'] != '443') {
					$GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'] .= ':'.$ssl_path_parts['port'];
				}
				$GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'] .= $ssl_path_parts['path'];
			}

			if (!isset($GLOBALS['ISC_NEW_CFG'])) {
				$GLOBALS['ISC_NEW_CFG'] = array();
			}

			$directories = array(
				'ImageDirectory' => 'product_images',
				'DownloadDirectory' => 'product_downloads'
			);
			foreach($directories as $directory => $default) {
				if(isset($GLOBALS['ISC_NEW_CFG'][$directory])) {
					$newDirectory = ISC_BASE_PATH.'/'.$GLOBALS['ISC_NEW_CFG'][$directory];
					if(!$GLOBALS['ISC_NEW_CFG'][$directory] || !is_dir($newDirectory)) {
						$GLOBALS['ISC_NEW_CFG'][$directory] = $default;
					}
				}
			}

			// Wht we're doing here is we copy the current configuration in to another variable and
			// then load the store configuration file again. We do this to prevent any settings
			// that may have temporarily been modified in memory from propagating to the configuration
			// file. We then revert back to the in memory settings
			$memoryConfig = $GLOBALS['ISC_CFG'];
			unset($GLOBALS['ISC_CFG']);
			require ISC_CONFIG_FILE;
			$originalConfig = $GLOBALS['ISC_CFG'];
			$GLOBALS['ISC_CFG'] = $memoryConfig;
			$GLOBALS['ISC_SAVE_CFG'] = array_merge($originalConfig, $GLOBALS['ISC_NEW_CFG']);
			// Save the var_exported vars in the globals array temporarily for saving
			foreach ($this->all_vars as $var) {
				if (!array_key_exists($var, $GLOBALS['ISC_SAVE_CFG'])) {
					if(array_key_exists($var, $memoryConfig)) {
						$GLOBALS[$var] = var_export($memoryConfig[$var], true);
					} else {
						$GLOBALS[$var] = "null";
					}
				} else {
					$GLOBALS[$var] = var_export($GLOBALS['ISC_SAVE_CFG'][$var], true);
				}
			}

			$config_data = $this->template->render('config.file.tpl');

			$setting_string = "<" . "?php\n\n";
			$setting_string .= "\t// Last Updated: ".isc_date("jS M Y @ g:i A") . "\n";
			$setting_string .= $config_data;

			if (!defined("ISC_CONFIG_FILE") || !defined("ISC_CONFIG_BACKUP_FILE")) {
				die("Config sanity check failed");
			}

			// Try to copy the current config file to a backup file
			if (!@copy(ISC_CONFIG_FILE, ISC_CONFIG_BACKUP_FILE)) {
				isc_chmod(ISC_CONFIG_BACKUP_FILE, ISC_WRITEABLE_FILE_PERM);
				$messages = array(GetLang('CouldntBackupConfig') => MSG_INFO);
			}

			// Try to write to the config file
			if (!is_writable(ISC_CONFIG_FILE)) {
				$this->error = GetLang('CouldntSaveConfig');
				return false;
			}

			if (!($fp = @fopen(ISC_CONFIG_FILE, "wb+"))) {
				$this->error = GetLang('CouldntSaveConfig');
				return false;
			}

			if (@fwrite($fp, $setting_string)) {
				fclose($fp);
				$prevCatListDepth = GetConfig('CategoryListDepth');
				// Include the config file again to initialize the new values
				include(ISC_CONFIG_FILE);

				if (isset($GLOBALS['ISC_NEW_CFG']['CategoryListDepth']) && $GLOBALS['ISC_NEW_CFG']['CategoryListDepth'] != $prevCatListDepth) {
					$GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories();
				}

				// trigger any events that should run after the settings have been saved
				Interspire_Event::trigger('settings_updated');

				return true;
			}

			fclose($fp);
			$this->error = GetLang('CouldntSaveConfig');
			return false;
		}
Пример #3
0
	/**
	 * This function will send the command to eBay to end the listing
	 */
	private function endListingAction()
	{
		$output['Success'] = false;
		$output['PartiallySuccess'] = false;
		$output['Failure'] = false;
		$output['UpdatedListingRows'] = false;
		$selectedItems = $_REQUEST['selectedItems'];
		$selectedReason = $_REQUEST['selectedReason'];
		$itemData = array();
		$deleteItemIds = array();
		$responseHtml = '';
		$endItemResults = array();
		foreach ($selectedItems as $selectedItem) {
			$itemData[] = array(
				'Id' => $selectedItem,
				'EndingReason' => $selectedReason
			);
		}
		while (!empty ($itemData)) {
			$doItem = array_splice($itemData, 0, 10);
			$tempEndItemResults = ISC_ADMIN_EBAY::endEbayListing($doItem);
			if (is_array($tempEndItemResults)) {
				$endItemResults = array_merge($endItemResults, $tempEndItemResults);
			}
		}

		if (!empty ($endItemResults)) {
			foreach ($endItemResults as $endItemResult) {
				$item = ISC_ADMIN_EBAY::getEbayListingRefByItemId($endItemResult->getItemId());
				if( !empty ($item)) {
					$item = array_shift($item);
					if ($endItemResult->hasErrors()) {
						$GLOBALS['ItemRowText'] = sprintf(GetLang('ItemEndedFailure'), $item['title'], $item['ebay_item_id']);
						$output['PartiallySuccess'] = true;
					} else {
						$GLOBALS['ItemRowText'] = sprintf(GetLang('ItemEndedSuccess'), $item['title'], $item['ebay_item_id']);
						$deleteItemIds[] = $item['ebay_item_id'];
					}
					$responseHtml .= $this->template->render('ebay.endinglistingresult.row.tpl');
				}
			}
			if (!$output['PartiallySuccess']) {
				$output['AllSuccess'] = true;
				$responseHtml = '';
			}
		} else {
			$output['Failure'] = true;
		}

		if (!empty ($deleteItemIds)) {
			ISC_ADMIN_EBAY::deleteEbayListingRefByItemId($deleteItemIds);
			$output['UpdatedListingRows'] = GetClass('ISC_ADMIN_EBAY')->ManageEbayLiveListingGrid();
		}
		$output['UpdatedListingRows'] = GetClass('ISC_ADMIN_EBAY')->ManageEbayLiveListingGrid();
		$output['endinglistingresultHTML'] = $responseHtml;
		ISC_JSON::output('', true, $output);

	}
	/**
	* Ebay: Sent to a subscribing third party for the seller when an item was not sold.
	*
	* My notes: I've seen this notification when items are cancelled, but I assume it also happens when the auction timer ends with no bids.
	*
	* @param array $body
	* @return boolean Return true if database updated correct. Otherwise, return false
	*/
	protected function _handleItemUnsold($body)
	{
		// The data fields the ItemUnsold notification returns are the same as those returned by GetItemResponse with the default detail level.
		if (!empty ($body['Item']['ItemID']) && ISC_ADMIN_EBAY::validEbayItemId($body['Item']['ItemID'])) {
			$updatedData = array('listing_status' => 'unsold');
			$this->log->LogSystemDebug('ebay', 'An Item ('. $body['Item']['ItemID'] .') on eBay has been unsold.');
			return $GLOBALS['ISC_CLASS_DB']->UpdateQuery('ebay_items', $updatedData, "ebay_item_id='".$body['Item']['ItemID']."'");
		}
		return false;
	}