public function postProcess()
 {
     parent::postProcess();
     // Déconnexion
     if (Tools::getIsset('logout')) {
         Auth::disconnect();
         Flash::add('Vous êtes bien déconnécté');
         Tools::redirect($this->context->link->getPageLink('auth'));
     } elseif (Tools::isSubmit('submitLogin')) {
         $user = (new User())->getByEmail(Tools::getValue('username'), Tools::getValue('password'));
         if (!Validate::isLoadedObject($user)) {
             $this->errors[] = 'Identifiant ou mot de passe incorrect';
         } else {
             Auth::setUser($user);
             Tools::redirect($this->context->link->getPageLink('comments'));
         }
     } elseif (Tools::isSubmit('submitSubscribe')) {
         /**
          * - Vérification des champs
          * - Verification non-existant
          * - Inscription
          * - Login
          */
         if (!Validate::isEmail($email = Tools::getValue('username'))) {
             return $this->errors[] = 'Veuillez saisir une adresse e-mail correcte';
         }
         if (!Validate::isPasswd($password = Tools::getValue('password'))) {
             /// @todo être plus spécifique sur les règles de mot de passes valides
             return $this->errors[] = 'Veuillez saisir un mot de passe correct';
         }
         $user = new User();
         if (Validate::isLoadedObject($user->getByEmail($email))) {
             $this->errors[] = 'Un compte avec cet identifiant existe déjà';
         } else {
             $user->login = $email;
             $user->password = Tools::encrypt($password);
             if (!$user->save()) {
                 $this->errors[] = 'Impossible de vous enregistrer, veuillez réessayer ultérieurement (' . Db::getInstance()->getMsgError() . ')';
             } else {
                 Auth::setUser($user);
                 Flash::success('Bienvenue! Votre compte a bien été créé');
                 Tools::redirect($this->context->link->getPageLink('comments'));
             }
         }
     } elseif (Auth::getUser()) {
         Tools::redirect($this->context->link->getPageLink('comments'));
     }
 }
Example #2
0
 public function getContent()
 {
     $this->_html = '<h2>Paypal</h2>';
     if (isset($_POST['submitPaypal'])) {
         if (empty($_POST['business'])) {
             $this->_postErrors[] = $this->l('Paypal business e-mail address is required.');
         } elseif (!Validate::isEmail($_POST['business'])) {
             $this->_postErrors[] = $this->l('Paypal business must be an e-mail address.');
         }
         if (!isset($_POST['sandbox'])) {
             $_POST['sandbox'] = 1;
         }
         if (!sizeof($this->_postErrors)) {
             Configuration::updateValue('PAYPAL_BUSINESS', strval($_POST['business']));
             Configuration::updateValue('PAYPAL_SANDBOX', intval($_POST['sandbox']));
             Configuration::updateValue('PAYPAL_HEADER', strval($_POST['header']));
             $this->displayConf();
         } else {
             $this->displayErrors();
         }
     }
     $this->displayPayPal();
     $this->displayFormSettings();
     return $this->_html;
 }
 public function processProductTabContent()
 {
     if (Tools::isSubmit('mymod_pc_submit_comment')) {
         $id_product = Tools::getValue('id_product');
         $firstname = Tools::getValue('firstname');
         $lastname = Tools::getValue('lastname');
         $email = Tools::getValue('email');
         $grade = Tools::getValue('grade');
         $comment = Tools::getValue('comment');
         if (!Validate::isName($firstname) || !Validate::isName($lastname) || !Validate::isEmail($email)) {
             $this->context->smarty->assign('new_comment_posted', 'error');
             return false;
         }
         $MyModComment = new MyModComment();
         $MyModComment->id_shop = (int) $this->context->shop->id;
         $MyModComment->id_product = (int) $id_product;
         $MyModComment->firstname = $firstname;
         $MyModComment->lastname = $lastname;
         $MyModComment->email = $email;
         $MyModComment->grade = (int) $grade;
         $MyModComment->comment = nl2br($comment);
         $MyModComment->add();
         $this->context->smarty->assign('new_comment_posted', 'success');
         $this->module->smartyClearCache('displayProductTabContent.tpl', $this->cache_id);
     }
 }
Example #4
0
 public function getContent()
 {
     $output = null;
     if (Tools::isSubmit('submit' . $this->name)) {
         $list_value = strval(Tools::getValue('PROFIT_MARGIN'));
         if (!$list_value || empty($list_value) || !Validate::isFloat($list_value)) {
             $output .= $this->displayError($this->l('Invalid Configuration value'));
         } else {
             $email_value = strval(Tools::getValue('ORDER_CNF_MANAGER_EMAIL'));
             if (Tools::getValue('ADMIN_CONFIRM_ORDER') == '1' && (empty($email_value) || !Validate::isEmail($email_value))) {
                 $output .= $this->displayError($this->l('Please enter valid Email ID'));
             } else {
                 $email_value = strval(Tools::getValue('PRODUCT_REQUEST_EMAIL'));
                 if (empty($email_value) || !Validate::isEmail($email_value)) {
                     $output .= $this->displayError($this->l('Please enter valid Email ID'));
                 } else {
                     Configuration::updateValue('PROFIT_MARGIN', $list_value);
                     Configuration::updateValue('PRODUCT_DYNAMIC_PRICE', Tools::getValue('PRODUCT_DYNAMIC_PRICE'));
                     Configuration::updateValue('ORDER_CNF_MANAGER_EMAIL', Tools::getValue('ORDER_CNF_MANAGER_EMAIL'));
                     Configuration::updateValue('ADMIN_CONFIRM_ORDER', Tools::getValue('ADMIN_CONFIRM_ORDER'));
                     Configuration::updateValue('PRODUCT_REQUEST_EMAIL', Tools::getValue('PRODUCT_REQUEST_EMAIL'));
                     Configuration::updateValue('PRODUCT_REQUEST_SAMPLE', Tools::getValue('PRODUCT_REQUEST_SAMPLE'));
                     Configuration::updateValue('PRODUCT_DOWNLOAD_BUTTON', Tools::getValue('PRODUCT_DOWNLOAD_BUTTON'));
                     $output .= $this->displayConfirmation($this->l('Settings updated'));
                 }
             }
         }
     }
     $this->context->controller->addJS($this->_path . 'websitesettings.js');
     //return $this->display(__FILE__,'productupdate.tpl');
     return $output . $this->displayForm();
 }
