/**
  * sendCustomerNotification() method send an-mail when the account is created
  *
  * @param int $iCountryId
  * @return bool
  */
 protected static function sendCustomerNotification($iIsoLang, $sEmail, $sPassword, $sFirstName, $sLastName)
 {
     // set params
     if (!empty($iIsoLang) && !empty($sEmail) && !empty($sPassword) && !empty($sFirstName) && !empty($sLastName)) {
         require_once _FPC_PATH_LIB . 'mail-send_class.php';
         $aParams = array();
         $aParams['isoId'] = $iIsoLang;
         $aParams['email'] = $sEmail;
         $aParams['password'] = $sPassword;
         $aParams['firstname'] = $sFirstName;
         $aParams['lastname'] = $sLastName;
         BT_FpcMailSend::create()->run('customerAccountNotification', $aParams);
     }
 }
 /**
  * _updateEmail() method update customer email
  *
  * @param array $aParams
  * @return bool
  */
 private function _updateEmail(array $aParams)
 {
     $aAssign = array();
     if (version_compare(_PS_VERSION_, '1.4', '>')) {
         $oLink = new Link();
         $sLink = $oLink->getPageLink('my-account.php');
         unset($oLink);
     } else {
         global $smarty;
         $sLink = $smarty->_tpl_vars['base_dir_ssl'] . 'my-account.php';
     }
     $aAssign['sLink'] = $sLink;
     // get serialized connector data
     BT_FPCModuleTools::getConnectorData();
     // check if customer is the same customer connected and if the e-mail is valid
     if (!empty($aParams['connector']) && !empty($GLOBALS[_FPC_MODULE_NAME . '_CONNECTORS'][$aParams['connector']]['data']['activeConnector']) && !empty($aParams['customerId']) && $aParams['customerId'] === md5(_FPC_MODULE_NAME . $aParams['connector'] . FacebookPsConnect::$oCookie->id_customer) && !empty($aParams['customerId']) && filter_var($aParams['socialEmail'], FILTER_VALIDATE_EMAIL) !== false) {
         // include
         require_once _FPC_PATH_LIB . 'module-dao_class.php';
         require_once _FPC_PATH_LIB . 'mail-send_class.php';
         // check if exists and return id customer if exists
         $iCustomerId = BT_FPCModuleDao::existCustomerEmail($aParams['socialEmail']);
         // if customer not exists
         if (empty($iCustomerId)) {
             if (BT_FPCModuleDao::updateCustomerEmail(FacebookPsConnect::$oCookie->id_customer, $aParams['socialEmail'])) {
                 $aAssign['sMsg'] = FacebookPsConnect::$oModule->l('Your information has been updated', 'hook-action_class');
                 // set the new e-mail in cookie
                 if (version_compare(_PS_VERSION_, '1.5', '>')) {
                     Context::getContext()->cookie->email = $aParams['socialEmail'];
                 } else {
                     global $cookie;
                     $cookie->email = $aParams['socialEmail'];
                 }
             } else {
                 $aAssign['aErrors'][] = array('msg' => FacebookPsConnect::$oModule->l('Internal server error. The customer e-mail has not been updated. Please try again by clicking on reload button below', 'hook-action_class') . '.', 'code' => 590);
             }
             // manage the update firstname and name for twitter connexion
             BT_FPCModuleDao::updateCustomerFirstName(FacebookPsConnect::$oCookie->id_customer, $aParams['socialFirstName']);
             BT_FPCModuleDao::updateCustomerName(FacebookPsConnect::$oCookie->id_customer, $aParams['socialName']);
             BT_FPCModuleDao::updateCustomerPassword(FacebookPsConnect::$oCookie->id_customer, $aParams['socialPassword']);
             BT_FpcMailSend::_updateEmailTwitter($aParams['socialFirstName'], $aParams['socialName'], $aParams['socialEmail'], $aParams['socialPassword'], FacebookPsConnect::$iCurrentLang, FacebookPsConnect::$iShopId);
         } else {
             $aAssign['aErrors'][] = array('msg' => FacebookPsConnect::$oModule->l('This e-mail address is already taken by a customer account or you already have linked this e-mail address with another network. Please try again by clicking on reload button below', 'hook-action_class') . '.', 'code' => 591);
         }
     } else {
         $aAssign['aErrors'][] = array('msg' => FacebookPsConnect::$oModule->l('Internal server error. The customer could not be identified. You may be a victim of cross-site request forgery', 'hook-action_class') . '.', 'code' => 592);
     }
     if (empty($aAssign['aErrors'])) {
         $sTpl = _FPC_TPL_CONFIRM;
     } else {
         $sTpl = _FPC_TPL_ERROR;
     }
     return array('tpl' => $sTpl, 'assign' => $aAssign);
 }