Пример #1
0
	public function SetCustomVars ()
	{
		parent::SetCustomVars();

		// for saving purposes only; the html form is a manual template
		$this->_variables['apikey'] = array(
			"name" => GetLang("MailChimpApiKey"),
			"type" => "textbox",
			"help" => GetLang('MailChimpApiKeyHelp'),
			"default" => "",
			"required" => true,
		);
	}
	/**
	* Initialise step of an order module export -- outputs the dialog html for use by the client-side FSM
	*
	* @param array $data
	*/
	protected function _moduleExportOrderInit($data)
	{
		if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Export_Orders)) {
			return;
		}

		$this->template->assign('modalTitle', 'Export Orders to ' . $this->_module->GetName());
		$this->template->assign('module', $this->_module);
		$this->template->assign('lists', $this->_module->getLists());
		$this->template->assign('typePlural', 'Orders');
		$this->template->assign('typeSingular', 'Order');

		$user = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUser();
		$this->template->assign('useremail', $user['useremail']);

		$this->template->display('emailintegration.moduleexport.tpl');
	}
Пример #3
0
		private function ManageCustomers($MsgDesc = "", $MsgStatus = "")
		{
			$GLOBALS['HideClearResults'] = "none";

			$numCustomers = 0;

			// Fetch any results, place them in the data grid
			$GLOBALS['CustomerDataGrid'] = $this->ManageCustomersGrid($numCustomers);

			// Was this an ajax based sort? Return the table now
			if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1) {
				echo $GLOBALS['CustomerDataGrid'];
				return;
			}

			if (isset($this->_customSearch['searchname'])) {
				$GLOBALS['ViewName'] = isc_html_escape($this->_customSearch['searchname']);
			}
			else {
				$GLOBALS['ViewName'] = GetLang('AllCustomers');
				$GLOBALS['HideDeleteViewLink'] = "none";
			}

			if (isset($this->_customSearch['searchname'])) {
				$GLOBALS['CustomSearchName'] = ": ".isc_html_escape($this->_customSearch['searchname']);
			}

			// Get the custom search as option fields
			$num_custom_searches = 0;
			$GLOBALS['CustomSearchOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->GetSearchesAsOptions(@$_GET['searchId'], $num_custom_searches, "AllCustomers", "viewCustomers", "customCustomerSearch");

			if (!isset($_REQUEST['searchId'])) {
				$GLOBALS['HideDeleteCustomSearch'] = "none";
			}
			else {
				$GLOBALS['CustomSearchId'] = (int)$_REQUEST['searchId'];
			}

			// Do we need to disable the add button?
			if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Customer)) {
				$GLOBALS['DisableAdd'] = "DISABLED";
			}

			// Do we need to disable the delete button?
			if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Delete_Customers) || $numCustomers == 0) {
				$GLOBALS['DisableDelete'] = "DISABLED";
			}

			// Do we need to disable the expory button?
			if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Export_Customers) || $numCustomers == 0) {
				$GLOBALS['DisableExport'] = "DISABLED";
			}

			if (isset($_REQUEST['searchQuery']) || isset($_GET['searchId'])) {
				$GLOBALS['HideClearResults'] = "";
			}

			$GLOBALS['CustomerIntro'] = GetLang('ManageCustomersIntro');

			if ($numCustomers > 0) {
				if ($MsgDesc == "" && (isset($_REQUEST['searchQuery']) || isset($_GET['searchId']))) {
					if ($numCustomers == 1) {
						$MsgDesc = GetLang('CustomerSearchResultsBelow1');
					}
					else {
						$MsgDesc = sprintf(GetLang('CustomerSearchResultsBelowX'), $numCustomers);
					}

					$MsgStatus = MSG_SUCCESS;
				}
			}
			else {
				$GLOBALS['DisplayGrid'] = "none";
				if (count($_GET) > 1) {
					if ($MsgDesc == "") {
						$GLOBALS['Message'] = MessageBox(GetLang('NoCustomerResults'), MSG_ERROR);
					}
				}
				else {
					// No actual custoemrs
					$GLOBALS['DisplaySearch'] = "none";
					$GLOBALS['Message'] = MessageBox(GetLang('NoCustomers'), MSG_SUCCESS);
				}
			}

			if (!gzte11(ISC_MEDIUMPRINT)) {
				$GLOBALS[base64_decode('SGlkZUV4cG9ydA==')] = "none";
			}

			if ($MsgDesc != "") {
				$GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus);
			}

			$flashMessages = GetFlashMessages();
			if(is_array($flashMessages) && !empty($flashMessages)) {
				$GLOBALS['Message'] = '';
				foreach($flashMessages as $flashMessage) {
					$GLOBALS['Message'] .= MessageBox($flashMessage['message'], $flashMessage['type']);
				}
			}

			if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Export_Customers)) {
				$exportAction = "index.php?ToDo=startExport&t=customers";
				if (isset($GLOBALS['CustomSearchId']) && $GLOBALS['CustomSearchId'] != '0') {
					$exportAction .= "&searchId=" . $GLOBALS['CustomSearchId'];
				}
				else {
					$params = $_GET;
					unset($params['ToDo']);

					if (!empty($params)) {
						$exportAction .= "&" . http_build_query($params);
					}
				}

				$searchQueryForExport = $_POST + $_GET;
				foreach ($searchQueryForExport as $index => $value) {
					if ($value === '') {
						unset($searchQueryForExport[$index]);
					}
				}
				unset($searchQueryForExport['ToDo'], $searchQueryForExport['SubmitButton1'], $searchQueryForExport['sortField'], $searchQueryForExport['sortOrder'], $searchQueryForExport['SearchButton_x'], $searchQueryForExport['SearchButton_y']);
				$searchQueryForExport = isc_json_encode($searchQueryForExport);

				$customerExportMenu = array();

				$customerExportMenu[] = array(
					array(
						'backgroundImage' => 'images/export.gif',
						'label' => GetLang('EmailIntegrationExportToFile'),
						'class' => 'exportMenuLink',
						'href' => $exportAction,
					),
				);

				$customerExportMenuModules = array();

				$emailModules = ISC_EMAILINTEGRATION::getConfiguredModules();
				foreach ($emailModules as /** @var ISC_EMAILINTEGRATION */$emailModule) {
					if (!$emailModule->supportsBulkExport()) {
						// not all modules have to support bulk exports
						continue;
					}

					$customerExportMenuModules[] = array(
						'backgroundImage' => '../modules/' . str_replace('_', '/', $emailModule->GetId()) . '/images/16x16.png',
						'label' => GetLang('EmailIntegrationExportToModule', array('module' => $emailModule->GetName())),
						'href' => 'javascript:Interspire_EmailIntegration_ModuleExportMachine.start({ exportType: "Customer", exportModule: "' . $emailModule->GetId() . '", exportSearch: ' . $searchQueryForExport . ' });',
					);
				}

				if (!empty($customerExportMenuModules)) {
					$customerExportMenu[] = $customerExportMenuModules;

					$this->engine->bodyScripts[] = '../javascript/fsm.js';
					$this->engine->bodyScripts[] = '../javascript/jquery/plugins/disabled/jquery.disabled.js';
					$this->engine->bodyScripts[] = '../javascript/ajaxDataProvider.js';
					$this->engine->bodyScripts[] = 'script/emailintegration.js';
					$this->engine->bodyScripts[] = 'script/emailintegration.export.js';

					// disabled for now until batch rule processing is implemented, as the existing, single-subscription rule processing is too slow for bulk export

	//				$customerExportMenu[] = array(
	//					array(
	//						'backgroundImage' => 'images/export_to_rules.gif',
	//						'label' => GetLang('EmailIntegrationExportToNewsletterRules'),
	//						'href' => 'javascript:Interspire_EmailIntegration_RuleExportMachine.start({ exportType: "Customer", exportRule: "NewsletterSubscribed", exportSearch: ' . $searchQueryForExport . ' });',
	//					),
	//				);
				}

				$this->template->assign('customerExportMenu', $customerExportMenu);
			}

			$this->template->display('customers.manage.tpl');
		}