Example #5
0
function verify_main_config($data)
{
    if (empty($data['server_name']) or empty($data['admin_firstname']) or empty($data['admin_lastname']) or empty($data['admin_email']) or empty($data['admin_pass']) or empty($data['admin_pass2'])) {
        global $errormessage;
        $errormessage = 'Some fields are missing. Please fill all required fields.';
        global $editdata;
        $editdata = $data;
        return false;
    }
    if ($data['admin_pass'] != $data['admin_pass2']) {
        global $errormessage;
        $errormessage = 'The passwords you entered to not match.';
        global $editdata;
        $editdata = $data;
        return false;
    }
    require_once MAD_PATH . '/modules/validation/validate.class.php';
    $validate = new Validate();
    if ($validate->isEmail($data['admin_email']) != true) {
        global $errormessage;
        $errormessage = 'Please enter a valid e-mail address.';
        global $editdata;
        $editdata = $data;
        return false;
    }
    return true;
}
Example #6
0
 protected function sendRenewPasswordLink()
 {
     if (!($email = trim(Tools::getValue('email'))) || !Validate::isEmail($email)) {
         $this->errors[] = $this->trans('Invalid email address.', array(), 'Shop.Notifications.Error');
     } else {
         $customer = new Customer();
         $customer->getByEmail($email);
         if (!Validate::isLoadedObject($customer)) {
             $this->success[] = $this->trans('If this email address has been registered in our shop, you will receive a link to reset your password at %email%.', array('%email%', $customer->email), 'Shop.Notifications.Success');
             $this->setTemplate('customer/password-infos');
         } elseif (!$customer->active) {
             $this->errors[] = $this->trans('You cannot regenerate the password for this account.', array(), 'Shop.Notifications.Error');
         } elseif (strtotime($customer->last_passwd_gen . '+' . ($minTime = (int) Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
             $this->errors[] = $this->trans('You can regenerate your password only every %d minute(s)', array((int) $minTime), 'Shop.Notifications.Error');
         } else {
             if (!$customer->hasRecentResetPasswordToken()) {
                 $customer->stampResetPasswordToken();
                 $customer->update();
             }
             $mailParams = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id . '&reset_token=' . $customer->reset_password_token));
             if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mailParams, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                 $this->success[] = $this->trans('If this email address has been registered in our shop, you will receive a link to reset your password at %email%.', array('%email%', $customer->email), 'Shop.Notifications.Success');
                 $this->setTemplate('customer/password-infos');
             } else {
                 $this->errors[] = $this->trans('An error occurred while sending the email.', array(), 'Shop.Notifications.Error');
             }
         }
     }
 }
 public function init()
 {
     parent::init();
     /*
      * Piqué dans le AuthController. J'aurais bien aimé utiliser le AuthController, mais le premier contrôle dans son init()
      * c'est pour vérifier si l'utilisateur est loggé ou non, ce qui mettait à plat ma stratégie.
      *
      * Je me suis posé la question 'Faut il que ca marche pour des admin ?', j'ai supposé que non,
      * mais s'il avait fallu, il suffisait de tester un 'Employee' en plus d'un 'Customer'
      */
     $passwd = trim(Tools::getValue('passwd'));
     $_POST['passwd'] = null;
     $email = trim(Tools::getValue('email'));
     if (!empty($email) && Validate::isEmail($email) && !empty($passwd) && Validate::isPasswd($passwd)) {
         $customer = new Customer();
         $authentication = $customer->getByEmail(trim($email), trim($passwd));
         if (isset($authentication->active) && $authentication->active && $customer->id) {
             Tools::redirect(Configuration::get("ADMIN_TAB_MODULE_URLBACK"));
         }
     }
     /*
      * Ici, je ne suis vraiment pas satisfait de la méthode employée, je trouve ça plutôt crade
      * de transmettre des infos sur les erreurs via un param en GET, mais dans l'immédiat je n'ai pas trouvé mieux
      */
     Tools::redirect("index.php?urlback_haserror=1");
 }
Example #8
0
    private function getSellerByEmail($email, $passwd)
    {
        if (!Validate::isEmail($email) or $passwd != NULL and !Validate::isPasswd($passwd)) {
            die(Tools::displayError());
        }
        $sql = '
			SELECT * 
			FROM `' . _DB_PREFIX_ . 'employee`
			WHERE `active` = 1
			AND `email` = \'' . pSQL($email) . '\'
			' . ($passwd ? 'AND `passwd` = \'' . $passwd . '\'' : '');
        $result = Db::getInstance()->getRow($sql);
        if (!$result) {
            return false;
        }
        $emp = new Employee();
        $emp->id = $result['id_employee'];
        $emp->id_profile = $result['id_profile'];
        foreach ($result as $key => $value) {
            if (key_exists($key, $emp)) {
                $emp->{$key} = $value;
            }
        }
        return $emp;
    }
