frontend/controllers/ProxyController.php
/**
     * Checks if user can proceed to download\stream
     *
     * @param  User $user
     * @param  UnrestrainedLink $link
     * @return boolean
     */
Checks if user can proceed to download\stream
@param  User $user
@param  UnrestrainedLink $link
@return boolean
Checks if user can proceed to download \ stream @param User $user @param UnrestrainedLink $link @return boolean
private function canProceed($user, $link)
    {
        $canProceed = false;
        $plan = $user->plan;
        if ($plan != null && $plan->isActive()) {
            if ($plan->product_type == Product::TYPE_DAILY) {
                if ($plan->expire >= time()) {
                    $canProceed = true;
                }
            } else if ($plan->product_type == Product::TYPE_LIMITED) {
                $bytesSended = DownloadJournal::getBytesSendedToUser($user, $plan->start);
                if ($plan->getLimitInBytes() >= ($bytesSended + $link->content_size)) {
                    $canProceed = true;
                }
            }
            if (!$canProceed && $plan != null && $plan->isActive()) {
                $plan->setScenario(UserPlan::SCENARIO_UPDATE);
                $plan->status = UserPlan::STATUS_EXPIRED;
                $plan->save();
            }
        }
        return $canProceed;
    }
private function canProceed ( $ user , $ link ) { $ canProceed = false ; $ plan = $ user -> plan ; if ( $ plan != null && $ plan -> isActive ( ) ) { if ( $ plan -> product_type == Product :: TYPE_DAILY ) { if ( $ plan -> expire >= time ( ) ) { $ canProceed = true ; } } else if ( $ plan -> product_type == Product :: TYPE_LIMITED ) { $ bytesSended = DownloadJournal :: getBytesSendedToUser ( $ user , $ plan -> start ) ; if ( $ plan -> getLimitInBytes ( ) >= ( $ bytesSended + $ link -> content_size ) ) { $ canProceed = true ; } } if ( ! $ canProceed && $ plan != null && $ plan -> isActive ( ) ) { $ plan -> setScenario ( UserPlan :: SCENARIO_UPDATE ) ; $ plan -> status = UserPlan :: STATUS_EXPIRED ; $ plan -> save ( ) ; } } return $ canProceed ; }
Checks if user can proceed to download\stream
 @param  User $user
 @param  UnrestrainedLink $link
 @return boolean
Checks if user can proceed to download \ stream @param User $user @param UnrestrainedLink $link @return boolean
//If user's plan is daily, check if it's not exipred //If user's plan is limited check if user has enought limit to download file //User's plan is expired. Update it