コード例 #1
0
 /**
  * check customer registration and carry on the registration process if it is not completed 
  *
  * Returns True if valid, false otherwise.
  *
  * @param string $email_address
  *
  * @return int
  */
 public function checkRegister($refno, $email, $isChangeEmail)
 {
     (string) ($refno = preg_replace('/X/', '', $refno));
     $customermgr = new Manager_Core_Customer();
     $customer = $customermgr->getCustomerByEmailAddress($email);
     $params = Zend_Registry::get('params');
     $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
     $digest = $mac->generate(array('email' => $email));
     $activationLink = 'refno=' . $refno . '&' . 'email=' . $email . '&' . 'mac=' . $digest;
     $customerMap = new Datasource_Core_CustomerMaps();
     if ($customer) {
         if (!$customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno)) {
             $customermgr->linkLegacyToNew($refno, $customer->getIdentifier(Model_Core_Customer::IDENTIFIER));
         }
         if (!$customer->getEmailValidated()) {
             $mail = new Application_Core_Mail();
             $mail->setTo($email, null);
             $mail->setFrom('*****@*****.**', 'HomeLet');
             $mail->setSubject('My HomeLet account validation');
             $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
             $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
             // Send email
             $mail->send();
             return 1;
         } else {
             return 0;
         }
     } else {
         if ($isChangeEmail) {
             $cMap = $customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
             if ($cMap) {
                 $customer = $customermgr->getCustomer(Model_Core_Customer::IDENTIFIER, $cMap->getIdentifier());
                 $customer->setEmailAddress($email);
                 $customermgr->updateCustomer($customer);
                 $legacyids = $customerMap->getLegacyIDs($customer->getIdentifier());
                 foreach ($legacyids as $legacyid) {
                     if ($legacyid != $refno) {
                         $customer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyid);
                         $customer->setEmailAddress($email);
                         $customermgr->updateCustomer($customer);
                     }
                 }
                 return 0;
             }
         }
         $oldCustomer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
         $mail = new Application_Core_Mail();
         $mail->setTo($email, null);
         $mail->setFrom('*****@*****.**', 'HomeLet');
         $mail->setSubject("Don't forget to register your My HomeLet account");
         $mail->applyTemplate('core/partial-registration', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
         $mail->applyTextTemplate('core/partial-registrationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
         // Send email
         $mail->send();
         return 2;
     }
 }
コード例 #2
0
 public function NotificationHistoryPanel($agentSchemeNumber)
 {
     $params = Zend_Registry::get('params');
     $baseReferencingUrl = $params->connect->baseUrl->referencing;
     // Instantiate security manager for generating MAC
     $securityManager = new Application_Core_Security($params->connect->ref->security->securityString->agent);
     $agentId = $this->view->agentId;
     $macToken = $securityManager->generate(array($agentSchemeNumber, $agentId));
     //	Zend_Debug::dump($this->view->agentId);die();
     $rs = new Datasource_Referencing_NotificationHistory();
     $dataToDisplay = $rs->getHistoryByASN($agentSchemeNumber);
     $enquiry = new Datasource_ReferencingLegacy_Enquiry();
     //Zend_Debug::dump($enquiry);
     $partialArray = array();
     $x = 0;
     foreach ($dataToDisplay as $d) {
         //Zend_Debug::dump($d);
         $refno = $d['refno'];
         $ds = $enquiry->getEnquiry($refno);
         $retrieveReportString = "/reports/view-report-pdf?refno={$refno}&repType=&contentDisposition=attachment";
         $partialArray[$x]['refno'] = $refno;
         $partialArray[$x]['line'] = '';
         $partialArray[$x]['viewReportURL'] = $retrieveReportString;
         $name = trim("{$ds->referenceSubject->name->firstName} {$ds->referenceSubject->name->lastName}");
         if ($name != '') {
             $partialArray[$x]['line'] .= "{$name}, ";
         }
         if (isset($ds->propertyLease->address->addressLine1)) {
             $partialArray[$x]['line'] .= $ds->propertyLease->address->addressLine1 . ', ';
         }
         /*if(isset($ds->propertyLease->address->addressLine2) && $ds->propertyLease->address->addressLine2 != ""){
         			$partialArray[$x]['line'] .= $ds->propertyLease->address->addressLine2 . ', ';
         		}
         		if(isset($ds->propertyLease->address->postCode)){
         			$partialArray[$x]['line'] .= $ds->propertyLease->address->postCode . ', ';
         		}*/
         $partialArray[$x]['line'] = preg_replace('/, $/', ' ', $partialArray[$x]['line']);
         //$partialArray[$x]['line'] .= "<em>(Reference number: {$refno})</em>";
         $x++;
     }
     //Zend_Debug::dump($partialArray);die();
     return array($this->view->partialLoop('partials/notificationhistorypanel.phtml', $partialArray), $x);
 }