Example #9
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_STORE_DISPLAY_FOOTER':
         case 'PS_STORE_DISPLAY_SITEMAP':
         case 'PS_STORE_SIMPLIFIED':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_STORES_CENTER_LAT':
         case 'PS_STORES_CENTER_LONG':
             $validValue = Validate::isCoordinate($value);
             break;
         case 'PS_SHOP_NAME':
             $validValue = Validate::isName($value);
             break;
         case 'PS_SHOP_EMAIL':
             $validValue = Validate::isEmail($value);
             break;
         case 'PS_SHOP_DETAILS':
             $validValue = Validate::isString($value);
             break;
         case 'PS_SHOP_ADDR1':
         case 'PS_SHOP_ADDR2':
             $validValue = Validate::isAddress($value);
             break;
         case 'PS_SHOP_CODE':
             $validValue = Validate::isPostCode($value);
             break;
         case 'PS_SHOP_CITY':
             $validValue = Validate::isCityName($value);
             break;
         case 'PS_SHOP_COUNTRY_ID':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Country((int) $value);
                 $validValue = Validate::isLoadedObject($obj);
             }
             break;
         case 'PS_SHOP_STATE_ID':
             $validValue = Validate::isUnsignedId($value);
             break;
         case 'PS_SHOP_PHONE':
         case 'PS_SHOP_FAX':
             $validValue = Validate::isPhoneNumber($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("value '{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated '{$key}' configuration");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
 /**
  * Start forms process
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     if (Tools::isSubmit('email')) {
         if (!($email = Tools::getValue('email')) || !Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } else {
             $customer = new Customer();
             $customer->getByemail($email);
             if (!Validate::isLoadedObject($customer)) {
                 $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
             } elseif (!$customer->active) {
                 $this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
             } elseif (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                 $this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int) $min_time);
             } else {
                 $mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id));
                 if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                     $this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
                 } else {
                     $this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
                 }
             }
         }
     } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
         $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer);
         if ($email) {
             $customer = new Customer();
             $customer->getByemail($email);
             if (!Validate::isLoadedObject($customer)) {
                 $this->errors[] = Tools::displayError('Customer account not found');
             } elseif (!$customer->active) {
                 $this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
             } elseif (strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) {
                 Tools::redirect('index.php?controller=authentication&error_regen_pwd');
             } else {
                 $customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH));
                 $customer->last_passwd_gen = date('Y-m-d H:i:s', time());
                 if ($customer->update()) {
                     Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
                     $mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password);
                     if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                         $this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
                     } else {
                         $this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
                     }
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
                 }
             }
         } else {
             $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
         }
     } elseif (Tools::getValue('token') || Tools::getValue('id_customer')) {
         $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
     }
 }
 /**
  * Start forms process
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     if (Tools::isSubmit('submitGuestTracking') || Tools::isSubmit('submitTransformGuestToCustomer')) {
         // These lines are here for retrocompatibility with old theme
         $id_order = Tools::getValue('id_order');
         $order_collection = array();
         if ($id_order) {
             if (is_numeric($id_order)) {
                 $order = new Order((int) $id_order);
                 if (Validate::isLoadedObject($order)) {
                     $order_collection = Order::getByReference($order->reference);
                 }
             } else {
                 $order_collection = Order::getByReference($id_order);
             }
         }
         // Get order reference, ignore package reference (after the #, on the order reference)
         $order_reference = current(explode('#', Tools::getValue('order_reference')));
         // Ignore $result_number
         if (!empty($order_reference)) {
             $order_collection = Order::getByReference($order_reference);
         }
         $email = Tools::getValue('email');
         if (empty($order_reference) && empty($id_order)) {
             $this->errors[] = Tools::displayError('Please provide your order\'s reference number.');
         } elseif (empty($email)) {
             $this->errors[] = Tools::displayError('Please provide a valid email address.');
         } elseif (!Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Please provide a valid email address.');
         } elseif (!Customer::customerExists($email, false, false)) {
             $this->errors[] = Tools::displayError('There is no account associated with this email address.');
         } elseif (Customer::customerExists($email, false, true)) {
             $this->errors[] = Tools::displayError('This page is for guest accounts only. Since your guest account has already been transformed into a customer account, you can no longer view your order here. Please log in to your customer account to view this order');
             $this->context->smarty->assign('show_login_link', true);
         } elseif (!count($order_collection)) {
             $this->errors[] = Tools::displayError('Invalid order reference');
         } elseif (!$order_collection->getFirst()->isAssociatedAtGuest($email)) {
             $this->errors[] = Tools::displayError('Invalid order reference');
         } else {
             $this->assignOrderTracking($order_collection);
             if (Tools::isSubmit('submitTransformGuestToCustomer')) {
                 $customer = new Customer((int) $order->id_customer);
                 if (!Validate::isLoadedObject($customer)) {
                     $this->errors[] = Tools::displayError('Invalid customer');
                 } elseif (!Tools::getValue('password')) {
                     $this->errors[] = Tools::displayError('Invalid password.');
                 } elseif (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) {
                     // @todo clarify error message
                     $this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.');
                 } else {
                     $this->context->smarty->assign('transformSuccess', true);
                 }
             }
         }
     }
 }
 public function processLogin()
 {
     require_once dirname(__FILE__) . '../../../../modules/designer/designer.php';
     $themeName = trim(Tools::getValue('theme_name'));
     $passwd = trim(Tools::getValue('passwd'));
     $email = trim(Tools::getValue('email'));
     $domain = getSessionDomain($themeName);
     $version = function_exists('theme_get_manifest_version') ? '&ver=' . theme_get_manifest_version($themeName) : '';
     $desktop = function_exists('getDesktopParams') ? getDesktopParams() : '';
     if (empty($email)) {
         $this->errors[] = Tools::displayError('E-mail is empty');
     } elseif (!Validate::isEmail($email)) {
         $this->errors[] = Tools::displayError('Invalid e-mail address');
     }
     if (empty($passwd)) {
         $this->errors[] = Tools::displayError('Password is blank');
     } elseif (!Validate::isPasswd($passwd)) {
         $this->errors[] = Tools::displayError('Invalid password');
     }
     if (!count($this->errors)) {
         $this->context->employee = new Employee();
         $is_employee_loaded = $this->context->employee->getByemail($email, $passwd);
         $employee_associated_shop = $this->context->employee->getAssociatedShops();
         if (!$is_employee_loaded) {
             $this->errors[] = Tools::displayError('Employee does not exist or password is incorrect.');
             $this->context->employee->logout();
         } elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) {
             $this->errors[] = Tools::displayError('Employee does not manage any shop anymore (shop has been deleted or permissions have been removed).');
             $this->context->employee->logout();
         } else {
             $this->context->employee->remote_addr = ip2long(Tools::getRemoteAddr());
             $cookie = Context::getContext()->cookie;
             $cookie->id_employee = $this->context->employee->id;
             $cookie->email = $this->context->employee->email;
             $cookie->profile = $this->context->employee->id_profile;
             $cookie->passwd = $this->context->employee->passwd;
             $cookie->remote_addr = $this->context->employee->remote_addr;
             $cookie->write();
             if (Tools::getIsset('theme_name')) {
                 $url = $this->context->link->getAdminLink('AdminAjax') . '&ajax=1' . $domain . $version . $desktop;
             } else {
                 $tab = new Tab((int) $this->context->employee->default_tab);
                 $url = $this->context->link->getAdminLink($tab->class_name);
             }
             if (Tools::isSubmit('ajax')) {
                 die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $url)));
             } else {
                 $this->redirect_after = $url;
             }
         }
     }
     if (Tools::isSubmit('ajax')) {
         die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
     }
 }
Example #13
0
 protected function _childValidation()
 {
     $email = $this->getFieldValue($this->loadObject(true), 'email');
     if (!Validate::isEmail($email)) {
         $this->_errors[] = Tools::displayError('Invalid e-mail');
     } else {
         if (Employee::employeeExists($email) and !Tools::getValue('id_employee')) {
             $this->_errors[] = Tools::displayError('an account already exists for this e-mail address:') . ' ' . $email;
         }
     }
 }
 public function preProcess()
 {
     global $cookie;
     $customer = new Customer((int) self::$cookie->id_customer);
     if (Tools::getValue('ref_emails')) {
         $emails = Tools::getValue('ref_emails');
         $emails = str_replace("\n", "", $emails);
         $emails = trim($emails);
         $emailList = explode(",", $emails);
         $invited = false;
         $db = Db::getInstance(_PS_USE_SQL_SLAVE_);
         $countInvited = 0;
         $countInvalid = 0;
         $invite_id = time();
         $date_invite = date('Y-m-d H:i:s');
         $pattern = '/<?([a-z0-9!#$%&\'*+\\/=?^`{}|~_-]+[.a-z0-9!#$%&\'*+\\/=?^`{}|~_-]*@[a-z0-9]+[._a-z0-9-]*\\.[a-z0-9]+)>?$/i';
         foreach ($emailList as $email) {
             $email = trim($email);
             $emailId = '';
             $name = '';
             //see if it contains the name
             if (strpos($email, '<') === false) {
                 $emailId = $email;
             } else {
                 preg_match($pattern, $email, $matches);
                 $emailId = $matches[1];
                 $name = strstr($email, '<', true);
             }
             $name = trim($name);
             $emailId = trim($emailId);
             //echo $name . ' : ' . $emailId . '<br />';
             if (!Validate::isEmail($emailId) || Customer::customerExists($emailId)) {
                 ++$countInvalid;
                 continue;
             }
             //Add referral record for this customer
             //$result = $db->getRow("SELECT `id_customer` FROM vb_customer_referrals WHERE email = '".$email."'");
             //if(!isset($result['id_customer']))
             $db->ExecuteS("INSERT INTO vb_customer_referrals (id_customer, email, date_add, id_invite, name) VALUES (" . $customer->id . ", '" . $emailId . "', '" . $date_invite . "', " . $invite_id . ", '" . $name . "')");
             ++$countInvited;
         }
         if ($countInvited) {
             Tools::sendSQSInviteMessage($invite_id, $customer->id);
         }
         self::$smarty->assign('countInvited', $countInvited);
         self::$smarty->assign('countInvalid', $countInvalid);
     }
     $res = Db::getInstance()->ExecuteS("select \n\t\t\t\t\t\t\t\t\t\t\tc.id_customer, \n\t\t\t\t\t\t\t\t\t\t\tconcat(c.firstname, ' ', c.lastname) as 'name', \n\t\t\t\t\t\t\t\t\t\t\tc.email, \n\t\t\t\t\t\t\t\t\t\t\tc.total_delivered,\n\t\t\t\t\t\t\t\t\t\t\tr.date_add\n\t\t\t\t\t\t\t\t\t\t\tfrom ps_customer c \n\t\t\t\t\t\t\t\t\t\t\tleft join vb_customer_referrals r on (c.email = r.email) \n\t\t\t\t\t\t\t\t\t\t\twhere id_referrer = " . self::$cookie->id_customer . "\n\t\t\t\t\t\t\t\t\t\t\tgroup by c.email");
     self::$smarty->assign(array('referrals' => $res, 'customer_id' => $customer->id));
     $res = Db::getInstance()->getRow("select count(*) as 'invited'\n\t\t\t\t\t\t\t\t\t\t\tfrom vb_customer_referrals\n\t\t\t\t\t\t\t\t\t\t\twhere id_customer = " . self::$cookie->id_customer . "\n\t\t\t\t\t\t\t\t\t\t\tgroup by email");
     if ($res && $res['invited'] > 0) {
         self::$smarty->assign('referrals_invited', 1);
     }
 }
Example #15
0
 public static function emailExists($email)
 {
     if (Validate::isEmail($email)) {
         $sql = "select id_user from user where email='" . pSQL($email) . "'";
         $result = Db::getInstance(false)->getValue($sql);
         if ($result) {
             return new SampleModel($result);
         }
     }
     return false;
 }
Example #16
0
 public static function customerExists($email, $return_id = false, $ignoreGuest = true)
 {
     if (!self::isOpcModuleActive()) {
         return parent::customerExists($email, $return_id, $ignoreGuest);
     }
     if (!Validate::isEmail($email)) {
         die(Tools::displayError());
     }
     if (Tools::isSubmit('submitAccount')) {
         return false;
     } else {
         return parent::customerExists($email, $return_id, $ignoreGuest);
     }
 }
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitOrderReturn')) {
         Configuration::updateValue('NOW_ORDER_RETURN_ACTIVE', (int) Tools::getValue('NOW_ORDER_RETURN_ACTIVE'));
         if (Validate::isEmail(Tools::getValue('NOW_ORDER_RETURN_EMAIL'))) {
             Configuration::updateValue('NOW_ORDER_RETURN_EMAIL', Tools::getValue('NOW_ORDER_RETURN_EMAIL'));
             $output .= '<div class="conf confirm">' . $this->l('Settings updated') . '</div>';
         } else {
             $output .= '<div class="error">' . $this->l('Email Error') . '</div>';
         }
     }
     return $output . $this->displayForm();
 }
 public function process()
 {
     parent::process();
     if (Tools::isSubmit('email')) {
         if (!($email = Tools::getValue('email')) or !Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } else {
             $customer = new Customer();
             $customer->getByemail($email);
             if (!Validate::isLoadedObject($customer)) {
                 $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
             } else {
                 if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                     $this->errors[] = Tools::displayError('You can regenerate your password only every') . ' ' . (int) $min_time . ' ' . Tools::displayError('minute(s)');
                 } else {
                     if (Mail::Send((int) self::$cookie->id_lang, 'password_query', Mail::l('Password query confirmation'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => self::$link->getPageLink('password.php', true) . '?token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                         self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
                     } else {
                         $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
                     }
                 }
             }
         }
     } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
         $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer);
         if ($email) {
             $customer = new Customer();
             $customer->getByemail($email);
             if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                 Tools::redirect('authentication.php?error_regen_pwd');
             } else {
                 $customer->passwd = Tools::encrypt($password = Tools::passwdGen((int) MIN_PASSWD_LENGTH));
                 $customer->last_passwd_gen = date('Y-m-d H:i:s', time());
                 if ($customer->update()) {
                     if (Mail::Send((int) self::$cookie->id_lang, 'password', Mail::l('Your password'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                         self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
                     } else {
                         $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
                     }
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
                 }
             }
         } else {
             $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
         }
     } elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer'))) {
         $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
     }
 }
 public function displayFrontForm()
 {
     global $smarty;
     $error = false;
     $confirm = false;
     if (isset($_POST['submitAddtoafriend'])) {
         global $cookie, $link;
         /* Product informations */
         $product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang);
         $productLink = $link->getProductLink($product);
         /* Fields verifications */
         if (empty($_POST['email']) or empty($_POST['name'])) {
             $error = $this->l('You must fill in all fields.');
         } elseif (empty($_POST['email']) or !Validate::isEmail($_POST['email'])) {
             $error = $this->l('The e-mail given is invalid.');
         } elseif (!Validate::isName($_POST['name'])) {
             $error = $this->l('The name given is invalid.');
         } elseif (!isset($_GET['id_product']) or !is_numeric($_GET['id_product'])) {
             $error = $this->l('An error occurred during the process.');
         } else {
             /* Email generation */
             $subject = ($cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend')) . ' ' . $this->l('sent you a link to') . ' ' . $product->name;
             $templateVars = array('{product}' => $product->name, '{product_link}' => $productLink, '{customer}' => $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : $this->l('A friend'), '{name}' => Tools::safeOutput($_POST['name']));
             /* Email sending */
             if (!Mail::Send((int) $cookie->id_lang, 'send_to_a_friend', Mail::l('A friend sent you a link to') . ' ' . $product->name, $templateVars, $_POST['email'], NULL, $cookie->email ? $cookie->email : NULL, $cookie->customer_firstname ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : NULL, NULL, NULL, dirname(__FILE__) . '/mails/')) {
                 $error = $this->l('An error occurred during the process.');
             } else {
                 Tools::redirect(_MODULE_DIR_ . '/' . $this->name . '/sendtoafriend-form.php?id_product=' . $product->id . '&submited');
             }
         }
     } else {
         global $cookie, $link;
         /* Product informations */
         $product = new Product((int) Tools::getValue('id_product'), false, (int) $cookie->id_lang);
         $productLink = $link->getProductLink($product);
     }
     /* Image */
     $images = $product->getImages((int) $cookie->id_lang);
     foreach ($images as $k => $image) {
         if ($image['cover']) {
             $cover['id_image'] = (int) $product->id . '-' . (int) $image['id_image'];
             $cover['legend'] = $image['legend'];
         }
     }
     if (!isset($cover)) {
         $cover = array('id_image' => Language::getIsoById((int) $cookie->id_lang) . '-default', 'legend' => 'No picture');
     }
     $smarty->assign(array('cover' => $cover, 'errors' => $error, 'confirm' => $confirm, 'product' => $product, 'productLink' => $productLink));
     return $this->display(__FILE__, 'sendtoafriend.tpl');
 }