Пример #4
0
		protected function ManageOrders($MsgDesc = "", $MsgStatus = "")
		{
			$GLOBALS['HideClearResults'] = "none";
			$status = array();
			$num_custom_searches = 0;
			$numOrders = 0;

			// Fetch any results, place them in the data grid
			$GLOBALS['OrderDataGrid'] = $this->ManageOrdersGrid($numOrders, $numDeletedOrders);

			// Was this an ajax based sort? Return the table now
			if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1) {
				echo $GLOBALS['OrderDataGrid'];
				return;
			}

			if(isset($_REQUEST['searchQuery']) || isset($_GET['searchId'])) {
				$GLOBALS['HideClearResults'] = "";
			}

			if(isset($this->_customSearch['searchname'])) {
				$GLOBALS['ViewName'] = $this->_customSearch['searchname'];

				if(!empty($this->_customSearch['searchlabel'])) {
					$GLOBALS['HideDeleteViewLink'] = "none";
				}
			}
			else {
				$GLOBALS['ViewName'] = GetLang('AllOrders');
				$GLOBALS['HideDeleteViewLink'] = "none";
			}

			// Do we display the add order buton?
			if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Add_Orders)) {
				$GLOBALS['AddOrderButton'] = '<input type="button" value="' . GetLang('AddAnOrder') . '..." class="FormButton" style="width:100px" onclick="document.location.href=\'index.php?ToDo=addOrder\'" />';
			} else {
				$GLOBALS['AddOrderButton'] = '';
			}

			$GLOBALS['OrderActionOptions'] = '<option selected="1">' . GetLang('ChooseAction') . '</option>';

			$searchDeletedOrders = 'no';
			if (isset($_REQUEST['searchDeletedOrders'])) {
				$searchDeletedOrders = $_REQUEST['searchDeletedOrders'];
			}

			if ($searchDeletedOrders != 'only') {
				// Do we need to disable the delete button?
				if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Delete_Orders) || $numOrders == 0) {
					$args = 'disabled="disabled"';
				} else {
					$args = 'value="delete"';
				}

				$GLOBALS['OrderActionOptions'] .= '<option ' . $args . '>' . GetLang('DeleteSelected') . '</option>';
			}

			$searchGet = $_GET;
			if (isset($searchGet['searchId']) && $searchGet['searchId'] == 0) {
				// this is a nasty hack but I can't right now figure out a better way of making count($_GET) work as
				// expected when the clicking 'view: all orders' which is '&ToDo=viewOrders&searchId=0'
				unset($searchGet['searchId']);
			}

			if ($searchDeletedOrders != 'no') {
				if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Undelete_Orders) || $numOrders == 0) {
					$GLOBALS['OrderActionOptions'] .= '<option disabled="disabled">' . isc_html_escape(GetLang('UndeleteSelected')) . '</option>';
				} else {
					$GLOBALS['OrderActionOptions'] .= '<option value="undelete">' . isc_html_escape(GetLang('UndeleteSelected')) . '</option>';
				}

				if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Purge_Orders) || $numOrders == 0) {
					$GLOBALS['OrderActionOptions'] .= '<option disabled="disabled">' . isc_html_escape(GetLang('PurgeSelected')) . '</option>';
				} else {
					$GLOBALS['OrderActionOptions'] .= '<option value="purge">' . isc_html_escape(GetLang('PurgeSelected')) . '</option>';
				}
			}

			if ($searchDeletedOrders == 'only' && GetConfig('DeletedOrdersAction') == 'purge') {
				// show a notice about searching for deleted orders when the feature is turned off
				FlashMessage(GetLang('OrderArchivingIsTurnedOff'), MSG_INFO);
			}

			if($numOrders > 0) {
				if($MsgDesc == "" && (isset($_REQUEST['searchQuery']) || count($searchGet) > 1) && !isset($_GET['selectOrder'])) {
					if($numOrders == 1) {
						$MsgDesc = GetLang('OrderSearchResultsBelow1');
					}
					else {
						$MsgDesc = sprintf(GetLang('OrderSearchResultsBelowX'), $numOrders);
					}

					$MsgStatus = MSG_SUCCESS;
				}
				$args1 = 'value="printInvoice"';
				$args2 = 'value="printSlip"';
			}
			else {
				$args1 = 'disabled="disabled"';
				$args2 = 'disabled="disabled"';
			}

			$GLOBALS['OrderActionOptions'] .= '<option ' . $args1 . '>' . GetLang('PrintInvoicesSelected') . '</option>';
			$GLOBALS['OrderActionOptions'] .= '<option ' . $args2 . '>' . GetLang('PrintPackingSlipsSelected') . '</option>';

			if(!gzte11(ISC_MEDIUMPRINT)) {
				$GLOBALS[base64_decode('SGlkZUV4cG9ydA==')] = "none";
				$GLOBALS[B('ZGlzYWJsZU9yZGVyRXhwb3J0cw==')] = true;
			}

			$GLOBALS['OrderActionOptions'] .= '<option disabled="disabled"></option><optgroup label="' . GetLang('BulkOrderStatus') . '">';

			$result = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]order_status ORDER BY statusorder ASC");
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$GLOBALS['OrderActionOptions'] .= '<option value="updateStatus' . $row['statusid'] . '">' . $row['statusdesc'] . '</option>';
			}
			$GLOBALS['OrderActionOptions'] .= '</optgroup>';

			if (!isset($_REQUEST['searchId'])) {
				$_REQUEST['searchId'] = 0;
			}

			// Get the custom search as option fields
			$GLOBALS['CustomSearchOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->GetSearchesAsOptions($_REQUEST['searchId'], $num_custom_searches, "AllOrders", "viewOrders", "customOrderSearch");

			// the above is pre-formatted, need it as raw data for the iphone
			$GLOBALS['customSearchList'] = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->GetSearches();

			if(!isset($_REQUEST['searchId'])) {
				$GLOBALS['HideDeleteCustomSearch'] = "none";
			} else {
				$GLOBALS['CustomSearchId'] = (int)$_REQUEST['searchId'];
			}

			$GLOBALS['OrderIntro'] = GetLang('ManageOrdersIntro');
			$GLOBALS['Message'] = '';

			// No orders
			if($numOrders == 0) {
				$GLOBALS['DisplayGrid'] = "none";

				if(count($searchGet) > 1) {
					// Performing a search of some kind
					if ($MsgDesc == "") {
						$GLOBALS['Message'] = MessageBox(GetLang('NoOrderResults'), MSG_ERROR);
						if ($numDeletedOrders) {
							$deletedUrl = $searchGet;
							$deletedUrl['searchDeletedOrders'] = 'only';
							$deletedUrl = 'index.php?' . http_build_query($deletedUrl);

							$GLOBALS['Message'] .= MessageBox(GetLang('DeletedOrdersMatchedYourSearch', array(
								'viewDeletedOrdersUrl' => $deletedUrl,
							)), MSG_INFO, 'MessageBoxTrash');
							unset($deletedUrl);
						}
					}
				} else {
					$GLOBALS['Message'] = MessageBox(GetLang('NoOrders'), MSG_SUCCESS);
					$GLOBALS['DisplaySearch'] = "none";
				}

				unset($searchGet);
			}

			if($MsgDesc != "") {
				$GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus);
			}

			$flashMessages = GetFlashMessages();
			if(is_array($flashMessages)) {
				foreach($flashMessages as $flashMessage) {
					$GLOBALS['Message'] .= MessageBox($flashMessage['message'], $flashMessage['type']);
				}
			}

			if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Export_Orders)) {
				$GLOBALS['ExportAction'] = "index.php?ToDo=startExport&t=orders";
				if (isset($GLOBALS['CustomSearchId']) && $GLOBALS['CustomSearchId'] != '0') {
					$GLOBALS['ExportAction'] .= "&searchId=" . $GLOBALS['CustomSearchId'];
				}
				else {
					$params = $_GET;
					unset($params['ToDo']);

					if (!empty($params)) {
						$GLOBALS['ExportAction'] .= "&" . http_build_query($params);
					}
				}
			}

			$selectOrder = '';
			if (!empty($_GET['selectOrder']) && isId($_GET['selectOrder'])) {
				$selectOrder = 'QuickView(' . $_GET['selectOrder'] . ');';
			}
			$GLOBALS['SelectOrder'] = $selectOrder;

			// Used for iPhone interface
			$GLOBALS['OrderStatusOptions'] = $this->GetOrderStatusOptions();

			if ($numOrders && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Export_Orders)) {
				$exportAction = "index.php?ToDo=startExport&t=orders";
				if (isset($GLOBALS['CustomSearchId']) && $GLOBALS['CustomSearchId'] != '0') {
					$exportAction .= "&searchId=" . $GLOBALS['CustomSearchId'];
				}
				else {
					$params = $_GET;
					unset($params['ToDo']);

					if (!empty($params)) {
						$exportAction .= "&" . http_build_query($params);
					}
				}

				$searchQueryForExport = $_POST + $_GET;
				foreach ($searchQueryForExport as $index => $value) {
					if ($value === '') {
						unset($searchQueryForExport[$index]);
					}
				}
				unset($searchQueryForExport['ToDo'], $searchQueryForExport['SubmitButton1'], $searchQueryForExport['sortField'], $searchQueryForExport['sortOrder'], $searchQueryForExport['SearchButton_x'], $searchQueryForExport['SearchButton_y']);
				$searchQueryForExport = isc_json_encode($searchQueryForExport);

				$orderExportMenu = array();

				$orderExportMenu[] = array(
					array(
						'backgroundImage' => 'images/export.gif',
						'label' => GetLang('EmailIntegrationExportToFile'),
						'class' => 'exportMenuLink',
						'href' => $exportAction,
					),
				);

				$emailModules = ISC_EMAILINTEGRATION::getConfiguredModules();
				foreach ($emailModules as /** @var ISC_EMAILINTEGRATION */$emailModule) {
					if (!$emailModule->supportsBulkExport()) {
						// not all modules have to support bulk exports
						continue;
					}

					$orderExportMenuModules[] = array(
						'backgroundImage' => '../modules/' . str_replace('_', '/', $emailModule->GetId()) . '/images/16x16.png',
						'label' => GetLang('EmailIntegrationExportToModule', array('module' => $emailModule->GetName())),
						'href' => 'javascript:Interspire_EmailIntegration_ModuleExportMachine.start({ exportType: "Order", exportModule: "' . $emailModule->GetId() . '", exportSearch: ' . $searchQueryForExport . ' });',
					);
				}

				if (!empty($orderExportMenuModules)) {
					$orderExportMenu[] = $orderExportMenuModules;

					$this->engine->bodyScripts[] = '../javascript/fsm.js';
					$this->engine->bodyScripts[] = '../javascript/jquery/plugins/disabled/jquery.disabled.js';
					$this->engine->bodyScripts[] = '../javascript/ajaxDataProvider.js';
					$this->engine->bodyScripts[] = 'script/emailintegration.js';
					$this->engine->bodyScripts[] = 'script/emailintegration.export.js';
				}

				$this->template->assign('orderExportMenu', $orderExportMenu);
			} else {
				$this->template->assign('disableOrderExports', true);
			}

			$this->template->display('orders.manage.tpl');
		}
