Beispiel #1
0
 public function transformToCustomer($lang_id, $password = null)
 {
     if (!$this->isGuest()) {
         return false;
     }
     if (empty($password)) {
         $password = JeproshopTools::passwdGen();
     }
     if (!JeproshopTools::isPasswd($password)) {
         return false;
     }
     $this->is_guest = 0;
     $this->passwd = JeproshopTools::encrypt($password);
     $this->cleanGroups();
     $this->addGroups(array(JeproshopSettingModelSetting::getValue('customer_group')));
     // add default customer group
     if ($this->update()) {
         $vars = array('{firstname}' => $this->firstname, '{lastname}' => $this->lastname, '{email}' => $this->email, '{passwd}' => $password);
         Mail::Send((int) $lang_id, 'guest_to_customer', Mail::l('Your guest account has been transformed into a customer account', (int) $lang_id), $vars, $this->email, $this->firstname . ' ' . $this->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $this->shop_id);
         return true;
     }
     return false;
 }
Beispiel #2
0
    /**
     * Check if employee password is the right one
     *
     * @param int $employee_id
     * @param string $passwd Password
     * @return boolean result
     */
    public static function checkPassword($employee_id, $passwd)
    {
        if (!JeproshopTools::isUnsignedInt($employee_id) || !JeproshopTools::isPasswd($passwd, 8)) {
            die('');
        }
        return Db::getInstance()->getValue('
		SELECT `id_employee`
		FROM `' . _DB_PREFIX_ . 'employee`
		WHERE `id_employee` = ' . (int) $employee_id . '
		AND `passwd` = \'' . pSQL($passwd) . '\'
		AND active = 1');
    }