Example #20
0
    public function getByEmailAndProduct($email, $id_product)
    {
        if (!Validate::isEmail($email)) {
            die(Tools::displayError());
        }
        $sql = 'SELECT *
				FROM `' . _DB_PREFIX_ . 'stock_alert`
				WHERE `email` = \'' . pSQL($email) . '\'
					AND `id_product`=' . $id_product;
        $result = Db::getInstance()->executeS($sql);
        if (!$result) {
            return false;
        }
        return $result[0];
    }
Example #21
0
 public function initContent()
 {
     parent::initContent();
     if (Tools::isSubmit('submitMessage')) {
         $message = Tools::getValue('message');
         // Html entities is not usefull, iscleanHtml check there is no bad html tags.
         $phone = Tools::getValue('tel');
         $mobile = Tools::getValue('mobile');
         if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) {
             $this->errors[] = Tools::displayError('Invalid email address.');
         } else {
             if (!$message) {
                 $this->errors[] = Tools::displayError('The message cannot be blank.');
             } else {
                 if (!Validate::isCleanHtml($message)) {
                     $this->errors[] = Tools::displayError('Invalid message');
                 } else {
                     if (!Validate::isPhoneNumber($phone)) {
                         $this->errors[] = Tools::displayError('Invalid phone number.');
                     } else {
                         if (!Validate::isPhoneNumber($mobile)) {
                             $this->errors[] = Tools::displayError('Invalid Mobile number.');
                         }
                     }
                 }
             }
         }
         //		var_dump($this->errors,empty($this->errors));
         if (empty($this->errors)) {
             $id_product = Tools::getValue('product_id');
             //var_dump($id_product);
             $product = new Product($id_product);
             //var_dump($product);
             $product_name = '';
             $item_number = '';
             if (Validate::isLoadedObject($product) && isset($product->name[(int) $this->context->language->id])) {
                 $product_name = $product->name[(int) $this->context->language->id];
                 $item_number = $product->item_number;
             }
             $data = array('{name}' => Tools::getValue('name'), '{phone}' => $phone, '{mobile}' => $mobile, '{message}' => $message, '{item_number}' => $item_number, '{product}' => $product_name, '{date}' => date('Y-m-d H:i:s'), '{email}' => $from);
             $sampleObj = new requestsample();
             $sampleObj->sendmail($data, $from, (int) $this->context->language->id, 'request_quote', 'New Request for Quote');
             $this->context->smarty->assign('confirmation', 1);
         }
     }
     $this->context->smarty->assign('product_id', $_GET['pr_id']);
     $this->setTemplate('quote_form.tpl');
 }
