Alteration for oscomerce importer prestashop 1.4 final
/**
* Return customers list
*
* @return array Customers
*/
static public function getCustomers()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT `id_customer`, `email`, `firstname`, `lastname`
FROM `'._DB_PREFIX_.'customer`
ORDER BY `id_customer` ASC');
}
/** alteration for oscommerce password prestashop 1.4 final */
static public function tep_validate_password($plain, $encrypted)
{
if (!empty($plain) && !empty($encrypted)) {
$stack = explode(':', $encrypted);
if (count($stack) != 2) return false;
if (md5($stack[1] . $plain) == $stack[0]) {
return true;
}
}
return false;
}
/**
* Return customer instance from its e-mail (optionnaly check password)
*
* @param string $email e-mail
* @param string $passwd Password is also checked if specified
* @return Customer instance
*/
public function getByEmail($email, $passwd = NULL)
{
if (!Validate::isEmail($email) OR ($passwd AND !Validate::isPasswd($passwd)))
die (Tools::displayError());
// alteration for oscommerce password prestashop 1.4 final
$result1 = Db::getInstance()->GetRow('
SELECT *
FROM `'._DB_PREFIX_ .'customer`
WHERE `active` = 1
AND `email` = \''.pSQL($email).'\'');
if (empty($result1['passwd']) || $result1['passwd'] != md5(pSQL(_COOKIE_KEY_.$passwd)))
{
if (!self::tep_validate_password($passwd, $result1['passwd_importerosc']))
return false;
Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_ .'customer`
SET `passwd` = \''.md5(pSQL(_COOKIE_KEY_.$passwd)).'\'
WHERE `email` = \''.pSQL($email).'\'');
}
/////// eof osc importer 1.4 final
$result = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_ .'customer`
WHERE `active` = 1
AND `email` = \''.pSQL($email).'\'
'.(isset($passwd) ? 'AND `passwd` = \''.md5(pSQL(_COOKIE_KEY_.$passwd)).'\'' : '').'
AND `deleted` = 0
AND `is_guest` = 0');
if (!$result)
return false;
$this->id = $result['id_customer'];
foreach ($result AS $key => $value)
if (key_exists($key, $this))
$this->{$key} = $value;
return $this;
}
Thanks Schilling http://www.casadorock.com