Пример #5
0
/**
 * Update the ip address of an order. This is useful for checkout providers like google checkout who provide
 * the customers ip address after the initial notification of a new order
 *
 * @return boolean
 **/
function UpdateOrderIpAddress($orderid, $ipaddress, $dogeoip=true)
{
	$value = trim($ipaddress);
	if (empty($ipaddress)) {
		return false;
	}

	if (!preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $ipaddress)) {
		return false;
	}

	$data = array (
		'ordipaddress' => $ipaddress
	);

	if ($dogeoip) {
		// Attempt to determine the GeoIP location based on their IP address
		require_once ISC_BASE_PATH."/lib/geoip/geoip.php";
		$gi = geoip_open(ISC_BASE_PATH."/lib/geoip/GeoIP.dat", GEOIP_STANDARD);


		$data['ordgeoipcountrycode'] = geoip_country_code_by_addr($gi, $ipaddress);

		// If we get the country, look up the country name as well
		if($data['ordgeoipcountrycode']) {
			$data['ordgeoipcountry'] = geoip_country_name_by_addr($gi, $ipaddress);
		}
	}

	$result = $GLOBALS['ISC_CLASS_DB']->UpdateQuery('orders', $data, "orderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderid)."'");
	if (!$result) {
		return $result;
	}

	// send update to email provider/s that support an IP field
	$query = "
		SELECT ordbillemail
		FROM `[|PREFIX|]orders`
		WHERE orderid = '".$GLOBALS['ISC_CLASS_DB']->Quote($orderid)."'";

	$email = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);

	if (!$email) {
		return false;
	}

	ISC_EMAILINTEGRATION::routeSubscriptionIpUpdate($email, $ipaddress);

	return true;
}
Пример #6
0
	/**
	* Route this subscription to email providers based on rules configured for the store
	*
	* @param bool $asynchronous
	* @return mixed An array of Interspire_EmailIntegration_AddSubscriberResult objects for synchronous calls, otherwise null
	*/
	public function routeSubscription($asynchronous = true)
	{
		$event = $this->getSubscriptionEventId();
		if (!$event) {
			// this subscription type does not support routing via subscription rules
			return;
		}

		return ISC_EMAILINTEGRATION::routeSubscription($event, $this, $asynchronous);
	}
