// Some fix on objectModel children classes (fields not valid, etc.)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9985 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie committed 2011-11-09 12:16:37 +00:00
1 parent 6694cf0a20
commit 14c94558a6
11 files changed
+29 -10

No files matched your search

+2
View File
@@ -164,6 +164,8 @@ class CartCore extends ObjectModel
public function add($autodate = true, $nullValues = false) public function add($autodate = true, $nullValues = false)
{ {
if (!$this->id_lang)
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
$return = parent::add($autodate); $return = parent::add($autodate);
Hook::exec('cart'); Hook::exec('cart');
return $return; return $return;
+5
View File
@@ -58,6 +58,11 @@ class ConnectionCore extends ObjectModel
public function getFields() public function getFields()
{ {
if (!$this->id_shop)
$this->id_shop = Context::getContext()->shop->getId(true);
if (!$this->id_group_shop)
$this->id_group_shop = Context::getContext()->shop->getGroupID();
$this->validateFields(); $this->validateFields();
$fields['id_guest'] = (int)($this->id_guest); $fields['id_guest'] = (int)($this->id_guest);
$fields['id_page'] = (int)($this->id_page); $fields['id_page'] = (int)($this->id_page);
+1 -1
View File
@@ -66,7 +66,7 @@ class CountryCore extends ObjectModel
protected $tables = array ('country', 'country_lang'); protected $tables = array ('country', 'country_lang');
protected $fieldsRequired = array('id_zone', 'id_currency', 'iso_code', 'contains_states', 'need_identification_number', 'display_tax_label'); protected $fieldsRequired = array('id_zone', 'iso_code', 'contains_states', 'need_identification_number', 'display_tax_label');
protected $fieldsSize = array('iso_code' => 3); protected $fieldsSize = array('iso_code' => 3);
protected $fieldsValidate = array( protected $fieldsValidate = array(
'id_zone' => 'isUnsignedId', 'id_zone' => 'isUnsignedId',
+4 -1
View File
@@ -112,6 +112,9 @@ class FeatureCore extends ObjectModel
public function add($autodate = true, $nullValues = false) public function add($autodate = true, $nullValues = false)
{ {
if ($this->position <= 0)
$this->position = Feature::getHigherPosition() + 1;
$return = parent::add($autodate, true); $return = parent::add($autodate, true);
Hook::exec('afterSaveFeature', array('id_feature' => $this->id)); Hook::exec('afterSaveFeature', array('id_feature' => $this->id));
return $return; return $return;
@@ -311,7 +314,7 @@ class FeatureCore extends ObjectModel
$sql = 'SELECT MAX(`position`) $sql = 'SELECT MAX(`position`)
FROM `'._DB_PREFIX_.'feature`'; FROM `'._DB_PREFIX_.'feature`';
$position = DB::getInstance()->getValue($sql); $position = DB::getInstance()->getValue($sql);
return ($position !== false) ? $position : -1; return (is_numeric($position)) ? $position : -1;
} }
} }
+1 -1
View File
@@ -989,7 +989,7 @@ abstract class ModuleCore
$sql = 'SELECT id_module, id_shop $sql = 'SELECT id_module, id_shop
FROM '._DB_PREFIX_.'hook_module FROM '._DB_PREFIX_.'hook_module
WHERE id_hook = '.(int)$id_hook.' WHERE id_hook = '.(int)$id_hook.'
'.((!is_null($shopList)) ? ' AND id_shop IN('.implode(', ', $shopList).')' : '').' '.((!is_null($shopList) && $shopList) ? ' AND id_shop IN('.implode(', ', $shopList).')' : '').'
ORDER BY position'; ORDER BY position';
$results = Db::getInstance()->executeS($sql); $results = Db::getInstance()->executeS($sql);
$position = array(); $position = array();
+3
View File
@@ -196,6 +196,9 @@ class OrderCore extends ObjectModel
public function getFields() public function getFields()
{ {
if (!$this->id_lang)
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
$this->validateFields(); $this->validateFields();
$fields['id_group_shop'] = (int)$this->id_group_shop; $fields['id_group_shop'] = (int)$this->id_group_shop;
+2 -2
View File
@@ -41,7 +41,7 @@ class TabCore extends ObjectModel
/** @var integer position */ /** @var integer position */
public $position; public $position;
protected $fieldsRequired = array('class_name', 'position'); protected $fieldsRequired = array('class_name');
protected $fieldsSize = array('class_name' => 64, 'module' => 64); protected $fieldsSize = array('class_name' => 64, 'module' => 64);
protected $fieldsValidate = array( protected $fieldsValidate = array(
'id_parent' => 'isInt', 'id_parent' => 'isInt',
@@ -105,7 +105,7 @@ class TabCore extends ObjectModel
{ {
if (!$context) if (!$context)
$context = Context::getContext(); $context = Context::getContext();
if (!$context->employee->id_profile) if (!$context->employee || !$context->employee->id_profile)
return false; return false;
/* Profile selection */ /* Profile selection */
$profiles = Db::getInstance()->executeS(' $profiles = Db::getInstance()->executeS('
+2 -2
View File
@@ -251,7 +251,7 @@ class ValidateCore
public static function isStateIsoCode($isoCode) public static function isStateIsoCode($isoCode)
{ {
return preg_match('/^[a-zA-Z0-9]{2,3}((-)[a-zA-Z0-9]{1,3})?$/', $isoCode); return preg_match('/^[a-zA-Z0-9]{1,3}((-)[a-zA-Z0-9]{1,3})?$/', $isoCode);
} }
public static function isNumericIsoCode($isoCode) public static function isNumericIsoCode($isoCode)
@@ -526,7 +526,7 @@ class ValidateCore
public static function isZipCodeFormat($zip_code) public static function isZipCodeFormat($zip_code)
{ {
if (!empty($zip_code)) if (!empty($zip_code))
return preg_match('/^[NLCnlc -]+$/', $zip_code); return preg_match('/^[NLCnlc 0-9-]+$/', $zip_code);
return true; return true;
} }
+6 -3
View File
@@ -64,17 +64,20 @@ class PrestashopExceptionCore extends Exception
echo '<ul>'; echo '<ul>';
foreach ($this->getTrace() as $id => $trace) foreach ($this->getTrace() as $id => $trace)
{ {
$relative_file = ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/'); $relative_file = (isset($trace['file'])) ? ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
$current_line = (isset($trace['line'])) ? $trace['line'] : '';
echo '<li>'; echo '<li>';
echo '<b>'.((isset($trace['class'])) ? $trace['class'] : '').((isset($trace['type'])) ? $trace['type'] : '').$trace['function'].'</b>'; echo '<b>'.((isset($trace['class'])) ? $trace['class'] : '').((isset($trace['type'])) ? $trace['type'] : '').$trace['function'].'</b>';
echo ' - <a href="#" style="font-size: 12px; color: #000000" onclick="document.getElementById(\'psTrace_'.$id.'\').style.display = (document.getElementById(\'psTrace_'.$id.'\').style.display != \'block\') ? \'block\' : \'none\'; return false">[line '.$trace['line'].' - '.$relative_file.']</a>'; echo ' - <a href="#" style="font-size: 12px; color: #000000" onclick="document.getElementById(\'psTrace_'.$id.'\').style.display = (document.getElementById(\'psTrace_'.$id.'\').style.display != \'block\') ? \'block\' : \'none\'; return false">[line '.$current_line.' - '.$relative_file.']</a>';
if (count($trace['args'])) if (count($trace['args']))
echo ' - <a href="#" onclick="document.getElementById(\'psArgs_'.$id.'\').style.display = (document.getElementById(\'psArgs_'.$id.'\').style.display != \'block\') ? \'block\' : \'none\'; return false">['.count($trace['args']).' Arguments]</a>'; echo ' - <a href="#" onclick="document.getElementById(\'psArgs_'.$id.'\').style.display = (document.getElementById(\'psArgs_'.$id.'\').style.display != \'block\') ? \'block\' : \'none\'; return false">['.count($trace['args']).' Arguments]</a>';
else else
echo ' - <span style="font-size: 12px;">[0 Argument]</a>'; echo ' - <span style="font-size: 12px;">[0 Argument]</a>';
$this->displayFileDebug($trace['file'], $trace['line'], $id);
if ($relative_file)
$this->displayFileDebug($trace['file'], $trace['line'], $id);
$this->displayArgsDebug($trace['args'], $id); $this->displayArgsDebug($trace['args'], $id);
echo '</li>'; echo '</li>';
} }
+2
View File
@@ -472,4 +472,6 @@ ALTER TABLE `PREFIX_specific_price` ADD `id_product_attribute` INT UNSIGNED NOT
ALTER TABLE `PREFIX_specific_price` DROP INDEX `id_product`; ALTER TABLE `PREFIX_specific_price` DROP INDEX `id_product`;
ALTER TABLE `PREFIX_specific_price` ADD INDEX `id_product` (`id_product`, `id_product_attribute`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`); ALTER TABLE `PREFIX_specific_price` ADD INDEX `id_product` (`id_product`, `id_product_attribute`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`);
ALTER TABLE `PREFIX_hook` ADD `is_native` TINYINT( 1 ) NOT NULL DEFAULT '0';
/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, 1); */; /* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, 1); */;
+1
View File
@@ -61,6 +61,7 @@ class BlockCms extends Module
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
`id_cms_block` int(10) unsigned NOT NULL auto_increment, `id_cms_block` int(10) unsigned NOT NULL auto_increment,
`id_shop` INT(11) UNSIGNED NOT NULL DEFAULT \'1\',
`id_cms_category` int(10) unsigned NOT NULL, `id_cms_category` int(10) unsigned NOT NULL,
`location` tinyint(1) unsigned NOT NULL, `location` tinyint(1) unsigned NOT NULL,
`position` int(10) unsigned NOT NULL default \'0\', `position` int(10) unsigned NOT NULL default \'0\',