Index: branches/5.2.x/units/affiliates/affiliates_tag_processor.php =================================================================== diff -u -N -r14582 -r14625 --- branches/5.2.x/units/affiliates/affiliates_tag_processor.php (.../affiliates_tag_processor.php) (revision 14582) +++ branches/5.2.x/units/affiliates/affiliates_tag_processor.php (.../affiliates_tag_processor.php) (revision 14625) @@ -1,6 +1,6 @@ Application->recallObject($this->Prefix.'.user', $this->Prefix, Array('skip_autoload'=>true) ); - $object->Load( $this->Application->RecallVar('user_id'), 'PortalUserId' ); - + $object =& $this->Application->recallObject($this->Prefix . '.user'); + /* @var $object kDBItem */ + return $object->isLoaded(); } - function User_AffiliateIsNotActive($params) + /** + * [Aggregated Tag] Checks, that affiliate record for current user exists and is active + * + * @param $params + * @return bool + * @access protected + */ + protected function User_AffiliateIsActive($params) { - $object =& $this->Application->recallObject($this->Prefix.'.user', $this->Prefix, Array('skip_autoload'=>true) ); - $object->Load( $this->Application->RecallVar('user_id'), 'PortalUserId' ); + $object =& $this->Application->recallObject($this->Prefix . '.user'); + /* @var $object kDBItem */ - return $object->isLoaded() && ($object->GetDBField('Status') != 1); + return $object->isLoaded() && ($object->GetDBField('Status') == STATUS_ACTIVE); } /** @@ -115,14 +123,14 @@ function IsAffiliateOrRegisterAsAffiliateAllowed($params) { - $object =& $this->Application->recallObject($this->Prefix.'.user', $this->Prefix, Array('skip_autoload'=>true) ); - $object->Load( $this->Application->RecallVar('user_id'), 'PortalUserId' ); + $object =& $this->Application->recallObject($this->Prefix . '.user'); + /* @var $object kDBItem */ - return ($this->Application->ConfigValue('Comm_RegisterAsAffiliate') || $object->isLoaded()) ? 1 : 0; + return $this->Application->ConfigValue('Comm_RegisterAsAffiliate') || $object->isLoaded() ? 1 : 0; } /** - * [AGGREGATED TAG] Checks if affilite registration is allowed + * [AGGREGATED TAG] Checks if affiliate registration is allowed * * @param Array $params * @return int @@ -135,10 +143,24 @@ function Main_RequireAffiliate($params) { $t = $params['registration_template']; - if( !$this->User_IsAffiliate($params) ) - { - $redirect_params = Array( 'next_template' => $this->Application->GetVar('t') ); + + if ( !$this->User_IsAffiliate($params) ) { + $redirect_params = Array ('next_template' => $this->Application->GetVar('t')); $this->Application->Redirect($t, $redirect_params); } } + + /** + * Calls OnNew event from template, when no other event submitted + * + * @param Array $params + */ + function PresetFormFields($params) + { + $prefix = $this->getPrefixSpecial(); + + if ( !$this->Application->GetVar($prefix . '_event') && !$this->Application->GetVar('u.register_event') ) { + $this->Application->HandleEvent(new kEvent($prefix . ':OnNew')); + } + } } \ No newline at end of file