コード例 #3
0
 /**
  * Sends a single email to a customer to provide a validation URL for activating a registered My HomeLet account.
  *
  * @param string $subject
  * @param string $heading
  * @param string $template
  * @param string $templateTxt
  * @param string $templateId
  * @return void
  */
 public function sendAccountValidationEmail($subject = self::VALIDATION_SUBJECT, $heading = self::VALIDATION_HEADING, $template = self::VALIDATION_TEMPLATE, $templateTxt = self::VALIDATION_TEMPLATETXT, $templateId = self::VALIDATION_TEMPLATEID)
 {
     $params = Zend_Registry::get('params');
     // Create sign-up completion email
     $mail = new Application_Core_Mail();
     $mail->setTo($this->getEmailAddress(), null);
     $mail->setFrom('*****@*****.**', 'HomeLet');
     $mail->setSubject($subject);
     //  Generate activation link
     $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
     $digest = $mac->generate(array('email' => $this->getEmailAddress()));
     $activationLink = sprintf('email=%s&mac=%s', urlencode($this->getEmailAddress()), $digest);
     // Apply template
     $mail->applyTemplate($template, array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $this->getFirstName(), 'templateId' => $templateId, 'heading' => $heading, 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
     $mail->applyTextTemplate($templateTxt, array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $this->getFirstName(), 'templateId' => $templateId, 'heading' => $heading), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
     // Send email
     $mail->send();
 }
コード例 #4
0
 /**
  * Display a list of quotes that can be retrieved after a user has identified themselves with an auth token via
  * retrieveQuoteAction().  Having this separate action allows an end user to press "Back" for up to an hour if they
  * have chosen to continue the wrong quote.
  *
  * @return void
  */
 public function retrieveMultipleQuotesAction()
 {
     if ($this->getRequest()->getParam('auth') != '') {
         $params = Zend_Registry::get('params');
         $mac = $this->getRequest()->getParam('auth');
         $securityManager = new Application_Core_Security($params->myhomelet->retrieveWithoutAccount->macSecret, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
         $dataKeys = array('customerEmail');
         $securityCheck = $securityManager->authenticate($mac, $dataKeys);
         if (isset($securityCheck['result']) && $securityCheck['result']) {
             // Customer has multiple quotes associated with their email address - look them up and generate a set of
             // auth tokens, show user the selection
             $email = $securityCheck['data']['customerEmail'];
             $policyCoverDatasource = new Datasource_Insurance_LegacyPolicyCovers();
             $customerManager = new Manager_Core_Customer();
             // Get all legacy quote IDs by customer e-mail address
             $legacyIDs = array();
             // Try to look up a customer record's quotes' IDs by the e-mail provided
             $newCustomer = $customerManager->getCustomerByEmailAddress($email);
             if ($newCustomer) {
                 $legacyCustomerMap = new Datasource_Core_CustomerMaps();
                 $legacyIDs = $legacyCustomerMap->getLegacyIDs($newCustomer->getIdentifier(Model_Core_Customer::IDENTIFIER));
             }
             // Also check in the legacy DB only to ensure landlords quotes are found
             $customer = $customerManager->getLegacyCustomerByEmailAddress($email);
             if ($customer) {
                 $legacyCustomerId = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
                 if (!in_array($legacyCustomerId, $legacyIDs)) {
                     $legacyIDs[] = $legacyCustomerId;
                 }
             }
             // Retrieve all quotes for the linked customer reference numbers
             $quoteDatasource = new Datasource_Insurance_LegacyQuotes();
             $quotes = $quoteDatasource->getActiveQuotes($legacyIDs, '', array('policynumber', 'startdate'));
             // Build the list of policy covers and generate auth tokens for each policy
             // Should be done in a manager, but the quote manager has been written with the row data gateway
             // design pattern in mind.
             $authTokens = array();
             foreach ($quotes as $quote) {
                 // Create list of policy covers
                 $policyCoverList = array();
                 $policyOptionsplit = explode('|', $quote->policyOptions);
                 $sumInsuredSplit = explode('|', $quote->amountsCovered);
                 for ($i = 0; $i < count($policyOptionsplit); $i++) {
                     if ($sumInsuredSplit[$i] == 'yes' || floatval($sumInsuredSplit[$i]) > 0) {
                         // A sum insured value has been set so assume cover is in force
                         $policyCover = $policyCoverDatasource->getPolicyCoverByLabel($policyOptionsplit[$i]);
                         if ($policyCover) {
                             array_push($policyCoverList, array('cover' => $policyOptionsplit[$i], 'name' => $policyCover->getName()));
                         }
                     }
                 }
                 $quote->policyCovers = $policyCoverList;
                 // Generate a policy-specific authentication token
                 $securityManager = new Application_Core_Security($params->myhomelet->retrieveWithoutAccount->macSecret, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
                 $securityData = array('quoteNumber' => $quote->policyNumber);
                 $authTokens[$quote->policyNumber] = $securityManager->generate($securityData);
             }
             // Pass quotes and auth tokens into view and finish
             $this->view->quotes = $quotes;
             $this->view->authTokens = $authTokens;
             return;
         }
     }
     // Failover for non-auth or other issue - go to main retrieve quote form
     $this->_helper->redirector->gotoUrl('/my-homelet/retrieve-quote');
 }
コード例 #5
0
 /**
  * Initialise the step 3 form [Important Information Form]
  *
  * @return void
  */
 public function step3Action()
 {
     $pageForm = new TenantsInsuranceQuoteB_Form_Step3();
     // Tell page to use AJAX validation as we go
     $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 3;');
     // Get customer details
     $customerManager = new Manager_Core_Customer();
     $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber);
     // Hydrate registration form
     if (isset($pageForm->subform_register) || isset($pageForm->subform_login)) {
         // Grab a new customer to populate the form
         $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
         $newCust = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $pageSession->CustomerID);
         if (isset($pageForm->subform_register)) {
             if ($newCust) {
                 $pageForm->subform_register->email->setValue($newCust->getEmailAddress());
                 $pageForm->subform_register->security_question->setValue($newCust->getSecurityQuestion());
                 $pageForm->subform_register->security_answer->setValue($newCust->getSecurityAnswer());
                 $emailAddress = $newCust->getEmailAddress();
             } else {
                 $pageForm->subform_register->email->setValue($customer->getEmailAddress());
                 $emailAddress = $customer->getEmailAddress();
             }
             if (!$emailAddress) {
                 $emailAddress = $newCust->getEmailAddress();
             }
         } else {
             if ($newCust) {
                 $pageForm->subform_login->email->setValue($newCust->getEmailAddress());
             }
         }
     }
     if ($this->getRequest()->isPost()) {
         $valid = $this->_formStepCommonValidate($pageForm, 3);
         if (isset($pageForm->subform_register)) {
             $pageForm->subform_register->getElement('email')->setValue($emailAddress);
         }
         if ($valid) {
             $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
             $pageSession->IsNewCustomer = false;
             $data = $pageForm->getValues();
             //Update the WebLead summary and create a STEP3 blob.
             $webLeadManager = new Manager_Core_WebLead();
             $webLeadSummary = $webLeadManager->getSummary($this->_webLeadSummaryId);
             $webLeadSummary->lastUpdatedTime = $this->_offsetDate();
             $webLeadSummary->promotionCode = $data["subform_howhear"]['campaign_code'];
             $webLeadManager->updateSummary($webLeadSummary);
             //Determine if a new STEP3 blob needs to be created, or an existing one retrieved.
             if ($webLeadManager->getBlobExists($this->_webLeadSummaryId, Model_Core_WebLeadStep::STEP3)) {
                 $webLeadBlob = $webLeadManager->getBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3);
             } else {
                 $webLeadBlob = $webLeadManager->createNewBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3);
             }
             //Update the blob and store
             $webLeadBlob->blob = Zend_Json::encode($_POST);
             $webLeadBlob->blobChecksum = crc32($webLeadBlob->blob);
             $webLeadManager->updateBlob($webLeadBlob);
             // Instantiate the quote manager
             $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber);
             // Save new ASN if there is one
             // Create a postcode model
             $postcode = new Manager_Core_Postcode();
             // Get the address as array for Insured and correspondance address
             $insuredAddress = $postcode->getPropertyByID($data['subform_insuredaddress']['ins_address'], false);
             $correspondenceAddress = $postcode->getPropertyByID($data['subform_correspondencedetails']['cor_address'], false);
             // Update the property address in the quote
             $quoteManager->setPropertyAddress(($insuredAddress['organisation'] != '' ? "{$insuredAddress['organisation']}, " : '') . ($insuredAddress['buildingName'] != '' ? "{$insuredAddress['buildingName']}, " : '') . ($insuredAddress['houseNumber'] != '' ? "{$insuredAddress['houseNumber']} " : '') . $insuredAddress['address2'], $insuredAddress['address4'], $insuredAddress['address5'], $insuredAddress['postcode']);
             // Update start and end dates
             $startDate = $data['subform_policydetails']['policy_start'];
             $startDate = substr($startDate, 6, 4) . '-' . substr($startDate, 3, 2) . '-' . substr($startDate, 0, 2);
             $endDate = date('Y-m-d', strtotime(date('Y-m-d', strtotime($startDate)) . ' +1 year -1 day'));
             $quoteManager->setStartAndEndDates($startDate, $endDate);
             //Update the customer in the DataStore and the LegacyDataStore. Use the CustomerManager
             //to do this.
             //$customerManager = new Manager_Core_Customer();
             //First get the existing customer details.
             //$customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber);
             //Now modify the details.
             $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']);
             $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']);
             $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']);
             $customer->setPostCode($correspondenceAddress['postcode']);
             $customer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob));
             //Finally, save the details back to both DataStores.
             $customerManager->updateCustomer($customer);
             $premiums = $quoteManager->calculatePremiums();
             // Save MI information - how did you hear about us
             $marketQuestion = new Manager_Core_ManagementInformation();
             $marketQuestion->saveMarketingAnswers($this->_policyNumber, $this->_customerReferenceNumber, $data["subform_howhear"]["how_hear"]);
             // Perform login/register procedure
             $auth = Zend_Auth::getInstance();
             $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
             if (isset($data['subform_register'])) {
                 // Process registration
                 $params = Zend_Registry::get('params');
                 $newCustomer = $customerManager->getCustomerByEmailAddress($data['subform_register']['email']);
                 if (!$newCustomer) {
                     $newCustomer = $customerManager->createCustomerFromLegacy($data['subform_register']['email'], $this->_customerReferenceNumber);
                 }
                 // Update customer with password and security data
                 $newCustomer->setTitle($customer->getTitle());
                 $newCustomer->setFirstName($customer->getFirstName());
                 $newCustomer->setLastName($customer->getLastName());
                 $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']);
                 $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']);
                 $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']);
                 $newCustomer->setPostCode($correspondenceAddress['postcode']);
                 $newCustomer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob));
                 //                    assuming that the email is already set and so won't require setting again.
                 //                    $newCustomer->setEmailAddress($data['subform_register']['email']);
                 $newCustomer->setSecurityQuestion($data['subform_register']['security_question']);
                 $newCustomer->setSecurityAnswer($data['subform_register']['security_answer']);
                 $newCustomer->setPassword($data['subform_register']['password']);
                 $newCustomer->setAccountLoadComplete(true);
                 $newCustomer->typeID = Model_Core_Customer::CUSTOMER;
                 $customerManager->updateCustomer($newCustomer);
                 // Create sign-up completion email
                 $mail = new Application_Core_Mail();
                 $mail->setTo($data['subform_register']['email'], null);
                 $mail->setFrom('*****@*****.**', 'HomeLet');
                 $mail->setSubject('My HomeLet account validation');
                 //  Generate activation link
                 $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
                 $digest = $mac->generate(array('email' => $data['subform_register']['email']));
                 $activationLink = 'email=' . $data['subform_register']['email'] . '&' . 'mac=' . $digest;
                 // Apply template
                 $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
                 $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
                 // Send email
                 $mail->send();
                 // Everything has been saved ok so navigate to next step
                 $this->_formStepCommonNavigate(3);
             } elseif ($auth->hasIdentity()) {
                 $this->_formStepCommonNavigate(3);
             }
             //return;
         } elseif (isset($_POST['back'])) {
             $this->_formStepCommonNavigate(3);
             return;
         }
     }
     // Load the element data from the database if we can
     if ($this->_formStepCommonPopulate($pageForm, 3)) {
         // Render the page unless we have been redirected
         $this->view->form = $pageForm;
         $this->render('step');
     }
 }
