Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Persistent_Block_Form_Remember
  • Mage_Persistent_Block_Header_Additional
  • Mage_Persistent_Helper_Data
  • Mage_Persistent_Helper_Session
  • Mage_Persistent_IndexController
  • Mage_Persistent_Model_Observer
  • Mage_Persistent_Model_Observer_Session
  • Mage_Persistent_Model_Persistent_Config
  • Mage_Persistent_Model_Resource_Session
  • Mage_Persistent_Model_Session
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Persistent
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Persistent Shopping Cart Data Helper
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Persistent
 33:  * @author     Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Persistent_Helper_Session extends Mage_Core_Helper_Data
 36: {
 37:     /**
 38:      * Instance of Session Model
 39:      *
 40:      * @var null|Mage_Persistent_Model_Session
 41:      */
 42:     protected $_sessionModel;
 43: 
 44:     /**
 45:      * Persistent customer
 46:      *
 47:      * @var null|Mage_Customer_Model_Customer
 48:      */
 49:     protected $_customer;
 50: 
 51:     /**
 52:      * Is "Remember Me" checked
 53:      *
 54:      * @var null|bool
 55:      */
 56:     protected $_isRememberMeChecked;
 57: 
 58:     /**
 59:      * Get Session model
 60:      *
 61:      * @return Mage_Persistent_Model_Session
 62:      */
 63:     public function getSession()
 64:     {
 65:         if (is_null($this->_sessionModel)) {
 66:             $this->_sessionModel = Mage::getModel('persistent/session');
 67:             $this->_sessionModel->loadByCookieKey();
 68:         }
 69:         return $this->_sessionModel;
 70:     }
 71: 
 72:     /**
 73:      * Force setting session model
 74:      *
 75:      * @param Mage_Persistent_Model_Session $sessionModel
 76:      * @return Mage_Persistent_Model_Session
 77:      */
 78:     public function setSession($sessionModel)
 79:     {
 80:         $this->_sessionModel = $sessionModel;
 81:         return $this->_sessionModel;
 82:     }
 83: 
 84:     /**
 85:      * Check whether persistent mode is running
 86:      *
 87:      * @return bool
 88:      */
 89:     public function isPersistent()
 90:     {
 91:         return $this->getSession()->getId() && Mage::helper('persistent')->isEnabled();
 92:     }
 93: 
 94:     /**
 95:      * Check if "Remember Me" checked
 96:      *
 97:      * @return bool
 98:      */
 99:     public function isRememberMeChecked()
100:     {
101:         if (is_null($this->_isRememberMeChecked)) {
102:             //Try to get from checkout session
103:             $isRememberMeChecked = Mage::getSingleton('checkout/session')->getRememberMeChecked();
104:             if (!is_null($isRememberMeChecked)) {
105:                 $this->_isRememberMeChecked = $isRememberMeChecked;
106:                 Mage::getSingleton('checkout/session')->unsRememberMeChecked();
107:                 return $isRememberMeChecked;
108:             }
109: 
110:             /** @var $helper Mage_Persistent_Helper_Data */
111:             $helper = Mage::helper('persistent');
112:             return $helper->isEnabled() && $helper->isRememberMeEnabled() && $helper->isRememberMeCheckedDefault();
113:         }
114: 
115:         return (bool)$this->_isRememberMeChecked;
116:     }
117: 
118:     /**
119:      * Set "Remember Me" checked or not
120:      *
121:      * @param bool $checked
122:      */
123:     public function setRememberMeChecked($checked = true)
124:     {
125:         $this->_isRememberMeChecked = $checked;
126:     }
127: 
128:     /**
129:      * Return persistent customer
130:      *
131:      * @return Mage_Customer_Model_Customer|bool
132:      */
133:     public function getCustomer()
134:     {
135:         if (is_null($this->_customer)) {
136:             $customerId = $this->getSession()->getCustomerId();
137:             $this->_customer = Mage::getModel('customer/customer')->load($customerId);
138:         }
139:         return $this->_customer;
140:     }
141: }
142: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0