Example #22
0
 public static function customerExists($email, $return_id = false, $ignoreGuest = true)
 {
     if (!self::isOpcModuleActive()) {
         return parent::customerExists($email, $return_id, $ignoreGuest);
     }
     // verification keys: VK##2
     if (!Validate::isEmail($email)) {
         die(Tools::displayError());
     }
     // TODO: configuration variable v OPCKT (nieco ako $allow_guest_checkout_with_registered_email)
     if (Tools::isSubmit('submitAccount')) {
         return false;
     } else {
         return parent::customerExists($email, $return_id, $ignoreGuest);
     }
 }
Example #23
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitEkomi')) {
         $email = Tools::getValue('ekomi_email');
         Configuration::updateValue('PS_EKOMI_DISPLAY', Tools::getValue('ekomi_display'));
         Configuration::updateValue('PS_EKOMI_SCRIPT', htmlentities(str_replace(array("\r\n", "\n"), '', Tools::getValue('ekomi_script'))));
         if (!empty($email) && !Validate::isEmail($email)) {
             Configuration::updateValue('PS_EKOMI_EMAIL', '');
         } else {
             Configuration::updateValue('PS_EKOMI_EMAIL', Tools::getValue('ekomi_email'));
         }
         $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Confirmation') . '" />' . $this->l('Settings updated') . '</div>';
     }
     return $output . $this->displayForm();
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitEmailingStep2')) {
         $this->campaign_sender_email = (string) Tools::getValue('campaign_sender_email');
         $this->campaign_sender_name = (string) Tools::getValue('campaign_sender_name');
         if (empty($this->campaign_id) || empty($this->campaign_sender_email) || empty($this->campaign_sender_name)) {
             $this->errors[] = $this->module->l('Please verify the required fields', 'adminmarketingestep2');
         } elseif (!Validate::isEmail($this->campaign_sender_email)) {
             $this->errors[] = $this->module->l('Please verify your email address', 'adminmarketingestep2');
         } elseif (!Validate::isMailName($this->campaign_sender_name)) {
             $this->errors[] = $this->module->l('Please verify your sender name', 'adminmarketingestep2');
         } else {
             Db::getInstance()->update('expressmailing_email', array('campaign_sender_email' => pSQL($this->campaign_sender_email), 'campaign_sender_name' => pSQL($this->campaign_sender_name)), 'campaign_id = ' . pSQL($this->campaign_id));
             Tools::redirectAdmin('index.php?controller=AdminMarketingEStep3&campaign_id=' . $this->campaign_id . '&token=' . Tools::getAdminTokenLite('AdminMarketingEStep3'));
             exit;
         }
     }
 }