コード例 #6
0
 /**
  * Executes checks when the user is a PLL finalizing an email-link-to-tenant.
  *
  * @param Zend_Controller_Request_Abstract $request
  * @param string $customerToken
  * @param string $refNo
  *
  * @return boolean
  */
 protected function _privateLandlordLinkPreDespatch(Zend_Controller_Request_Abstract $request, $customerToken, $refNo)
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($refNo);
     //Check the validity of the access.
     $params = Zend_Registry::get('params');
     $hashingString = $params->pll->emailLink->security->securityString;
     $leeWay = $params->pll->emailLink->security->securityTokenTimeLeewayUser;
     $securityManager = new Application_Core_Security($hashingString, true, $leeWay);
     $securityCheck = $securityManager->authenticate($customerToken, array('refNo', 'customerId'));
     if ($securityCheck['result']) {
         //Ensure the customer identifier extracted from the $customerToken matches the identifier
         //stored in the reference.
         $customerId = $securityCheck['data']['customerId'];
         if ($customerId != $reference->customer->customerId) {
             $session->security->error = 'Customer identifier does not match';
             return false;
         }
     } else {
         // Something went wrong, eg, hash didn't match or time was out of bounds
         $session->security->error = $securityCheck['error'];
         return false;
     }
     //Log the customer in.
     $customerManager = new Manager_Referencing_Customer();
     $customer = $customerManager->getCustomer($customerId);
     $loginManager = new Manager_Referencing_Login();
     $loginManager->logUserIn($customer->getEmailAddress(), $customer->getPassword());
     //Set the relevant session variables so that the PLL can proceed the reference.
     $session->referenceId = $reference->internalId;
     $session->productName = $reference->productSelection->product->key;
     $session->userType = Model_Referencing_ReferenceUserTypes::PRIVATE_LANDLORD;
     $session->customerToken = $customerToken;
     $session->refNo = $refNo;
     return true;
 }