Пример #7
0
	protected function _performCustomerExport()
	{
		if (!empty($this->_search)) {
			// there are search parameters, use them to filter customer data before exporting
			/** @var ISC_ADMIN_CUSTOMERS */
			$customerClass = GetClass('ISC_ADMIN_CUSTOMERS');
			$search = $customerClass->BuildWhereFromVars($this->_search);

			$where = ' WHERE 1=1 ' . $search['query'] . ' ';
			$join = $search['join'];

			unset($search);
		}
		else
		{
			$where = '';
			$join = '';
		}

		$query = 'SELECT /*:columns*/ FROM `[|PREFIX|]customers` ' . $join . ' ' . $where;

		if (!$this->_skip) {
			$count = $this->_db->FetchOne(str_replace('/*:columns*/', 'COUNT(*)', $query));
			$this->_log->LogSystemNotice('emailintegration', GetLang('EmailIntegration_Log_JobCommencingCustomerExport', array(
				'count' => $count,
			)));
			$this->_keystore->set($this->_prefix . 'estimate', $count);
		}

		// no matter what the search specified, always order by id so new customers do not mess up the batch logic
		$query .= ' ORDER BY customerid LIMIT ';

		if ($this->_skip) {
			$query .= $this->_skip . ',';
		}

		$query .= self::BATCH_SIZE;

		$query = $this->_db->Query(str_replace('/*:columns*/', '`customerid`,`custconemail`,`custconfirstname`', $query));
		if (!$query) {
			$error = GetLang('EmailIntegration_Log_JobCustomerDatabaseError');
			$this->_logError($error);
			$this->_errorExport($error);
			return false;
		}

		// currently the only possible routing for existing customers is via newsletter subscription rules so we don't need to check $this->_rule here and we don't need to perform field mapping because it's always based on email and first-name

		$subscriptions = array();
		while ($row = $this->_db->Fetch($query))
		{
			$subscriptions[] = new Interspire_EmailIntegration_Subscription_Newsletter($row['custconemail'], $row['custconfirstname']);
		}

		ISC_EMAILINTEGRATION::routeSubscriptions('onNewsletterSubscribed', $subscriptions, false);

		return count($subscriptions);
	}
