// BugFix : Adding an error when you try to update a shop_url already existing in another shop

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11857 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vChabot committed 2011-12-28 15:24:47 +00:00
1 parent 76533c40bd
commit 97722fd0d4
2 files changed
+25

No files matched your search

+18
View File
@@ -159,4 +159,22 @@ class ShopUrlCore extends ObjectModel
} }
return self::$main_domain_ssl; return self::$main_domain_ssl;
} }
/**
* @static
* @param string $virtual_uri
* @param int $id_shop_tested
* @return bool
*/
public static function virtualUriExists($virtual_uri, $id_shop_tested)
{
$virtual_uri = trim($virtual_uri);
if (substr($virtual_uri, -1) != '/')
$virtual_uri .= '/';
return (bool) Db::getInstance()->getValue('
SELECT `virtual_uri`
FROM `'._DB_PREFIX_.'shop_url`
WHERE `id_shop` != '.(int)$id_shop_tested.'
AND `virtual_uri` = "'.pSQL($virtual_uri).'"');
}
} }
@@ -258,6 +258,13 @@ class AdminShopUrlControllerCore extends AdminController
else else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.'); $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
} }
else if (Tools::isSubmit('submitAdd'.$this->table) && $this->tabAccess['add'] === '1')
{
if (ShopUrl::virtualUriExists(Tools::getValue('virtual_uri'), Tools::getValue('id_shop')))
$this->_errors[] = Tools::displayError('Virtual URI already used.');
else
return parent::postProcess();
}
else else
return parent::postProcess(); return parent::postProcess();
} }