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_Customer_AccountController
  • Mage_Customer_AddressController
  • Mage_Customer_Block_Account
  • Mage_Customer_Block_Account_Dashboard
  • Mage_Customer_Block_Account_Dashboard_Address
  • Mage_Customer_Block_Account_Dashboard_Block
  • Mage_Customer_Block_Account_Dashboard_Hello
  • Mage_Customer_Block_Account_Dashboard_Info
  • Mage_Customer_Block_Account_Dashboard_Newsletter
  • Mage_Customer_Block_Account_Dashboard_Sidebar
  • Mage_Customer_Block_Account_Forgotpassword
  • Mage_Customer_Block_Account_Navigation
  • Mage_Customer_Block_Account_Resetpassword
  • Mage_Customer_Block_Address_Book
  • Mage_Customer_Block_Address_Edit
  • Mage_Customer_Block_Address_Renderer_Default
  • Mage_Customer_Block_Form_Edit
  • Mage_Customer_Block_Form_Login
  • Mage_Customer_Block_Form_Register
  • Mage_Customer_Block_Newsletter
  • Mage_Customer_Block_Widget_Abstract
  • Mage_Customer_Block_Widget_Dob
  • Mage_Customer_Block_Widget_Gender
  • Mage_Customer_Block_Widget_Name
  • Mage_Customer_Block_Widget_Taxvat
  • Mage_Customer_Helper_Address
  • Mage_Customer_Helper_Data
  • Mage_Customer_Model_Address
  • Mage_Customer_Model_Address_Abstract
  • Mage_Customer_Model_Address_Api
  • Mage_Customer_Model_Address_Api_V2
  • Mage_Customer_Model_Address_Config
  • Mage_Customer_Model_Api2_Customer
  • Mage_Customer_Model_Api2_Customer_Address
  • Mage_Customer_Model_Api2_Customer_Address_Rest
  • Mage_Customer_Model_Api2_Customer_Address_Rest_Admin_V1
  • Mage_Customer_Model_Api2_Customer_Address_Rest_Customer_V1
  • Mage_Customer_Model_Api2_Customer_Address_Validator
  • Mage_Customer_Model_Api2_Customer_Rest
  • Mage_Customer_Model_Api2_Customer_Rest_Admin_V1
  • Mage_Customer_Model_Api2_Customer_Rest_Customer_V1
  • Mage_Customer_Model_Api_Resource
  • Mage_Customer_Model_Attribute
  • Mage_Customer_Model_Attribute_Backend_Data_Boolean
  • Mage_Customer_Model_Attribute_Data
  • Mage_Customer_Model_Attribute_Data_Abstract
  • Mage_Customer_Model_Attribute_Data_Boolean
  • Mage_Customer_Model_Attribute_Data_Date
  • Mage_Customer_Model_Attribute_Data_File
  • Mage_Customer_Model_Attribute_Data_Hidden
  • Mage_Customer_Model_Attribute_Data_Image
  • Mage_Customer_Model_Attribute_Data_Multiline
  • Mage_Customer_Model_Attribute_Data_Multiselect
  • Mage_Customer_Model_Attribute_Data_Postcode
  • Mage_Customer_Model_Attribute_Data_Select
  • Mage_Customer_Model_Attribute_Data_Text
  • Mage_Customer_Model_Attribute_Data_Textarea
  • Mage_Customer_Model_Config_Share
  • Mage_Customer_Model_Convert_Adapter_Customer
  • Mage_Customer_Model_Convert_Parser_Customer
  • Mage_Customer_Model_Customer
  • Mage_Customer_Model_Customer_Api
  • Mage_Customer_Model_Customer_Api_V2
  • Mage_Customer_Model_Customer_Attribute_Backend_Billing
  • Mage_Customer_Model_Customer_Attribute_Backend_Password
  • Mage_Customer_Model_Customer_Attribute_Backend_Shipping
  • Mage_Customer_Model_Customer_Attribute_Backend_Store
  • Mage_Customer_Model_Customer_Attribute_Backend_Website
  • Mage_Customer_Model_Customer_Attribute_Source_Group
  • Mage_Customer_Model_Customer_Attribute_Source_Store
  • Mage_Customer_Model_Customer_Attribute_Source_Website
  • Mage_Customer_Model_Entity_Address
  • Mage_Customer_Model_Entity_Address_Attribute_Backend_Region
  • Mage_Customer_Model_Entity_Address_Attribute_Backend_Street
  • Mage_Customer_Model_Entity_Address_Attribute_Collection
  • Mage_Customer_Model_Entity_Address_Attribute_Source_Country
  • Mage_Customer_Model_Entity_Address_Attribute_Source_Region
  • Mage_Customer_Model_Entity_Address_Collection
  • Mage_Customer_Model_Entity_Attribute
  • Mage_Customer_Model_Entity_Attribute_Collection
  • Mage_Customer_Model_Entity_Customer
  • Mage_Customer_Model_Entity_Customer_Collection
  • Mage_Customer_Model_Entity_Form_Attribute
  • Mage_Customer_Model_Entity_Form_Attribute_Collection
  • Mage_Customer_Model_Entity_Group
  • Mage_Customer_Model_Entity_Group_Collection
  • Mage_Customer_Model_Entity_Setup
  • Mage_Customer_Model_Entity_Wishlist_Collection
  • Mage_Customer_Model_Form
  • Mage_Customer_Model_Group
  • Mage_Customer_Model_Group_Api
  • Mage_Customer_Model_Group_Api_V2
  • Mage_Customer_Model_Observer
  • Mage_Customer_Model_Resource_Address
  • Mage_Customer_Model_Resource_Address_Attribute_Backend_Region
  • Mage_Customer_Model_Resource_Address_Attribute_Backend_Street
  • Mage_Customer_Model_Resource_Address_Attribute_Collection
  • Mage_Customer_Model_Resource_Address_Attribute_Source_Country
  • Mage_Customer_Model_Resource_Address_Attribute_Source_Region
  • Mage_Customer_Model_Resource_Address_Collection
  • Mage_Customer_Model_Resource_Attribute
  • Mage_Customer_Model_Resource_Attribute_Collection
  • Mage_Customer_Model_Resource_Customer
  • Mage_Customer_Model_Resource_Customer_Collection
  • Mage_Customer_Model_Resource_Form_Attribute
  • Mage_Customer_Model_Resource_Form_Attribute_Collection
  • Mage_Customer_Model_Resource_Group
  • Mage_Customer_Model_Resource_Group_Collection
  • Mage_Customer_Model_Resource_Setup
  • Mage_Customer_Model_Resource_Wishlist_Collection
  • Mage_Customer_Model_Session
  • Mage_Customer_ReviewController

