public function checkCustomerId($customerId) { $result = parent::checkCustomerId($customerId); if ($result) { $customer = Mage::getModel('customer/customer')->load($customerId); if (Mage::getStoreConfig('amcustomerattr/activation/activation_required', $customer->getStoreId()) && Amasty_Customerattr_Model_Rewrite_Customer::ACTIVATION_STATUS_ACTIVATED !== $customer->getAmIsActivated()) { return false; } } return $result; }
public function checkCustomerId($customerId) { $result = parent::checkCustomerId($customerId); if ($result) { $customer = Mage::getModel('customer/customer')->load($customerId); if (Amasty_Customerattr_Model_Rewrite_Customer::ACTIVATION_STATUS_ACTIVATED !== $customer->getAmIsActivated()) { return false; } } return $result; }
/** * Check customer scope, email,company name and confirmation key before saving */ protected function _beforeSave(Varien_Object $customer) { parent::_beforeSave($customer); if (!$customer->getEmail()) { throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('Customer email is required')); } $adapter = $this->_getWriteAdapter(); $bind = array('email' => $customer->getCompanyName()); $select = $adapter->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email = :email'); if ($customer->getSharingConfig()->isWebsiteScope()) { $bind['website_id'] = (int) $customer->getWebsiteId(); $select->where('website_id = :website_id'); } if ($customer->getId()) { $bind['entity_id'] = (int) $customer->getId(); $select->where('entity_id != :entity_id'); } $result = $adapter->fetchOne($select, $bind); if ($result) { throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('This customer email already exists'), Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS); } /*Get attribute id of attribute company_name*/ $code = 'company_name'; $companyAttribute = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($code)->getFirstItem(); $companyAttrId = $companyAttribute->getId(); /*Check if same company name already exist*/ $writeAdapter = $this->_getWriteAdapter(); $companybind = array('company_name' => $customer->getCompanyName()); $resource = Mage::getSingleton("core/resource"); $compselect = $writeAdapter->select()->from($resource->getTableName('customer_entity_varchar'), array($this->getEntityIdField()))->where('value = :company_name AND attribute_id =' . $companyAttrId); if ($customer->getId()) { $companybind['entity_id'] = (int) $customer->getId(); $compselect->where('entity_id != :entity_id'); } $compresult = $writeAdapter->fetchOne($compselect, $companybind); if ($compresult) { throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('Company name already exist')); } /*Check if same company name already exist*/ // set confirmation key logic if ($customer->getForceConfirmed()) { $customer->setConfirmation(null); } elseif (!$customer->getId() && $customer->isConfirmationRequired()) { $customer->setConfirmation($customer->getRandomConfirmationKey()); } // remove customer confirmation key from database, if empty if (!$customer->getConfirmation()) { $customer->setConfirmation(null); } return $this; }
public function loadByEmail(Mage_Customer_Model_Customer $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c, $_ff0a3525eb1a63ce44e7951a0b522829a4d2f607, $_f970317d6ba1fcd2cb9e02bbb6f967c922e4e5ca = false) { $_39cc59a647aed4446ab8f3ef32b7135f664a845f = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('email', $_ff0a3525eb1a63ce44e7951a0b522829a4d2f607); $_ecd7e55877f28a8e3e14ca46c40ecf420dcdb9a6 = Mage::app()->getRequest()->getPost('original_login'); if (strpos($_ff0a3525eb1a63ce44e7951a0b522829a4d2f607, "@") === false) { $_ecd7e55877f28a8e3e14ca46c40ecf420dcdb9a6 = array('username' => $_ff0a3525eb1a63ce44e7951a0b522829a4d2f607); } if (isset($_ecd7e55877f28a8e3e14ca46c40ecf420dcdb9a6['username'])) { $_39cc59a647aed4446ab8f3ef32b7135f664a845f = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('customer_id', $_ecd7e55877f28a8e3e14ca46c40ecf420dcdb9a6['username']); } $_930a0745b391fca7316377cbe31f8f0a4441b9d3 = Mage::app()->getRequest(); $_c50c3755974ed43c1eb96eb5e083f81b281339d0 = (bool) ($_930a0745b391fca7316377cbe31f8f0a4441b9d3->getControllerName() . '_' . $_930a0745b391fca7316377cbe31f8f0a4441b9d3->getActionName() == 'account_loginPost'); $_1a3023404ab69f5356a5aefcbc28ffa4866f85a0 = (bool) ($_930a0745b391fca7316377cbe31f8f0a4441b9d3->getControllerName() . '_' . $_930a0745b391fca7316377cbe31f8f0a4441b9d3->getActionName() == 'customer_account_loginPost'); $_3a69ee1fffa7b37ae32c13e48dfd5890e9ca68d9 = (bool) ($_930a0745b391fca7316377cbe31f8f0a4441b9d3->getControllerName() . '_' . $_930a0745b391fca7316377cbe31f8f0a4441b9d3->getActionName() == 'account_forgotpasswordpost'); $_c6eb4ae67d924180789f177a814467ccccab6939 = (bool) ($_930a0745b391fca7316377cbe31f8f0a4441b9d3->getControllerName() . '_' . $_930a0745b391fca7316377cbe31f8f0a4441b9d3->getActionName() == 'account_resetpassword'); $_aa0d150c512db0683d9c50c0c12f71b1d80409a0 = (bool) ($_930a0745b391fca7316377cbe31f8f0a4441b9d3->getControllerName() . '_' . $_930a0745b391fca7316377cbe31f8f0a4441b9d3->getActionName() == 'account_resetpasswordpost'); if ($_c50c3755974ed43c1eb96eb5e083f81b281339d0 || $_1a3023404ab69f5356a5aefcbc28ffa4866f85a0 || $_3a69ee1fffa7b37ae32c13e48dfd5890e9ca68d9 || $_c6eb4ae67d924180789f177a814467ccccab6939 || $_aa0d150c512db0683d9c50c0c12f71b1d80409a0) { $_8c21f819efc249c0efe711aa784aa8a6a6d8a13f = Mage::app()->getWebsite()->getWebsiteId(); foreach ($_39cc59a647aed4446ab8f3ef32b7135f664a845f as $_4e45fa4f3249d9c3cc1314ed89922593008cf117) { $_f9712cf3eb2bf043e1ddede22c150b1170c69142 = Mage::getModel('customer/customer')->load($_4e45fa4f3249d9c3cc1314ed89922593008cf117->getEntityId()); if ($_f9712cf3eb2bf043e1ddede22c150b1170c69142->getWebsiteId() != $_8c21f819efc249c0efe711aa784aa8a6a6d8a13f) { continue; } if ($_4e45fa4f3249d9c3cc1314ed89922593008cf117->getId()) { if ($_4e45fa4f3249d9c3cc1314ed89922593008cf117->getActive()) { return $this->_loginSublogin($_4e45fa4f3249d9c3cc1314ed89922593008cf117, $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c); } else { if ($_3a69ee1fffa7b37ae32c13e48dfd5890e9ca68d9) { $_7661e073459e96b1adbc480bebcb023560a54a58 = Mage::getStoreConfig('sublogin/general/expire_interval'); $_4e45fa4f3249d9c3cc1314ed89922593008cf117->setExpireDate(strtotime(date("Y-m-d", strtotime(date('Y-m-d'))) . " + " . $_7661e073459e96b1adbc480bebcb023560a54a58 . " days")); $_4e45fa4f3249d9c3cc1314ed89922593008cf117->setActive(1); $_4e45fa4f3249d9c3cc1314ed89922593008cf117->save(); return $this->_loginSublogin($_4e45fa4f3249d9c3cc1314ed89922593008cf117, $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c); } else { Mage::helper('sublogin/email')->sendAccountExpiredMail($_4e45fa4f3249d9c3cc1314ed89922593008cf117); Mage::getSingleton('customer/session')->addError(Mage::helper('sublogin')->__("Your account is deactivated. You have received an email to reactivate the account.")); throw new Exception(Mage::helper('sublogin')->__("Your account is deactivated. You have received an email to reactivate the account.")); } } } } } Mage::getSingleton('customer/session')->setSubloginEmail(false); return parent::loadByEmail($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c, $_ff0a3525eb1a63ce44e7951a0b522829a4d2f607, $_f970317d6ba1fcd2cb9e02bbb6f967c922e4e5ca); }
protected function _getDefaultAttributes() { $attributes = parent::_getDefaultAttributes(); array_push($attributes, 'is_active'); return $attributes; }
public function __construct() { parent::__construct(); }