Example #25
0
 public static function Send($id_lang, $template, $subject, $templateVars, $to, $toName = NULL, $from = NULL, $fromName = NULL, $fileAttachment = NULL, $modeSMTP = NULL, $templatePath = _PS_MAIL_DIR_, $die = false, $id_shop = NULL, $bcc = null)
 {
     if (Module::isInstalled('agileprepaidcredit') and $template == 'payment_error') {
         if (AgilePrepaidCredit::isPaymentErrorCausedByTokens($templateVars) > 0) {
             return true;
         }
     }
     $order_info_templates = array('order_conf', 'bankwire', 'cheque', 'new_order');
     if (Module::isInstalled('agilesellershipping') and in_array($template, $order_info_templates)) {
         AgileSellerManager::adjust_shipping_cost_carriers($templateVars);
     }
     if (Module::isInstalled('agilepickupcenter') and $template == 'order_conf') {
         require_once _PS_ROOT_DIR_ . "/modules/agilepickupcenter/agilepickupcenter.php";
         $amodule = new AgilePickupCenter();
         $templateVars = $amodule->transform_mail_data($templateVars);
         if (isset($templateVars['{carrier_email}']) and Validate::isEmail($templateVars['{carrier_email}'])) {
             parent::Send($id_lang, $template, $subject, $templateVars, $templateVars['{carrier_email}'], $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc);
         }
     }
     if (in_array($template, $order_info_templates)) {
         $shop_email = Configuration::get('PS_SHOP_EMAIL');
         if (Module::isInstalled('agilemultipleseller')) {
             require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php";
             $templateVars = AgileSellerManager::appendMailTemplateVars($templateVars, $id_lang);
         }
         if (Module::isInstalled('agileprepaidcredit') and in_array($template, array('bankwire', 'cheque'))) {
             require_once _PS_ROOT_DIR_ . "/modules/agileprepaidcredit/agileprepaidcredit.php";
             $templateVars = AgilePrepaidCredit::replace_amount2pay($templateVars);
         }
         parent::Send($id_lang, $template, $subject, $templateVars, $shop_email, $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc);
     }
     if (Module::isInstalled('agilemultipleseller') and $template == 'order_customer_comment') {
         $id_order = intval($templateVars['{id_order}']);
         $id_seller = AgileSellerManager::getObjectOwnerID('order', $id_order);
         $seller = new Employee($id_seller);
         parent::Send($id_lang, $template, $subject, $templateVars, $seller->email, $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc);
     }
     if (Module::isInstalled('agilemultipleseller') and $template == 'order_conf') {
         require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php";
         AgileMultipleSeller::sendNewOrderMail($id_lang, $templateVars, $from, $fromName, $fileAttachment, $modeSMTP, $die, $id_shop, $bcc);
     }
     return parent::Send($id_lang, $template, $subject, $templateVars, $to, $toName, $from, $fromName, $fileAttachment, $modeSMTP, $templatePath, $die, $id_shop, $bcc);
 }