Пример #8
0
	/**
	 * Polls each configured email provider module to determine which format preferences are available
	 *
	 * @return array An array of preference id => description values
	 */
	public function GenerateMailFormatPreferences()
	{
		$modules = ISC_EMAILINTEGRATION::getConfiguredModules();
		$preferences = array();
		foreach ($modules as /** @var ISC_EMAILINTEGRATION */$module) {
			$modulePreferences = $module->getAvailableMailFormatPreferences();
			foreach ($modulePreferences as $preference) {
				if (isset($preferences[$preference])) {
					continue;
				}
				$preferences[$preference] = GetLang('EmailFormatDescription_' . $preference);
			}
		}
		ksort($preferences);
		return $preferences;
	}
Пример #9
0
	/**
	* Delete all configured email integration rules (except built-in rules)
	*
	* @return bool
	*/
	public static function deleteAllRules()
	{
		ISC_EMAILINTEGRATION::flushRules();
		return $GLOBALS['ISC_CLASS_DB']->Query('TRUNCATE TABLE `[|PREFIX|]email_rules`');
	}
Пример #10
0
	public function __construct ()
	{
		parent::__construct();

		$this->name = GetLang('ExportOnlyModuleName');
	}
Пример #11
0
	/**
	 * Update the email integration module variables in the data store.
	 *
	 * @return mixed The data that was saved if successful, false if there was a problem saving the data.
	 */
	public function UpdateEmailIntegrationModuleVars()
	{
		ISC_EMAILINTEGRATION::flushEnabledModuleCache();
		return $this->UpdateModuleVars('EmailIntegration');
	}