コード例 #7
0
 /**
  * Resume an existing quote for customers who either have a temporary auth token for a retrieval with no My HomeLet
  * account, or who are My HomeLet authenticated.  Customers with no form of valid authentication are redirected to
  * the My HomeLet login page.
  *
  * @return void
  */
 public function retrieveAction()
 {
     // Authorisation using no-account My HomeLet retrieval auth token
     if ($this->getRequest()->getParam('auth') != '') {
         $mac = $this->getRequest()->getParam('auth');
         $securityManager = new Application_Core_Security($this->_params->myhomelet->retrieveWithoutAccount->macSecret, $this->_params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $this->_params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
         $dataKeys = array('quoteNumber');
         $securityCheck = $securityManager->authenticate($mac, $dataKeys);
         if (isset($securityCheck['result']) && $securityCheck['result']) {
             $quoteNumber = $securityCheck['data']['quoteNumber'];
             $quoteManager = new Manager_Insurance_LegacyQuote();
             $customerManager = new Manager_Core_Customer();
             $quote = $quoteManager->getQuoteByPolicyNumber($quoteNumber);
             $quoteRefNo = $quote->refNo;
             $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $quoteRefNo);
             $customerID = $referenceNumber = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $quoteRefNo);
             $quoteManager = new Manager_Insurance_LandlordsPlus_Quote(null, $quoteNumber, null, $customerID);
             $quote = $quoteManager->getModel();
             $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
             $pageSession->quoteID = $quote->ID;
             $pageSession->customerRefNo = $referenceNumber;
             //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
             //details captured, such as the campaign code.
             $webLeadManager = new Manager_Core_WebLead();
             $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($quoteNumber);
             $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step1');
             return;
         }
     }
     // Authorisation using My HomeLet logged in details
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     if ($auth->hasIdentity()) {
         // Check to see if we have a reference number to load up
         if ($this->getRequest()->getParam('quote') != '') {
             $quoteNumber = $this->getRequest()->getParam('quote');
             // Customer is logged in and is trying to retrieve a specific quote
             // We need to check to make sure they own it
             $customerID = $auth->getStorage()->read()->id;
             // Now we need to get their legacy ID
             $customerManager = new Manager_Core_Customer();
             $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerID);
             $referenceNumber = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
             // Need to find the quote ID by the policy number
             $quotes = new Manager_Insurance_LandlordsPlus_Quote(null, $quoteNumber, null, $customerID);
             $quote = $quotes->getModel();
             $legacyCustomerMap = new Datasource_Core_CustomerMaps();
             $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerID);
             if (in_array($quote->legacyCustomerID, $legacyIDs)) {
                 // This customer does own this reference - so set the page session stuff up and redirect
                 $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
                 $pageSession->quoteID = $quote->ID;
                 $pageSession->customerRefNo = $referenceNumber;
                 //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
                 //details captured, such as the campaign code.
                 $webLeadManager = new Manager_Core_WebLead();
                 $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($quoteNumber);
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step1');
             }
         }
     }
     $this->_helper->redirector->gotoUrl('/login?referrerUrl=/my-homelet/quotes');
 }
