コード例 #1
0
ファイル: module.exportonly.php プロジェクト: hungnv0789/vhtm
	public function addSubscriberToList ($listId, Interspire_EmailIntegration_Subscription $subscription, $fieldMap, $asynchronous = true)
	{
		/** @var ISC_LOG */
		$log = $GLOBALS['ISC_CLASS_LOG'];

		/** @var mysqldb */
		$db = $GLOBALS['ISC_CLASS_DB'];

		// the field mapping is most likely subscribers.subfirstname -> $subscription->firstName but, just incase, use the provided field map in the rule anyway
		$data = $subscription->getSubscriptionData();

		$insert = array(
			'subemail' => $subscription->getSubscriptionEmail(),
			'subfirstname' => $data[$fieldMap['subfirstname']],
		);

		$existed = (bool)$db->FetchOne("SELECT COUNT(*) FROM [|PREFIX|]subscribers WHERE subemail = '" . $db->Quote($insert['subemail']) . "'");

		if (!$existed) {
			$success = (bool)$db->InsertQuery('subscribers', $insert);
		} else {
			$success = true;
		}

		if ($success) {
			$log->LogSystemSuccess(array('emailintegration', $this->GetName()), GetLang('EmailIntegration_ExportOnly_Stored', array(
				'email' => $insert['subemail'],
			)));
		} else {
			$log->LogSystemError(array('emailintegration', $this->GetName()), GetLang('EmailIntegration_ExportOnly_FailedToStore'));
		}

		return new Interspire_EmailIntegration_AddSubscriberResult($this->GetId(), $listId, false, $success, $existed);
	}