frontend/components/behaviors/ReferralBehavior.php
/**
     * "Catches" referral and creates record in referral journal
     *
     * @param  common\models\ReferralAction $action referal journal action
     * @return boolean                              true when referral journal record is created
     */
"Catches" referral and creates record in referral journal
@param  common\models\ReferralAction $action referal journal action
@return boolean                              true when referral journal record is created
" Catches " referral and creates record in referral journal @param common \ models \ ReferralAction $action referal journal action @return boolean true when referral journal record is created
private function catchReferral(ReferralAction $action)
    {
         $trk = $this->getTrackingNum();
         if ($trk !== null) {
             if ((list($uid, $lid, $unq) = $this->parseTrackingNum($trk)) === false) {
                 Yii::error("Can\'t parse tracking number {$trk}");
                 return false;
             }
             $rec = new ReferralJournal();
             $rec->setScenario(ReferralJournal::SCENARIO_CREATE);
             $rec->user_id = $uid;
             $rec->referral_link_id = $lid;
             $rec->action_id = $action->id;
             $rec->tracking_num = $trk;
             if ($rec->save()) {
                 $rec->owner->grantReferralPoints($action->points);
                 if (!$rec->owner->save()) {
                    Yii::error('referral', 'Failed to grant referral points to user. Referral journal rec id - '.$rec->id);
                 }
             }
         }
    }
private function catchReferral ( ReferralAction $ action ) { $ trk = $ this -> getTrackingNum ( ) ; if ( $ trk !== null ) { if ( ( list ( $ uid , $ lid , $ unq ) = $ this -> parseTrackingNum ( $ trk ) ) === false ) { Yii :: error ( " Can\'t parse tracking number  { $ trk } " ) ; return false ; } $ rec = new ReferralJournal ( ) ; $ rec -> setScenario ( ReferralJournal :: SCENARIO_CREATE ) ; $ rec -> user_id = $ uid ; $ rec -> referral_link_id = $ lid ; $ rec -> action_id = $ action -> id ; $ rec -> tracking_num = $ trk ; if ( $ rec -> save ( ) ) { $ rec -> owner -> grantReferralPoints ( $ action -> points ) ; if ( ! $ rec -> owner -> save ( ) ) { Yii :: error ( 'referral' , 'Failed to grant referral points to user. Referral journal rec id - ' . $ rec -> id ) ; } } } }
"Catches" referral and creates record in referral journal
 @param  common\models\ReferralAction $action referal journal action
 @return boolean                              true when referral journal record is created
" Catches " referral and creates record in referral journal @param common \ models \ ReferralAction $action referal journal action @return boolean true when referral journal record is created