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

This commit is contained in:
vChabot
2011-12-28 15:24:47 +00:00
parent 9e291b0a1b
commit 9ecde25550
2 changed files with 25 additions and 0 deletions
+18
View File
@@ -159,4 +159,22 @@ class ShopUrlCore extends ObjectModel
}
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
$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
return parent::postProcess();
}