Page MenuHomeIn-Portal Phabricator

D27.id77.diff
No OneTemporary

File Metadata

Created
Sat, Feb 1, 10:52 PM

D27.id77.diff

Index: modules/in-commerce/units/affiliates/affiliates_tag_processor.php
===================================================================
--- modules/in-commerce/units/affiliates/affiliates_tag_processor.php
+++ modules/in-commerce/units/affiliates/affiliates_tag_processor.php
@@ -18,51 +18,69 @@
/**
* Returns link to be placed on other sites
*
- * @param Array $params
+ * @param array $params Tag params.
+ *
* @return string
*/
- function GetAffiliateLink($params)
+ protected function GetAffiliateLink(array $params)
{
+ /** @var kDBItem $object */
$object = $this->getObject($params);
- /* @var $object kDBItem */
-
- $params['affiliate'] = $object->GetDBField('AffiliateCode');
- $params['prefix'] = '_FRONT_END_';
- $params['index_file'] = 'index.php';
-
- // to build non-SSL link without SID in case, when SSL is enabled (or SSL domain doesn't match non-SSL domain)
- $params['__SSL__'] = 0;
- $params['__NO_SID__'] = 1;
-
- $link = $this->Application->ProcessParsedTag('m', 'Link', $params);
- // remove env manually
- return preg_replace('/(.*)\/index.php\?env=(.*?)&(.*)/', '\\1/index.php?\\3', $link);
+ return $this->buildAffiliateLink($object);
}
/**
* Returns link to be placed on other sites (for current user)
*
- * @param Array $params
+ * @param array $params Tag params.
+ *
* @return string
*/
- function GetUserAffiliateLink($params)
+ protected function GetUserAffiliateLink(array $params)
{
- $object = $this->getObject(kUtil::array_merge_recursive($params, array('skip_autoload' => true)));
- /* @var $object kDBItem */
+ /** @var kDBItem $object */
+ $object = $this->Application->recallObject($this->Prefix . '.manual', null, array('skip_autoload' => true));
+ $object->Load($this->Application->RecallVar('user_id'), 'PortalUserId');
- $object->Load(array('PortalUserId' => $this->Application->RecallVar('user_id')));
+ return $this->buildAffiliateLink($object);
+ }
- $params['index_file'] = 'index.php';
+ /**
+ * Builds affiliate link for given affiliate record.
+ *
+ * @param kDBBase $object Affiliate.
+ *
+ * @return string
+ */
+ protected function buildAffiliateLink(kDBBase $object)
+ {
$params['affiliate'] = $object->GetDBField('AffiliateCode');
- // to build non-SSL link without SID in case, when SSL is enabled (or SSL domain doesn't match non-SSL domain)
+ if ( $this->Application->isAdmin ) {
+ $params['prefix'] = '_FRONT_END_';
+ }
+
+ // Force defaults to remove "index.html" in Mod-Rewrite mode.
+ $params['template'] = 'index';
+ $params['m_lang'] = $this->Application->GetDefaultLanguageId();
+ $params['m_theme'] = $this->Application->GetDefaultThemeId();
+
+ // Build non-SSL link without SID in case, when SSL is enabled (or SSL domain doesn't match non-SSL domain).
$params['__SSL__'] = 0;
$params['__NO_SID__'] = 1;
+ // Use Mod-Rewrite, when available.
+ if ( $this->Application->ConfigValue('UseModRewrite') ) {
+ $params['__MOD_REWRITE__'] = 1;
+ }
+ else {
+ $params['index_file'] = 'index.php';
+ }
+
$link = $this->Application->ProcessParsedTag('m', 'Link', $params);
- // remove env manually
+ // Manually remove "env".
return preg_replace('/(.*)\/index.php\?env=(.*?)&(.*)/', '\\1/index.php?\\3', $link);
}
@@ -171,4 +189,4 @@
$this->Application->HandleEvent(new kEvent($prefix . ':OnNew'));
}
}
- }
\ No newline at end of file
+ }

Event Timeline