コード例 #8
0
 public function resendEmailAction()
 {
     // Pop-up results need pop-up layout
     $this->_helper->layout->setLayout('popup');
     // Get refno from GET var, look up applicant details
     $refno = isset($_GET['refno']) ? $_GET['refno'] : '';
     $refMuntManager = new Manager_ReferencingLegacy_Munt();
     $reference = $refMuntManager->getReference($refno);
     $applicantTypes = array_flip(Model_Referencing_ReferenceSubjectTypes::iterableKeys());
     $applicantType = ucwords(strtolower($applicantTypes[$reference->referenceSubject->type]));
     $applicantType = $applicantType == 'Tenant' ? 'Applicant' : $applicantType;
     // Intantiate form definition
     $pageForm = new Connect_Form_ReferencingResendEmail();
     // Validate form if POSTed
     $request = $this->getRequest();
     if ($request->isPost() && !is_null($request->getParam('fromForm')) && $request->getParam('fromForm') == '1') {
         $postData = $request->getPost();
         if ($pageForm->isValid($postData)) {
             // Instantiate security manager for generating MAC
             $securityManager = new Application_Core_Security($this->_params->connect->ref->security->securityString->user);
             $macToken = $securityManager->generate(array($this->_agentSchemeNumber, $this->_agentId));
             // cURL original page in old ref system, bleurgh
             $baseReferencingUrl = $this->_params->connect->baseUrl->referencing;
             $to = $pageForm->getElement('email')->getValue();
             $url = "{$baseReferencingUrl}frontEnd/emailtenantlink.php?refno={$refno}&tempemail={$to}&brand=default&agentToken={$macToken}";
             // TODO: Use Zend_Http_Client and Zend_Http_Client_Adapter_Curl
             $ch = curl_init($url);
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
             curl_setopt($ch, CURLOPT_AUTOREFERER, true);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
             curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
             curl_setopt($ch, CURLOPT_AUTOREFERER, true);
             curl_setopt($ch, CURLOPT_TIMEOUT, 60);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_exec($ch);
             $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             if ($status != 200) {
                 // Show user there was a problem
                 $this->view->error = "({$status}): " . curl_error($ch);
                 $this->_helper->viewRenderer('resend-email-failed');
             } else {
                 curl_close($ch);
                 // TODO: Check for error being returned
                 if (false) {
                     // Show user there was a fatal problem
                     $this->_helper->viewRenderer('resend-email-failed');
                 } else {
                     //Update e-mail address.
                     if ($pageForm->getElement('replace')->getValue() == '1') {
                         //Get the legacy Tenant ID, then use that to identify the
                         //Tenant record to update in the legacy Tenant table.
                         $legacyEnquiryDatasource = new Datasource_ReferencingLegacy_Enquiry();
                         $legacyTenantId = $legacyEnquiryDatasource->getTenantId($reference->externalId);
                         $rsds = new Datasource_ReferencingLegacy_ReferenceSubject();
                         $rsds->updateField($legacyTenantId, Datasource_ReferencingLegacy_ReferenceSubject::FIELD_EMAIL, $to);
                     }
                     // Show user all was successful
                     $this->_helper->viewRenderer('resend-email-confirmation');
                 }
             }
         } else {
             // Show errors back to user
             $allErrors = $pageForm->getMessages();
             foreach ($allErrors as $field => $errors) {
                 foreach ($errors as $errorType => $errorMessage) {
                     $this->_helper->flashmessages->addMessage($errorMessage);
                 }
             }
         }
     } else {
         // Pre-fill in refno, e-mail address and replacement checkbox
         $pageForm->getElement('email')->setValue($reference->referenceSubject->contactDetails->email1);
         $pageForm->getElement('replace')->setValue(1);
     }
     $this->view->refno = $refno;
     $this->view->applicantName = "{$reference->referenceSubject->name->title} {$reference->referenceSubject->name->firstName} {$reference->referenceSubject->name->lastName}";
     $this->view->applicantType = $applicantType;
     $this->view->form = $pageForm;
     $this->view->flashMessages = $this->_helper->flashmessages->getCurrentMessages();
 }