Пример #12
0
	public function SetCustomVars ()
	{
		parent::SetCustomVars();

		// for saving purposes only; the html form is a manual template
		$this->_variables['url'] = array(
			"name" => '',
			"type" => "textbox",
			"help" => '',
			"default" => "",
			"required" => true,
		);

		$this->_variables['username'] = $this->_variables['url'];
		$this->_variables['usertoken'] = $this->_variables['url'];
	}
Пример #13
0
	/**
	* Returns a list of configured email integration routing rules
	*
	* @param string $eventId Optional, if provided, will only return rules that match the given eventId
	* @return array An array of Interspire_EmailIntegration_Rule if an empty array if no rules were configured
	*/
	public static function getRules($eventId = null)
	{
		if (self::$_rules === null) {
			// note: this loads all rules because it's a left-over from when rules were stored serialized in the store config

			/** @var mysqldb */
			$db = $GLOBALS['ISC_CLASS_DB'];
			$result = $db->Query("SELECT * FROM `[|PREFIX|]email_rules`");
			if (!$result) {
				return array();
			}

			self::$_rules = array();
			while ($row = $db->Fetch($result)) {
				$rule = Interspire_EmailIntegration_Rule::fromDatabaseRow($row);
				GetModuleById('emailintegration', /** @var ISC_EMAILINTEGRATION */$module, $rule->moduleId);
				if (!$module || !$module->IsEnabled() || !$module->isConfigured()) {
					// ignore rules for modules that doesn't exist / are not enabled / are not configured
					continue;
				}
				self::$_rules[] = $rule;
			}
		}

		if ($eventId === null) {
			return self::$_rules;
		}

		$rules = array();
		foreach (self::$_rules as /** @var Interspire_EmailIntegration_Rule */$rule) {
			if ($rule->eventId == $eventId) {
				$rules[] = $rule;
			}
		}

		if ($eventId == 'onNewsletterSubscribed' && empty($rules)) {
			// exception: if the event is newsletter subscription, and no rules are configured, provide a built-in rule that routes it to the export only module
			$rules[] = self::getBuiltInExportOnlyRule();
		}

		return $rules;
	}