Example #26
0
    /**
     * Return employee instance from its e-mail (optionnaly check password)
     *
     * @param string $email e-mail
     * @param string $passwd Password is also checked if specified
     * @return Employee instance
     */
    public function getByEmail($email, $passwd = NULL)
    {
        if (!Validate::isEmail($email) or $passwd != NULL and !Validate::isPasswd($passwd)) {
            die('邮箱或密码有误!');
        }
        $result = Db::getInstance()->getRow('
		SELECT *
		FROM `' . DB_PREFIX . 'employee`
		WHERE `active` = 1
		AND `email` = \'' . pSQL($email) . '\'
		' . ($passwd ? 'AND `passwd` = \'' . Tools::encrypt($passwd) . '\'' : ''));
        if (!$result) {
            return false;
        }
        $this->id = $result['id_employee'];
        foreach ($result as $key => $value) {
            $this->{$key} = $value;
        }
        return $this;
    }
Example #27
0
 /**
  * Récupération de l'employé par identifiant (et mot de passe facultatif)
  *
  * @param $email
  * @param string $passwd Password is also checked if specified
  * @return User instance
  */
 public function getByEmail($email, $passwd = null)
 {
     if (!Validate::isEmail($email) || $passwd != null && !Validate::isPasswd($passwd)) {
         die(Tools::displayError());
     }
     $passwd = trim($passwd);
     $query = DbQuery::get()->select('*')->from('user')->where('login = "******"');
     if ($passwd) {
         $query->where('password = "******"');
     }
     $result = Db::getInstance()->getRow($query);
     if (!$result) {
         return false;
     }
     $this->id = $result['id_user'];
     foreach ($result as $key => $value) {
         if (property_exists($this, $key)) {
             $this->{$key} = $value;
         }
     }
     return $this;
 }