コード例 #9
0
 /**
  * Resume an existing quote for customers who either have a temporary auth token for a retrieval with no My HomeLet
  * account, or who are My HomeLet authenticated.  Customers with no form of valid authentication are redirected to
  * the My HomeLet login page.
  *
  * @return void
  */
 public function retrieveAction()
 {
     // Authorisation using no-account My HomeLet retrieval auth token
     if ($this->getRequest()->getParam('auth') != '') {
         $mac = $this->getRequest()->getParam('auth');
         $securityManager = new Application_Core_Security($this->_params->myhomelet->retrieveWithoutAccount->macSecret, $this->_params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $this->_params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
         $dataKeys = array('quoteNumber');
         $securityCheck = $securityManager->authenticate($mac, $dataKeys);
         if (isset($securityCheck['result']) && $securityCheck['result']) {
             $quoteNumber = $securityCheck['data']['quoteNumber'];
             $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $quoteNumber);
             $quote = $quoteManager->getQuoteObject();
             if ($quote->policyType == 'T') {
                 // Make sure this is a tenants quote
                 $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
                 $pageSession->CustomerRefNo = $quote->refNo;
                 $pageSession->PolicyNumber = $quote->policyNumber;
                 // Note that this user retrieved a quote, so that if they login in using the login action their
                 // details don't get nulled out.
                 $pageSession->RetrievedQuote = true;
                 //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
                 //details captured, such as the campaign code.
                 $webLeadManager = new Manager_Core_WebLead();
                 $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($pageSession->PolicyNumber);
                 $this->_helper->redirector->gotoUrl('/tenants/insurance-quote/step1');
                 return;
             } else {
                 // This isn't a tenants quote! OOPS
                 $this->render('retrieve-failed');
                 return;
             }
         }
     }
     // Authorisation using My HomeLet logged in details
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     if ($auth->hasIdentity()) {
         // Check to see if we have a reference number to load up
         if ($this->getRequest()->getParam('quote') != '') {
             $quoteNumber = $this->getRequest()->getParam('quote');
             // Customer is logged in and is trying to retrieve a specific quote
             // We need to check to make sure they own it
             $customerID = $auth->getStorage()->read()->id;
             // Get customers legacy IDs and confirm the refno of the quote
             // can be accessed by the customer.
             $legacyCustomerMap = new Datasource_Core_CustomerMaps();
             $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerID);
             $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $quoteNumber);
             $quote = $quoteManager->getQuoteObject();
             if (in_array($quote->refNo, $legacyIDs)) {
                 // This customer does own this reference - so set the page session stuff up and redirect
                 if ($quote->policyType == 'T') {
                     // Make sure this is a tenants quote
                     $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
                     $pageSession->CustomerRefNo = $quote->refNo;
                     $pageSession->PolicyNumber = $quote->policyNumber;
                     //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
                     //details captured, such as the campaign code.
                     $webLeadManager = new Manager_Core_WebLead();
                     $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($pageSession->PolicyNumber);
                     $this->_helper->redirector->gotoUrl('/tenants/insurance-quote/step1');
                 } else {
                     // This isn't a tenants quote! OOPS
                     $this->render('retrieve-failed');
                     return;
                 }
             }
         }
     }
     $this->_helper->redirector->gotoUrl('/login?referrerUrl=/my-homelet/quotes');
 }