コード例 #1
0
ファイル: oto.php プロジェクト: alexanderTsig/arabic
 function _onThanksPage(Am_Event $event)
 {
     /* @var $invoice Invoice */
     $invoice = $event->getInvoice();
     /* @var $controller ThanksController */
     $controller = $event->getController();
     if (!$invoice || !$invoice->tm_started) {
         return;
     }
     // invoice is not yet paid
     $this->getDi()->blocks->add(new Am_Block('thanks/success', 'Parent Invoices', 'oto-parents', $this, array($this, 'renderParentInvoices')));
     // find first matching upsell
     $oto = $this->getDi()->otoTable->findUpsell($invoice->getProducts());
     if ($controller->getRequest()->get('oto') == 'no') {
         $oto = $this->getDi()->otoTable->findDownsell($invoice->data()->get(self::LAST_OTO_SHOWN));
     }
     if (!$oto) {
         return;
     }
     $event->stop();
     if ($controller->getRequest()->get('oto') == 'yes') {
         return $this->yesOto($controller, $invoice, $this->getDi()->otoTable->load($invoice->data()->get(self::LAST_OTO_SHOWN)));
     }
     $invoice->data()->set(self::LAST_OTO_SHOWN, $oto->pk())->update();
     $html = $oto->render();
     $controller->getResponse()->setBody($html);
     throw new Am_Exception_Redirect();
 }
コード例 #2
0
 function onAuthCheckUser(Am_Event $event)
 {
     /* @var $user User */
     $user = $event->getUser();
     $recs = $this->getDi()->loginSessionTable->findBy(array('user_id' => $user->pk(), 'session_id' => '<>' . Zend_Session::getId(), 'modified' => '>' . sqlTime(sprintf('-%d minutes', $this->getConfig('timeout', 5))), 'need_logout' => 0));
     if ($recs) {
         switch ($this->getConfig('action', self::ACTION_LOGIN_REJECT)) {
             case self::ACTION_LOGIN_REJECT:
                 $event->setReturn(new Am_Auth_Result(-100, $this->getConfig('error', 'There is already exits active login session for your account.
                         Simultaneous login from different computers is not allowed.')));
                 $event->stop();
                 break;
             case self::ACTION_LOGOUT_OTHER:
                 foreach ($recs as $rec) {
                     $rec->updateQuick('need_logout', 1);
                 }
                 break;
             case self::ACTION_NOTHING:
                 break;
         }
         if ($this->getConfig('notify_admin') && !$this->getDi()->store->get('single-login-session-detected-' . $user->pk())) {
             $this->getDi()->store->set('single-login-session-detected-' . $user->pk(), 1, '+20 minutes');
             if ($et = Am_Mail_Template::load('misc.single-login-session.notify_admin')) {
                 $et->setUser($user);
                 $et->sendAdmin();
             }
         }
     }
 }