Interfaces

  • Mage_Customer_Block_Address_Renderer_Interface

Exceptions

  • Mage_Customer_Exception
  • 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_Customer
 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:  * Customer session model
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Customer
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Customer_Model_Session extends Mage_Core_Model_Session_Abstract
 35: {
 36:     /**
 37:      * Customer object
 38:      *
 39:      * @var Mage_Customer_Model_Customer
 40:      */
 41:     protected $_customer;
 42: 
 43:     /**
 44:      * Flag with customer id validations result
 45:      *
 46:      * @var bool
 47:      */
 48:     protected $_isCustomerIdChecked = null;
 49: 
 50:     /**
 51:      * Persistent customer group id
 52:      *
 53:      * @var null|int
 54:      */
 55:     protected $_persistentCustomerGroupId = null;
 56: 
 57:     /**
 58:      * Retrieve customer sharing configuration model
 59:      *
 60:      * @return Mage_Customer_Model_Config_Share
 61:      */
 62:     public function getCustomerConfigShare()
 63:     {
 64:         return Mage::getSingleton('customer/config_share');
 65:     }
 66: 
 67:     public function __construct()
 68:     {
 69:         $namespace = 'customer';
 70:         if ($this->getCustomerConfigShare()->isWebsiteScope()) {
 71:             $namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode());
 72:         }
 73: 
 74:         $this->init($namespace);
 75:         Mage::dispatchEvent('customer_session_init', array('customer_session'=>$this));
 76:     }
 77: 
 78:     /**
 79:      * Set customer object and setting customer id in session
 80:      *
 81:      * @param   Mage_Customer_Model_Customer $customer
 82:      * @return  Mage_Customer_Model_Session
 83:      */
 84:     public function setCustomer(Mage_Customer_Model_Customer $customer)
 85:     {
 86:         // check if customer is not confirmed
 87:         if ($customer->isConfirmationRequired()) {
 88:             if ($customer->getConfirmation()) {
 89:                 return $this->_logout();
 90:             }
 91:         }
 92:         $this->_customer = $customer;
 93:         $this->setId($customer->getId());
 94:         // save customer as confirmed, if it is not
 95:         if ((!$customer->isConfirmationRequired()) && $customer->getConfirmation()) {
 96:             $customer->setConfirmation(null)->save();
 97:             $customer->setIsJustConfirmed(true);
 98:         }
 99:         return $this;
100:     }
101: 
102:     /**
103:      * Retrieve customer model object
104:      *
105:      * @return Mage_Customer_Model_Customer
106:      */
107:     public function getCustomer()
108:     {
109:         if ($this->_customer instanceof Mage_Customer_Model_Customer) {
110:             return $this->_customer;
111:         }
112: 
113:         $customer = Mage::getModel('customer/customer')
114:             ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
115:         if ($this->getId()) {
116:             $customer->load($this->getId());
117:         }
118: 
119:         $this->setCustomer($customer);
120:         return $this->_customer;
121:     }
122: 
123:     /**
124:      * Set customer id
125:      *
126:      * @param int|null $id
127:      * @return Mage_Customer_Model_Session
128:      */
129:     public function setCustomerId($id)
130:     {
131:         $this->setData('customer_id', $id);
132:         return $this;
133:     }
134: 
135:     /**
136:      * Retrieve customer id from current session
137:      *
138:      * @return int|null
139:      */
140:     public function getCustomerId()
141:     {
142:         if ($this->getData('customer_id')) {
143:             return $this->getData('customer_id');
144:         }
145:         return ($this->isLoggedIn()) ? $this->getId() : null;
146:     }
147: 
148:     /**
149:      * Set customer group id
150:      *
151:      * @param int|null $id
152:      * @return Mage_Customer_Model_Session
153:      */
154:     public function setCustomerGroupId($id)
155:     {
156:         $this->setData('customer_group_id', $id);
157:         return $this;
158:     }
159: 
160:     /**
161:      * Get customer group id
162:      * If customer is not logged in system, 'not logged in' group id will be returned
163:      *
164:      * @return int
165:      */
166:     public function getCustomerGroupId()
167:     {
168:         if ($this->getData('customer_group_id')) {
169:             return $this->getData('customer_group_id');
170:         }
171:         if ($this->isLoggedIn() && $this->getCustomer()) {
172:             return $this->getCustomer()->getGroupId();
173:         }
174:         return Mage_Customer_Model_Group::NOT_LOGGED_IN_ID;
175:     }
176: 
177:     /**
178:      * Checking customer login status
179:      *
180:      * @return bool
181:      */
182:     public function isLoggedIn()
183:     {
184:         return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId());
185:     }
186: 
187:     /**
188:      * Check exists customer (light check)
189:      *
190:      * @param int $customerId
191:      * @return bool
192:      */
193:     public function checkCustomerId($customerId)
194:     {
195:         if ($this->_isCustomerIdChecked === null) {
196:             $this->_isCustomerIdChecked = Mage::getResourceSingleton('customer/customer')->checkCustomerId($customerId);
197:         }
198:         return $this->_isCustomerIdChecked;
199:     }
200: 
201:     /**
202:      * Customer authorization
203:      *
204:      * @param   string $username
205:      * @param   string $password
206:      * @return  bool
207:      */
208:     public function login($username, $password)
209:     {
210:         /** @var $customer Mage_Customer_Model_Customer */
211:         $customer = Mage::getModel('customer/customer')
212:             ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
213: 
214:         if ($customer->authenticate($username, $password)) {
215:             $this->setCustomerAsLoggedIn($customer);
216:             $this->renewSession();
217:             return true;
218:         }
219:         return false;
220:     }
221: 
222:     public function setCustomerAsLoggedIn($customer)
223:     {
224:         $this->setCustomer($customer);
225:         Mage::dispatchEvent('customer_login', array('customer'=>$customer));
226:         return $this;
227:     }
228: 
229:     /**
230:      * Authorization customer by identifier
231:      *
232:      * @param   int $customerId
233:      * @return  bool
234:      */
235:     public function loginById($customerId)
236:     {
237:         $customer = Mage::getModel('customer/customer')->load($customerId);
238:         if ($customer->getId()) {
239:             $this->setCustomerAsLoggedIn($customer);
240:             return true;
241:         }
242:         return false;
243:     }
244: 
245:     /**
246:      * Logout customer
247:      *
248:      * @return Mage_Customer_Model_Session
249:      */
250:     public function logout()
251:     {
252:         if ($this->isLoggedIn()) {
253:             Mage::dispatchEvent('customer_logout', array('customer' => $this->getCustomer()) );
254:             $this->_logout();
255:         }
256:         return $this;
257:     }
258: 
259:     /**
260:      * Authenticate controller action by login customer
261:      *
262:      * @param   Mage_Core_Controller_Varien_Action $action
263:      * @param   bool $loginUrl
264:      * @return  bool
265:      */
266:     public function authenticate(Mage_Core_Controller_Varien_Action $action, $loginUrl = null)
267:     {
268:         if ($this->isLoggedIn()) {
269:             return true;
270:         }
271: 
272:         $this->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true)));
273:         if (isset($loginUrl)) {
274:             $action->getResponse()->setRedirect($loginUrl);
275:         } else {
276:             $action->setRedirectWithCookieCheck(Mage_Customer_Helper_Data::ROUTE_ACCOUNT_LOGIN,
277:                 Mage::helper('customer')->getLoginUrlParams()
278:             );
279:         }
280: 
281:         return false;
282:     }
283: 
284:     /**
285:      * Set auth url
286:      *
287:      * @param string $key
288:      * @param string $url
289:      * @return Mage_Customer_Model_Session
290:      */
291:     protected function _setAuthUrl($key, $url)
292:     {
293:         $url = Mage::helper('core/url')
294:             ->removeRequestParam($url, Mage::getSingleton('core/session')->getSessionIdQueryParam());
295:         // Add correct session ID to URL if needed
296:         $url = Mage::getModel('core/url')->getRebuiltUrl($url);
297:         return $this->setData($key, $url);
298:     }
299: 
300:     /**
301:      * Logout without dispatching event
302:      *
303:      * @return Mage_Customer_Model_Session
304:      */
305:     protected function _logout()
306:     {
307:         $this->setId(null);
308:         $this->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
309:         $this->getCookie()->delete($this->getSessionName());
310:         return $this;
311:     }
312: 
313:     /**
314:      * Set Before auth url
315:      *
316:      * @param string $url
317:      * @return Mage_Customer_Model_Session
318:      */
319:     public function setBeforeAuthUrl($url)
320:     {
321:         return $this->_setAuthUrl('before_auth_url', $url);
322:     }
323: 
324:     /**
325:      * Set After auth url
326:      *
327:      * @param string $url
328:      * @return Mage_Customer_Model_Session
329:      */
330:     public function setAfterAuthUrl($url)
331:     {
332:         return $this->_setAuthUrl('after_auth_url', $url);
333:     }
334: 
335:     /**
336:      * Reset core session hosts after reseting session ID
337:      *
338:      * @return Mage_Customer_Model_Session
339:      */
340:     public function renewSession()
341:     {
342:         parent::renewSession();
343:         Mage::getSingleton('core/session')->unsSessionHosts();
344: 
345:         return $this;
346:     }
347: }
348: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0