/**
  * Creates a new customer in the LegacyDataStore and returns an object representation of this.
  * 
  * @param string $emailAddress The customer's email address. No validation checking is performed on this,
  *          other than to check for a non-empty string.
  * @return Model_Core_Customer Returns a Customer object encapsulating the customer details.
  * @throws Zend_Exception Throws a Zend_Exception if parameters are missing.
  */
 public function createNewCustomer($emailAddress)
 {
     // Validate the data passed in.
     if (empty($emailAddress)) {
         throw new Zend_Exception('Required parameters missing');
     }
     // Save the customer into the LegacyDataStore.
     $passwordUtil = new Application_Core_Password();
     $password = $passwordUtil->generate();
     $identifier = $this->_customerModel->insertCustomer($emailAddress, $password, Model_Core_Customer::CUSTOMER);
     // Encapsulate the customer details in a Model_Core_Customer object and return
     $customer = new Model_Core_Customer();
     $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier);
     $customer->setEmailAddress($emailAddress);
     $customer->setPassword($password);
     return $customer;
 }
 /**
  * Resets the customer's password
  *
  * @return void
  */
 public function resetpassword()
 {
     $this->_password = Application_Core_Password::generate();
     $params = Zend_Registry::get('params');
     // Email the customer with the new password
     $metaData = array('name' => $this->getFirstName(), 'email' => $this->getEmailAddress(), 'password' => $this->_password, 'homeletWebsite' => $params->homelet->domain, 'templateId' => 'HL2485 12-12', 'heading' => 'We’ve reset your password for you', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl);
     $emailer = new Application_Core_Mail();
     $emailer->setTo($this->getEmailAddress(), $this->getFirstName() . ' ' . $this->getLastName())->setSubject('HomeLet - Your Password')->applyTemplate('core_resetpassword', $metaData, false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
     $emailer->send();
 }
 public function createCustomerFromLegacy($emailAddress, $legacyIdentifier)
 {
     //Validate the data passed in.
     if (empty($emailAddress) || empty($legacyIdentifier)) {
         throw new Zend_Exception('Required parameters missing');
     }
     //Save the customer into the DataStore and LegacyDataStore. To do this
     //first obtain the email address, password, customer type (tenant, landlord,
     //agent) and an unused legacy identifier (customerRefno).
     $passwordUtil = new Application_Core_Password();
     $password = $passwordUtil->generate();
     //And create:
     $identifier = $this->_customerModel->insertCustomer($emailAddress, $password, Model_Core_Customer::CUSTOMER);
     //Next link the LegacyDataStore and the DataStore.
     $customerMap = new Datasource_Core_CustomerMaps();
     $customerMap->insertMap($legacyIdentifier, $identifier);
     //Finally, encapsulate the customer details in a Model_Insurance_Common_Customer_DomainObjects_Customer
     //object and return.
     $customer = new Model_Core_Customer();
     $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier);
     $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyIdentifier);
     $customer->setEmailAddress($emailAddress);
     $customer->setPassword($password);
     return $customer;
 }