예제 #1
0
파일: Merge.php 프로젝트: nabble/ajde-core
 public static function mergeClientToUser()
 {
     Model::register('user');
     Model::register('shop');
     if ($user = User::getLoggedIn()) {
         // Do we have a saved client cart?
         $clientCart = new CartModel();
         if ($clientCart->loadByClient()) {
             // Do we have a saved cart for logged in user?
             $userCart = new CartModel();
             if ($userCart->loadByUser($user) === false) {
                 $userCart->user = $user->getPK();
                 $userCart->insert();
             }
             if ($userCart->hasItems()) {
                 // Set alert message
                 Flash::alert(__("Your items are still in the shopping cart"));
             }
             // Merge items
             foreach ($clientCart->getItems() as $item) {
                 /* @var $item Ajde_Shop_Cart_Item */
                 $userCart->addItem($item->getEntity(), null, $item->getQty());
             }
             // And delete client
             $clientCart->delete();
         }
     }
 }
예제 #2
0
파일: User.php 프로젝트: nabble/ajde-core
 public function verifyCookie($includeDomain = true)
 {
     $cookie = new Cookie(Config::get('ident') . '_user', true);
     if (!$cookie->has('auth')) {
         return false;
     }
     $auth = $cookie->get('auth');
     list($uid, $hash) = explode(':', $auth);
     if (!$this->loadByPK($uid)) {
         return false;
     }
     if ($this->getCookieHash($includeDomain) === $hash) {
         $this->login();
         Flash::alert(sprintf(__('Welcome back %s'), $this->getFullname()));
         Cache::getInstance()->disable();
     } else {
         return false;
     }
 }