Public Member Functions | |
getCustomerConfigShare () | |
__construct () | |
setCustomer (Mage_Customer_Model_Customer $customer) | |
getCustomer () | |
getCustomerId () | |
getCustomerGroupId () | |
isLoggedIn () | |
checkCustomerId ($customerId) | |
login ($username, $password) | |
setCustomerAsLoggedIn ($customer) | |
loginById ($customerId) | |
logout () | |
authenticate (Mage_Core_Controller_Varien_Action $action, $loginUrl=null) | |
Protected Attributes | |
$_customer |
Definition at line 34 of file Session.php.
__construct | ( | ) |
Constructor
By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes
Reimplemented from Varien_Object.
Definition at line 48 of file Session.php.
00049 { 00050 $namespace = 'customer'; 00051 if ($this->getCustomerConfigShare()->isWebsiteScope()) { 00052 $namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode()); 00053 } 00054 00055 $this->init($namespace); 00056 Mage::dispatchEvent('customer_session_init', array('customer_session'=>$this)); 00057 }
authenticate | ( | Mage_Core_Controller_Varien_Action $ | action, | |
$ | loginUrl = null | |||
) |
Authenticate controller action by login customer
Mage_Core_Controller_Varien_Action | $action |
Definition at line 217 of file Session.php.
00218 { 00219 if (!$this->isLoggedIn()) { 00220 $this->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current'=>true))); 00221 if (is_null($loginUrl)) { 00222 $loginUrl = Mage::helper('customer')->getLoginUrl(); 00223 } 00224 $action->getResponse()->setRedirect($loginUrl); 00225 return false; 00226 } 00227 return true; 00228 }
checkCustomerId | ( | $ | customerId | ) |
Check exists customer (light check)
int | $customerId |
Definition at line 147 of file Session.php.
00148 { 00149 return Mage::getResourceSingleton('customer/customer') 00150 ->checkCustomerId($customerId); 00151 }
getCustomer | ( | ) |
Retrieve costomer model object
Definition at line 90 of file Session.php.
00091 { 00092 if ($this->_customer instanceof Mage_Customer_Model_Customer) { 00093 return $this->_customer; 00094 } 00095 00096 $customer = Mage::getModel('customer/customer') 00097 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); 00098 if ($this->getId()) { 00099 $customer->load($this->getId()); 00100 } 00101 00102 $this->setCustomer($customer); 00103 return $this->_customer; 00104 }
getCustomerConfigShare | ( | ) |
Retrieve customer sharing configuration model
Definition at line 43 of file Session.php.
00044 { 00045 return Mage::getSingleton('customer/config_share'); 00046 }
getCustomerGroupId | ( | ) |
Get customer group id If customer is not logged in system not logged in group id will be returned
Definition at line 122 of file Session.php.
00123 { 00124 if ($this->isLoggedIn()) { 00125 return $this->getCustomer()->getGroupId(); 00126 } else { 00127 return Mage_Customer_Model_Group::NOT_LOGGED_IN_ID; 00128 } 00129 }
getCustomerId | ( | ) |
Retrieve customer id from current session
Definition at line 111 of file Session.php.
00112 { 00113 return $this->getId(); 00114 }
isLoggedIn | ( | ) |
Checking custommer loggin status
Definition at line 136 of file Session.php.
00137 { 00138 return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId()); 00139 }
login | ( | $ | username, | |
$ | password | |||
) |
Customer authorization
string | $username | |
string | $password |
Definition at line 160 of file Session.php.
00161 { 00162 $customer = Mage::getModel('customer/customer') 00163 ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); 00164 00165 if ($customer->authenticate($username, $password)) { 00166 $this->setCustomer($customer); 00167 Mage::dispatchEvent('customer_login', array('customer'=>$customer)); 00168 return true; 00169 } 00170 return false; 00171 }
loginById | ( | $ | customerId | ) |
Authorization customer by identifier
int | $customerId |
Definition at line 186 of file Session.php.
00187 { 00188 $customer = Mage::getModel('customer/customer')->load($customerId); 00189 if ($customer) { 00190 $this->setCustomer($customer); 00191 Mage::dispatchEvent('customer_login', array('customer'=>$customer)); 00192 return true; 00193 } 00194 return false; 00195 }
logout | ( | ) |
Logout customer
Definition at line 202 of file Session.php.
00203 { 00204 if ($this->isLoggedIn()) { 00205 Mage::dispatchEvent('customer_logout', array('customer' => $this->getCustomer()) ); 00206 $this->setId(null); 00207 } 00208 return $this; 00209 }
setCustomer | ( | Mage_Customer_Model_Customer $ | customer | ) |
Set customer object and setting customer id in session
Mage_Customer_Model_Customer | $customer |
Definition at line 65 of file Session.php.
00066 { 00067 // check if customer is not confirmed 00068 if ($customer->isConfirmationRequired()) { 00069 if ($customer->getConfirmation()) { 00070 throw new Exception('This customer is not confirmed and cannot log in.', 00071 Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED 00072 ); 00073 } 00074 } 00075 $this->_customer = $customer; 00076 $this->setId($customer->getId()); 00077 // save customer as confirmed, if it is not 00078 if ((!$customer->isConfirmationRequired()) && $customer->getConfirmation()) { 00079 $customer->setConfirmation(null)->save(); 00080 $customer->setIsJustConfirmed(true); 00081 } 00082 return $this; 00083 }
setCustomerAsLoggedIn | ( | $ | customer | ) |
Definition at line 173 of file Session.php.
00174 { 00175 $this->setCustomer($customer); 00176 Mage::dispatchEvent('customer_login', array('customer'=>$customer)); 00177 return $this; 00178 }
$_customer [protected] |
Definition at line 36 of file Session.php.