Esempio n. 1
0
 /**
  * List of subscriptions
  */
 public function indexAction()
 {
     $subscriptionPlansTable = new Subscriptions_Model_SubscriptionPlans_Table();
     $this->view->subscriptionPlan = $subscriptionPlansTable->fetchAll();
     //Get user
     $identity = Zend_Auth::getInstance()->getIdentity();
     if ($identity) {
         $userId = $identity->id;
         //Get current subscription
         $subscriptionManager = new Subscriptions_Model_Subscription_Manager();
         $currentSubscription = $subscriptionManager->getCurrentSubscription($userId);
         if ($currentSubscription) {
             $subscriptionPlansTable = new Subscriptions_Model_SubscriptionPlans_Table();
             $currentSubscriptionPlan = $subscriptionPlansTable->getById($currentSubscription->subscriptionPlanId);
             $paypalHost = false;
             if (Zend_Registry::isRegistered('payments')) {
                 $payments = Zend_Registry::get('payments');
                 if (isset($payments['gateways']) && $payments['gateways'] && isset($payments['gateways']['paypal']) && $payments['gateways']['paypal']) {
                     $paypalHost = $payments['gateways']['paypal']['paypalHost'];
                 }
             }
             if (!$paypalHost) {
                 if (Zend_Registry::isRegistered('Log')) {
                     $log = Zend_Registry::get('Log');
                     $log->log("PayPal is not configured.", Zend_Log::CRIT);
                 }
                 throw new Exception($this->__("Paypal is not configured."));
             }
             $this->view->paypalHost = $paypalHost;
             $this->view->currentSubscription = $currentSubscription;
             $this->view->currentSubscriptionPlan = $currentSubscriptionPlan;
         }
     }
 }