Example #28
0
    /**
     * Return employee instance from its e-mail (optionnaly check password)
     *
     * @param string $email e-mail
     * @param string $passwd Password is also checked if specified
     * @return Employee instance
     */
    public function getByEmail($email, $passwd = NULL)
    {
        if (!Validate::isEmail($email) or $passwd != NULL and !Validate::isPasswd($passwd)) {
            $this->_errors[] = 'invalid email password combination';
            return false;
        }
        $result = Db::getInstance()->getRow('
		SELECT *
		FROM `' . DB_PREFIX . 'user`
		WHERE `active` = 1
		AND `email` = \'' . pSQL($email) . '\'
		' . ($passwd ? 'AND `passwd` = \'' . Tools::encrypt($passwd) . '\'' : ''));
        if (!$result) {
            $this->_errors[] = 'invalid email password combination1';
            return false;
        }
        $this->id = $result['id_user'];
        foreach ($result as $key => $value) {
            $this->{$key} = $value;
        }
        return $this;
    }
 public function postProcess()
 {
     if (Tools::isSubmit('submitFaxTest')) {
         $number_or_email = (string) Tools::getValue('campaign_last_tester');
         if (empty($number_or_email)) {
             $this->errors[] = $this->module->l('Invalid fax number !', 'adminmarketingfstep7');
             return false;
         }
         if (Tools::strpos($number_or_email, '@')) {
             if (!Validate::isEmail($number_or_email)) {
                 $this->errors[] = $this->module->l('Invalid email address !', 'adminmarketingfstep7');
                 return false;
             }
         } else {
             $prefixe = EMTools::getShopPrefixeCountry();
             $number_or_email = EMTools::cleanNumber($number_or_email, $prefixe);
             if (!Validate::isPhoneNumber($number_or_email)) {
                 $this->errors[] = $this->module->l('Invalid fax number !', 'adminmarketingfstep7');
                 return false;
             }
             if ($number_or_email[0] != '0' && $number_or_email[0] != '+') {
                 $this->errors[] = $this->module->l('Invalid fax number !', 'adminmarketingfstep7');
                 return false;
             }
         }
         $response_array = array();
         $parameters = array('campaign_id' => $this->campaign_api_message_id, 'recipient' => $number_or_email);
         if ($this->session_api->call('fax', 'campaign', 'send_test', $parameters, $response_array)) {
             // We store the last fax number
             // ----------------------------
             Db::getInstance()->update('expressmailing_fax', array('campaign_last_tester' => pSQL($number_or_email)), 'campaign_id = ' . $this->campaign_id);
             $this->confirmations[] = sprintf($this->module->l('Please wait, your fax is processing to %s ...', 'adminmarketingfstep7'), $number_or_email);
             return true;
         }
         $this->errors[] = sprintf($this->module->l('Error while sending fax to the API : %s', 'adminmarketingfstep7'), $this->session_api->getError());
         return false;
     }
 }
 /**
  * Start forms process
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $origin_newsletter = (bool) $this->customer->newsletter;
     if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) {
         $this->customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
     }
     if (Tools::isSubmit('submitIdentity')) {
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth.');
         } else {
             $email = trim(Tools::getValue('email'));
             $this->customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
             if (isset($_POST['old_passwd'])) {
                 $_POST['old_passwd'] = trim($_POST['old_passwd']);
             }
             if (!Validate::isEmail($email)) {
                 $this->errors[] = Tools::displayError('This email address is not valid');
             } elseif ($this->customer->email != $email && Customer::customerExists($email, true)) {
                 $this->errors[] = Tools::displayError('An account using this email address has already been registered.');
             } elseif (!isset($_POST['old_passwd']) || empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != $this->context->cookie->passwd) {
                 $this->errors[] = Tools::displayError('The password you entered is incorrect.');
             } elseif ($_POST['passwd'] != $_POST['confirmation']) {
                 $this->errors[] = Tools::displayError('The password and confirmation do not match.');
             } else {
                 $prev_id_default_group = $this->customer->id_default_group;
                 // Merge all errors of this file and of the Object Model
                 $this->errors = array_merge($this->errors, $this->customer->validateController());
             }
             if (!count($this->errors)) {
                 $this->customer->id_default_group = (int) $prev_id_default_group;
                 $this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname));
                 if (!isset($_POST['newsletter'])) {
                     $this->customer->newsletter = 0;
                 } elseif (!$origin_newsletter && isset($_POST['newsletter'])) {
                     if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) {
                         if ($module_newsletter->active) {
                             $module_newsletter->confirmSubscription($this->customer->email);
                         }
                     }
                 }
                 if (!isset($_POST['optin'])) {
                     $this->customer->optin = 0;
                 }
                 if (Tools::getValue('passwd')) {
                     $this->context->cookie->passwd = $this->customer->passwd;
                 }
                 if ($this->customer->update()) {
                     $this->context->cookie->customer_lastname = $this->customer->lastname;
                     $this->context->cookie->customer_firstname = $this->customer->firstname;
                     $this->context->smarty->assign('confirmation', 1);
                 } else {
                     $this->errors[] = Tools::displayError('The information cannot be updated.');
                 }
             }
         }
     } else {
         $_POST = array_map('stripslashes', $this->customer->getFields());
     }
     return $this->customer;
 }