// Some fix on objectModel children classes (fields not valid, etc.)
This commit is contained in:
+1
-1
@@ -183,7 +183,7 @@ class CarrierCore extends ObjectModel
|
||||
return false;
|
||||
return Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'cart_rule_carrier WHERE id_carrier = '.(int)$this->id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change carrier id in delivery prices when updating a carrier
|
||||
*
|
||||
|
||||
+7
-5
@@ -164,6 +164,8 @@ class CartCore extends ObjectModel
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
{
|
||||
if (!$this->id_lang)
|
||||
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
||||
$return = parent::add($autodate);
|
||||
Hook::exec('cart');
|
||||
return $return;
|
||||
@@ -253,7 +255,7 @@ class CartCore extends ObjectModel
|
||||
Tools::displayAsDeprecated();
|
||||
return $this->getCartRules();
|
||||
}
|
||||
|
||||
|
||||
public function getCartRules()
|
||||
{
|
||||
// TODO : add cache
|
||||
@@ -266,7 +268,7 @@ class CartCore extends ObjectModel
|
||||
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||
$shipping_ti = $this->getOrderShippingCost();
|
||||
$shipping_te = $this->getOrderShippingCost(NULL, false);
|
||||
|
||||
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'cart_cart_rule` cd
|
||||
@@ -279,7 +281,7 @@ class CartCore extends ObjectModel
|
||||
$cartRule = new CartRule($row['id_cart_rule'], (int)$this->id_lang);
|
||||
$row['value_real'] = $cartRule->getContextualValue(true);
|
||||
$row['value_tax_exc'] = $cartRule->getContextualValue(false);
|
||||
|
||||
|
||||
// Retro compatibility < 1.5.0.2
|
||||
$row['id_discount'] = $row['id_cart_rule'];
|
||||
$row['description'] = $row['name'];
|
||||
@@ -1016,7 +1018,7 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
$wrapping_fees = Tools::convertPrice(Tools::ps_round($wrapping_fees, 2), Currency::getCurrencyInstance((int)($this->id_currency)));
|
||||
}
|
||||
|
||||
|
||||
$order_total_discount = 0;
|
||||
if ($type != Cart::ONLY_PRODUCTS && CartRule::isFeatureActive())
|
||||
{
|
||||
@@ -1275,7 +1277,7 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
return self::$_totalWeight[$this->id];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.0.1
|
||||
*/
|
||||
|
||||
+26
-21
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -26,10 +26,10 @@
|
||||
*/
|
||||
|
||||
class ConnectionCore extends ObjectModel
|
||||
{
|
||||
{
|
||||
/** @var integer */
|
||||
public $id_guest;
|
||||
|
||||
|
||||
/** @var integer */
|
||||
public $id_page;
|
||||
|
||||
@@ -38,26 +38,31 @@ class ConnectionCore extends ObjectModel
|
||||
|
||||
/** @var string */
|
||||
public $http_referer;
|
||||
|
||||
|
||||
/** @var int */
|
||||
public $id_shop;
|
||||
|
||||
|
||||
/** @var int */
|
||||
public $id_group_shop;
|
||||
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
public $date_add;
|
||||
|
||||
protected $fieldsRequired = array ('id_guest', 'id_page', 'id_shop', 'id_group_shop');
|
||||
protected $fieldsRequired = array ('id_guest', 'id_page', 'id_shop', 'id_group_shop');
|
||||
protected $fieldsValidate = array ('id_guest' => 'isUnsignedId', 'id_page' => 'isUnsignedId',
|
||||
'ip_address' => 'isInt', 'http_referer' => 'isAbsoluteUrl');
|
||||
|
||||
/* MySQL does not allow 'connection' for a table name */
|
||||
/* MySQL does not allow 'connection' for a table name */
|
||||
protected $table = 'connections';
|
||||
protected $identifier = 'id_connections';
|
||||
|
||||
|
||||
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();
|
||||
$fields['id_guest'] = (int)($this->id_guest);
|
||||
$fields['id_page'] = (int)($this->id_page);
|
||||
@@ -69,33 +74,33 @@ class ConnectionCore extends ObjectModel
|
||||
$fields['id_group_shop'] = (int)$this->id_group_shop;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
public static function setPageConnection($cookie, $full = true)
|
||||
{
|
||||
// The connection is created if it does not exist yet and we get the current page id
|
||||
if (!isset($cookie->id_connections) OR !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false)))
|
||||
if (!isset($cookie->id_connections) OR !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false)))
|
||||
$id_page = Connection::setNewConnection($cookie);
|
||||
if (!isset($id_page) OR !$id_page)
|
||||
$id_page = Page::getCurrentId();
|
||||
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
|
||||
return array('id_page' => $id_page);
|
||||
|
||||
|
||||
// The ending time will be updated by an ajax request when the guest will close the page
|
||||
$time_start = date('Y-m-d H:i:s');
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'connections_page', array('id_connections' => (int)($cookie->id_connections), 'id_page' => (int)($id_page), 'time_start' => $time_start), 'INSERT');
|
||||
|
||||
|
||||
// This array is serialized and used by the ajax request to identify the page
|
||||
return array(
|
||||
'id_connections' => (int)($cookie->id_connections),
|
||||
'id_page' => (int)($id_page),
|
||||
'time_start' => $time_start);
|
||||
}
|
||||
|
||||
|
||||
public static function setNewConnection($cookie, Shop $shop = null)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])
|
||||
AND preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz|bbot|Bjaaland|Ukonline|borg\-bot\/0\.9|boxseabot|bspider|calif|christcrawler|CMC\/0\.01|combine|confuzzledbot|CoolBot|cosmos|Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|H�m�h�kki|KIT\-Fireball|fouineur|Freecrawl|gammaSpider|gazz|gcreep|golem|googlebot|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\/0\.1|Informant|InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\.kapsi\.net|KDD\-Explorer|ko_yappo_robot|label\-grabber|larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\-MeshExplorer|MindCrawler|udmsearch|moget|Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\-info\-agent|WebMechanic|NetScoop|newscan\-online|ObjectsSearch|Occam|Orbsearch\/1\.0|packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\-Plus|Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|SLCrawler\/2\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\/1\.0|spiderline|nil|suke|http:\/\/www\.sygol\.com|tach_bw|TechBOT|templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\-perl|verticrawl|Victoria|void\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\/1\.0|webcatcher|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|Nederland\.zoek/i', $_SERVER['HTTP_USER_AGENT']))
|
||||
{
|
||||
@@ -111,7 +116,7 @@ class ConnectionCore extends ObjectModel
|
||||
return Page::getCurrentId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// A new connection is created if the guest made no actions during 30 minutes
|
||||
$sql = 'SELECT `id_guest`
|
||||
FROM `'._DB_PREFIX_.'connections`
|
||||
@@ -124,7 +129,7 @@ class ConnectionCore extends ObjectModel
|
||||
{
|
||||
// The old connections details are removed from the database in order to spare some memory
|
||||
Connection::cleanConnectionsPages();
|
||||
|
||||
|
||||
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
|
||||
$arrayUrl = parse_url($referer);
|
||||
if (!isset($arrayUrl['host']) OR preg_replace('/^www./', '', $arrayUrl['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)))
|
||||
@@ -142,14 +147,14 @@ class ConnectionCore extends ObjectModel
|
||||
return $connection->id_page;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function setPageTime($id_connections, $id_page, $time_start, $time)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_connections)
|
||||
OR !Validate::isUnsignedId($id_page)
|
||||
OR !Validate::isDate($time_start))
|
||||
return;
|
||||
|
||||
|
||||
// Limited to 5 minutes because more than 5 minutes is considered as an error
|
||||
if ($time > 300000)
|
||||
$time = 300000;
|
||||
@@ -160,7 +165,7 @@ class ConnectionCore extends ObjectModel
|
||||
AND `id_page` = '.(int)($id_page).'
|
||||
AND `time_start` = \''.pSQL($time_start).'\'');
|
||||
}
|
||||
|
||||
|
||||
public static function cleanConnectionsPages()
|
||||
{
|
||||
$period = Configuration::get('PS_STATS_OLD_CONNECT_AUTO_CLEAN');
|
||||
@@ -173,7 +178,7 @@ class ConnectionCore extends ObjectModel
|
||||
$interval = '1 YEAR';
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
if ($interval != null)
|
||||
{
|
||||
// Records of connections details older than the beginning of the specified interval are deleted
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ class CountryCore extends ObjectModel
|
||||
|
||||
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 $fieldsValidate = array(
|
||||
'id_zone' => 'isUnsignedId',
|
||||
@@ -122,7 +122,7 @@ class CountryCore extends ObjectModel
|
||||
$this->validateFieldsLang();
|
||||
return $this->getTranslationsFields(array('name'));
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!parent::delete())
|
||||
|
||||
+34
-31
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -30,14 +30,14 @@ class FeatureCore extends ObjectModel
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
public $position;
|
||||
|
||||
|
||||
protected $fieldsRequiredLang = array('name');
|
||||
protected $fieldsSizeLang = array('name' => 128);
|
||||
protected $fieldsValidateLang = array('name' => 'isGenericName', 'position' => 'isInt');
|
||||
|
||||
|
||||
protected $table = 'feature';
|
||||
protected $identifier = 'id_feature';
|
||||
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectsNodeName' => 'product_features',
|
||||
'objectNodeName' => 'product_feature',
|
||||
@@ -48,7 +48,7 @@ class FeatureCore extends ObjectModel
|
||||
{
|
||||
return array('id_feature' => NULL, 'position' => (int)$this->position);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check then return multilingual fields for database interaction
|
||||
*
|
||||
@@ -59,7 +59,7 @@ class FeatureCore extends ObjectModel
|
||||
$this->validateFieldsLang();
|
||||
return $this->getTranslationsFields(array('name'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a feature data for a given id_feature and id_lang
|
||||
*
|
||||
@@ -76,7 +76,7 @@ class FeatureCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON ( f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)($id_lang).')
|
||||
WHERE f.`id_feature` = '.(int)($id_feature));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all features for a given language
|
||||
*
|
||||
@@ -92,7 +92,7 @@ class FeatureCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON (f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = '.(int)($id_lang).')
|
||||
ORDER BY f.`position` ASC');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete several objects from database
|
||||
*
|
||||
@@ -112,6 +112,9 @@ class FeatureCore extends ObjectModel
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
{
|
||||
if ($this->position <= 0)
|
||||
$this->position = Feature::getHigherPosition() + 1;
|
||||
|
||||
$return = parent::add($autodate, true);
|
||||
Hook::exec('afterSaveFeature', array('id_feature' => $this->id));
|
||||
return $return;
|
||||
@@ -124,21 +127,21 @@ class FeatureCore extends ObjectModel
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)($this->id));
|
||||
/* Also delete related products */
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'feature_product` WHERE `id_feature` = '.(int)($this->id));
|
||||
|
||||
|
||||
$return = parent::delete();
|
||||
if($return)
|
||||
Hook::exec('afterDeleteFeature', array('id_feature' => $this->id));
|
||||
|
||||
|
||||
/* Reinitializing position */
|
||||
$this->cleanPositions();
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
public function update($nullValues = false)
|
||||
{
|
||||
$this->clearCache();
|
||||
|
||||
|
||||
$result = 1;
|
||||
$fields = $this->getTranslationsFieldsChild();
|
||||
foreach ($fields as $field)
|
||||
@@ -146,19 +149,19 @@ class FeatureCore extends ObjectModel
|
||||
foreach (array_keys($field) as $key)
|
||||
if (!Validate::isTableOrIdentifier($key))
|
||||
die(Tools::displayError());
|
||||
|
||||
|
||||
$sql = 'SELECT `id_lang` FROM `'.pSQL(_DB_PREFIX_.$this->table).'_lang`
|
||||
WHERE `'.pSQL($this->identifier).'` = '.(int)$this->id.'
|
||||
AND `id_lang` = '.(int)$field['id_lang'];
|
||||
$mode = Db::getInstance()->getRow($sql);
|
||||
$result &= (!$mode) ? Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->table.'_lang', $field, 'INSERT') :
|
||||
$result &= (!$mode) ? Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->table.'_lang', $field, 'INSERT') :
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->table.'_lang', $field, 'UPDATE', '`'.
|
||||
pSQL($this->identifier).'` = '.(int)$this->id.' AND `id_lang` = '.(int)$field['id_lang']);
|
||||
}
|
||||
Hook::exec('afterSaveFeature', array('id_feature' => $this->id));
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count number of features for a given language
|
||||
*
|
||||
@@ -175,14 +178,14 @@ class FeatureCore extends ObjectModel
|
||||
ORDER BY `name` ASC');
|
||||
return ($result['nb']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a feature from import
|
||||
*
|
||||
* @param integer $id_feature Feature id
|
||||
* @param integer $id_product Product id
|
||||
* @param array $value Feature Value
|
||||
*/
|
||||
* @param integer $id_product Product id
|
||||
* @param array $value Feature Value
|
||||
*/
|
||||
public static function addFeatureImport($name, $position = false)
|
||||
{
|
||||
$rq = Db::getInstance()->getRow('SELECT `id_feature` FROM '._DB_PREFIX_.'feature_lang WHERE `name` = \''.pSQL($name).'\' GROUP BY `id_feature`');
|
||||
@@ -200,21 +203,21 @@ class FeatureCore extends ObjectModel
|
||||
$feature->add();
|
||||
return $feature->id;
|
||||
}
|
||||
|
||||
|
||||
public static function getFeaturesForComparison($list_ids_product, $id_lang)
|
||||
{
|
||||
if (!Feature::isFeatureActive())
|
||||
return false;
|
||||
|
||||
|
||||
$ids = '';
|
||||
foreach($list_ids_product as $id)
|
||||
$ids .= (int)($id).',';
|
||||
|
||||
|
||||
$ids = rtrim($ids, ',');
|
||||
|
||||
|
||||
if (empty($ids))
|
||||
return false;
|
||||
|
||||
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT * , COUNT(*) as nb
|
||||
FROM `'._DB_PREFIX_.'feature` f
|
||||
@@ -225,7 +228,7 @@ class FeatureCore extends ObjectModel
|
||||
GROUP BY f.`id_feature`
|
||||
ORDER BY nb DESC');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This metohd is allow to know if a feature is used or active
|
||||
* @since 1.5.0.1
|
||||
@@ -235,7 +238,7 @@ class FeatureCore extends ObjectModel
|
||||
{
|
||||
return Configuration::get('PS_FEATURE_FEATURE_ACTIVE');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move a feature
|
||||
* @param boolean $way Up (1) or Down (0)
|
||||
@@ -273,7 +276,7 @@ class FeatureCore extends ObjectModel
|
||||
SET `position` = '.(int)$position.'
|
||||
WHERE `id_feature`='.(int)$movedFeature['id_feature']));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reorder feature position
|
||||
* Call it after deleting a feature.
|
||||
@@ -301,9 +304,9 @@ class FeatureCore extends ObjectModel
|
||||
|
||||
/**
|
||||
* getHigherPosition
|
||||
*
|
||||
*
|
||||
* Get the higher feature position
|
||||
*
|
||||
*
|
||||
* @return integer $position
|
||||
*/
|
||||
public static function getHigherPosition()
|
||||
@@ -311,7 +314,7 @@ class FeatureCore extends ObjectModel
|
||||
$sql = 'SELECT MAX(`position`)
|
||||
FROM `'._DB_PREFIX_.'feature`';
|
||||
$position = DB::getInstance()->getValue($sql);
|
||||
return ($position !== false) ? $position : -1;
|
||||
return (is_numeric($position)) ? $position : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -989,7 +989,7 @@ abstract class ModuleCore
|
||||
$sql = 'SELECT id_module, id_shop
|
||||
FROM '._DB_PREFIX_.'hook_module
|
||||
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';
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
$position = array();
|
||||
|
||||
@@ -478,7 +478,7 @@ abstract class ObjectModelCore
|
||||
foreach ($fieldsRequired as $field)
|
||||
if (Tools::isEmpty($this->{$field}) AND (!is_numeric($this->{$field})))
|
||||
{
|
||||
if ($die)
|
||||
if ($die)
|
||||
throw new PrestashopException('property empty : '.get_class($this).'->'.$field);
|
||||
return $errorReturn ? get_class($this).' -> '.$field.' is empty' : false;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ abstract class ObjectModelCore
|
||||
throw new PrestashopException('Validation function not found. '.$method);
|
||||
elseif (!empty($this->{$field}) AND !call_user_func(array('Validate', $method), $this->{$field}))
|
||||
{
|
||||
if ($die)
|
||||
if ($die)
|
||||
throw new PrestashopException('Field not valid : '.get_class($this).'->'.$field.' = '.$this->{$field});
|
||||
return $errorReturn ? get_class($this).' -> '.$field.' = '.$this->{$field} : false;
|
||||
}
|
||||
@@ -514,7 +514,7 @@ abstract class ObjectModelCore
|
||||
continue ;
|
||||
if (!$this->{$fieldArray} OR !sizeof($this->{$fieldArray}) OR ($this->{$fieldArray}[$defaultLanguage] !== '0' AND empty($this->{$fieldArray}[$defaultLanguage])))
|
||||
{
|
||||
if ($die)
|
||||
if ($die)
|
||||
throw new PrestashopException('empty for default language : '.get_class($this).'->'.$fieldArray);
|
||||
return $errorReturn ? get_class($this).'->'.$fieldArray.' '.Tools::displayError('is empty for default language.') : false;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ abstract class ObjectModelCore
|
||||
foreach ($this->{$fieldArray} as $k => $value)
|
||||
if (Tools::strlen($value) > $size)
|
||||
{
|
||||
if ($die)
|
||||
if ($die)
|
||||
throw new PrestashopException('fieldsize error '.get_class($this).'->'.$fieldArray.' length of '.$size.' for language');
|
||||
return $errorReturn ? get_class($this).'->'.$fieldArray.' '.Tools::displayError('Length').' '.$size.' '.Tools::displayError('for language') : false;
|
||||
}
|
||||
@@ -541,7 +541,7 @@ abstract class ObjectModelCore
|
||||
throw new PrestashopException('Validation function not found for lang: '.$method);
|
||||
elseif (!empty($value) AND !call_user_func(array('Validate', $method), $value))
|
||||
{
|
||||
if ($die)
|
||||
if ($die)
|
||||
throw new PrestashopException('Field not valid : '.get_class($this).'->'.$field.' = '.$this->{$field}. 'for language '.$k);
|
||||
return $errorReturn ? Tools::displayError('The following field is invalid according to the validate method ').'<b>'.$method.'</b>:<br/> ('. get_class($this).'->'.$fieldArray.' = '.$value.' '.Tools::displayError('for language').' '.$k : false;
|
||||
}
|
||||
|
||||
+6
-3
@@ -196,6 +196,9 @@ class OrderCore extends ObjectModel
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
if (!$this->id_lang)
|
||||
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
||||
|
||||
$this->validateFields();
|
||||
|
||||
$fields['id_group_shop'] = (int)$this->id_group_shop;
|
||||
@@ -614,7 +617,7 @@ class OrderCore extends ObjectModel
|
||||
}
|
||||
return $virtual;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.0.1
|
||||
*/
|
||||
@@ -623,7 +626,7 @@ class OrderCore extends ObjectModel
|
||||
Tools::displayAsDeprecated();
|
||||
return Order::getCartRules();
|
||||
}
|
||||
|
||||
|
||||
public function getCartRules()
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
@@ -898,7 +901,7 @@ class OrderCore extends ObjectModel
|
||||
Tools::displayAsDeprecated();
|
||||
return Order::addCartRule($id_cart_rule, $name, $value);
|
||||
}
|
||||
|
||||
|
||||
public function addCartRule($id_cart_rule, $name, $value)
|
||||
{
|
||||
return Db::getInstance()->AutoExecute(_DB_PREFIX_.'order_cart_rule', array('id_order' => (int)$this->id, 'id_cart_rule' => (int)$id_cart_rule, 'name' => pSQL($name), 'value' => (float)$value), 'INSERT');
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ class TabCore extends ObjectModel
|
||||
/** @var integer position */
|
||||
public $position;
|
||||
|
||||
protected $fieldsRequired = array('class_name', 'position');
|
||||
protected $fieldsRequired = array('class_name');
|
||||
protected $fieldsSize = array('class_name' => 64, 'module' => 64);
|
||||
protected $fieldsValidate = array(
|
||||
'id_parent' => 'isInt',
|
||||
@@ -105,7 +105,7 @@ class TabCore extends ObjectModel
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
if (!$context->employee->id_profile)
|
||||
if (!$context->employee || !$context->employee->id_profile)
|
||||
return false;
|
||||
/* Profile selection */
|
||||
$profiles = Db::getInstance()->executeS('
|
||||
|
||||
+27
-27
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -36,7 +36,7 @@ class ValidateCore
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for e-mail validity
|
||||
*
|
||||
@@ -106,7 +106,7 @@ class ValidateCore
|
||||
{
|
||||
return strval((float)($float)) == strval($float);
|
||||
}
|
||||
|
||||
|
||||
public static function isUnsignedFloat($float)
|
||||
{
|
||||
return strval((float)($float)) == strval($float) AND $float >= 0;
|
||||
@@ -243,17 +243,17 @@ class ValidateCore
|
||||
{
|
||||
return preg_match('/^[a-zA-Z]{2,3}$/', $isoCode);
|
||||
}
|
||||
|
||||
|
||||
public static function isLanguageCode($s)
|
||||
{
|
||||
return preg_match('/^[a-zA-Z]{2}(-[a-zA-Z]{2})?$/', $s);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
return preg_match('/^[0-9]{2,3}$/', $isoCode);
|
||||
@@ -430,7 +430,7 @@ class ValidateCore
|
||||
{
|
||||
return (bool)preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[0-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for date validity
|
||||
*
|
||||
@@ -494,7 +494,7 @@ class ValidateCore
|
||||
{
|
||||
return !$ean13 OR preg_match('/^[0-9]{0,13}$/', $ean13);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for barcode validity (UPC)
|
||||
*
|
||||
@@ -516,7 +516,7 @@ class ValidateCore
|
||||
{
|
||||
return empty($postcode) OR preg_match('/^[a-zA-Z 0-9-]+$/', $postcode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for zip code format validity
|
||||
*
|
||||
@@ -526,7 +526,7 @@ class ValidateCore
|
||||
public static function isZipCodeFormat($zip_code)
|
||||
{
|
||||
if (!empty($zip_code))
|
||||
return preg_match('/^[NLCnlc -]+$/', $zip_code);
|
||||
return preg_match('/^[NLCnlc 0-9-]+$/', $zip_code);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -691,12 +691,12 @@ class ValidateCore
|
||||
{
|
||||
return (in_array($engine, array('InnoDB', 'MyISAM')));
|
||||
}
|
||||
|
||||
|
||||
public static function isUnixName($data)
|
||||
{
|
||||
return preg_match('/^[a-z0-9\._-]+$/ui', $data);
|
||||
}
|
||||
|
||||
|
||||
public static function isTablePrefix($data)
|
||||
{
|
||||
// Even if "-" is theorically allowed, it will be considered a syntax error if you do not add backquotes (`) around the table name
|
||||
@@ -729,7 +729,7 @@ class ValidateCore
|
||||
{
|
||||
return preg_match('/^[a-zA-Z]{1,3}$/', $unit);
|
||||
}
|
||||
|
||||
|
||||
public static function isDistanceUnit($unit)
|
||||
{
|
||||
return preg_match('/^[a-zA-Z]{1,2}$/', $unit);
|
||||
@@ -777,7 +777,7 @@ class ValidateCore
|
||||
{
|
||||
return ($data == PS_TAX_EXC OR $data == PS_TAX_INC);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $dni to validate
|
||||
* @return bool
|
||||
@@ -786,7 +786,7 @@ class ValidateCore
|
||||
{
|
||||
return empty($dni) OR (bool)preg_match('/^[0-9A-Za-z-.]{1,16}$/U', $dni);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if $data is a PrestaShop cookie object
|
||||
*
|
||||
@@ -819,7 +819,7 @@ class ValidateCore
|
||||
{
|
||||
return ($data === 'amount' || $data === 'percentage');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for bool_id
|
||||
*
|
||||
@@ -841,7 +841,7 @@ class ValidateCore
|
||||
{
|
||||
return ($data === 'states' OR $data === 'taxes' OR $data === 'currencies' OR $data === 'languages' OR $data === 'units');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for PHP serialized data
|
||||
*
|
||||
@@ -852,7 +852,7 @@ class ValidateCore
|
||||
{
|
||||
return ($data == NULL) OR (bool)(is_string($data) AND preg_match('/^a:[0-9]+:{.*;}$/s', $data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for Latitude/Longitude
|
||||
*
|
||||
@@ -863,7 +863,7 @@ class ValidateCore
|
||||
{
|
||||
return ($data == NULL) OR (bool)(preg_match('/^\-?[0-9]{1,8}\.[0-9]{1,8}$/s', $data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for Language Iso Code
|
||||
*
|
||||
@@ -874,7 +874,7 @@ class ValidateCore
|
||||
{
|
||||
return (bool)(preg_match('/^[a-zA-Z]{2,3}$/s', $iso_code));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for Language File Name
|
||||
*
|
||||
@@ -885,11 +885,11 @@ class ValidateCore
|
||||
{
|
||||
return (bool)(preg_match('/^[a-zA-Z]{2,3}\.gzip$/s', $file_name));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $ids
|
||||
* @return boolean return true if the array contain only unsigned int value
|
||||
* @return boolean return true if the array contain only unsigned int value
|
||||
*/
|
||||
public static function isArrayWithIds($ids)
|
||||
{
|
||||
@@ -899,11 +899,11 @@ class ValidateCore
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $zones
|
||||
* @return boolean return true if array contain all value required for an image map zone
|
||||
* @return boolean return true if array contain all value required for an image map zone
|
||||
*/
|
||||
public static function isSceneZones($zones)
|
||||
{
|
||||
@@ -922,9 +922,9 @@ class ValidateCore
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param array $stock_management
|
||||
* @return boolean return true if is a valide stock management
|
||||
*/
|
||||
|
||||
@@ -64,17 +64,20 @@ class PrestashopExceptionCore extends Exception
|
||||
echo '<ul>';
|
||||
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 '<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']))
|
||||
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
|
||||
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);
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
@@ -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` ADD INDEX `id_product` (`id_product`, `id_product_attribute`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`);
|
||||
|
||||
/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, 1); */;
|
||||
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); */;
|
||||
|
||||
@@ -61,6 +61,7 @@ class BlockCms extends Module
|
||||
!Db::getInstance()->execute('
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
|
||||
`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,
|
||||
`location` tinyint(1) unsigned NOT NULL,
|
||||
`position` int(10) unsigned NOT NULL default \'0\',
|
||||
|
||||
Reference in New Issue
Block a user