// removing cookie from product customization
This commit is contained in:
@@ -174,7 +174,6 @@ abstract class AdminTabCore
|
||||
public function __construct()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$context->tab = $this;
|
||||
|
||||
$this->id = Tab::getCurrentTabId();
|
||||
$this->_conf = array(
|
||||
|
||||
+111
-73
@@ -339,8 +339,17 @@ class CartCore extends ObjectModel
|
||||
return array();
|
||||
// Product cache must be strictly compared to NULL, or else an empty cart will add dozens of queries
|
||||
if ($this->_products !== NULL AND !$refresh)
|
||||
{
|
||||
// Return product row with specified ID if it exists
|
||||
if (is_int($id_product))
|
||||
{
|
||||
foreach ($this->_products as $product)
|
||||
if ($product['id_product'] == $id_product)
|
||||
return array($product);
|
||||
return array();
|
||||
}
|
||||
return $this->_products;
|
||||
|
||||
}
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
@@ -632,7 +641,7 @@ class CartCore extends ObjectModel
|
||||
// refresh cache of self::_products
|
||||
$this->_products = $this->getProducts(true);
|
||||
$this->update(true);
|
||||
|
||||
|
||||
if ($product->customizable)
|
||||
return $this->_updateCustomizationQuantity((int)$quantity, (int)$id_customization, (int)$id_product, (int)$id_product_attribute, $operator);
|
||||
else
|
||||
@@ -642,16 +651,26 @@ class CartCore extends ObjectModel
|
||||
/*
|
||||
** Customization management
|
||||
*/
|
||||
protected function _updateCustomizationQuantity($quantity, $id_customization, $id_product, $id_product_attribute, $operator = 'up', Context $context = null)
|
||||
protected function _updateCustomizationQuantity($quantity, $id_customization, $id_product, $id_product_attribute, $operator = 'up')
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
/* Getting datas */
|
||||
$files = $context->cookie->getFamily('pictures_'.(int)($id_product).'_');
|
||||
$textFields = $context->cookie->getFamily('textFields_'.(int)($id_product).'_');
|
||||
/* Customization addition */
|
||||
if (count($files) > 0 OR count($textFields) > 0)
|
||||
return $this->_addCustomization((int)$id_product, (int)$id_product_attribute, $files, $textFields, (int)$quantity);
|
||||
// Link customization to product combination when it is first added to cart
|
||||
if (empty($id_customization))
|
||||
{
|
||||
$customization = $this->getProductCustomization($id_product, null, false);
|
||||
foreach ($customization as $field)
|
||||
{
|
||||
if ($field['quantity'] == 0)
|
||||
{
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'customization`
|
||||
SET `quantity` = '.(int)($quantity).',
|
||||
`id_product_attribute` = '.(int)$id_product_attribute.',
|
||||
`in_cart` = 1
|
||||
WHERE `id_customization` = '.(int)$field['id_customization']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Deletion */
|
||||
if (!empty($id_customization) AND (int)($quantity) < 1)
|
||||
return $this->_deleteCustomization((int)$id_customization, (int)$id_product, (int)$id_product_attribute);
|
||||
@@ -663,7 +682,10 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
if ($operator == 'down' AND (int)($result['quantity']) - (int)($quantity) < 1)
|
||||
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.(int)$id_customization);
|
||||
return Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customization` SET `quantity` = `quantity` '.($operator == 'up' ? '+ ' : '- ').(int)($quantity).' WHERE `id_customization` = '.(int)($id_customization));
|
||||
return Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'customization`
|
||||
SET `quantity` = `quantity` '.($operator == 'up' ? '+ ' : '- ').(int)($quantity).'
|
||||
WHERE `id_customization` = '.(int)($id_customization));
|
||||
}
|
||||
}
|
||||
// refresh cache of self::_products
|
||||
@@ -672,33 +694,46 @@ class CartCore extends ObjectModel
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _addCustomization($id_product, $id_product_attribute, $files, $textFields, $quantity)
|
||||
public function _addCustomization($id_product, $id_product_attribute, $index, $type, $field, $quantity, $id_customization = null)
|
||||
{
|
||||
if (!is_array($files) OR !is_array($textFields))
|
||||
die(Tools::displayError());
|
||||
/* Copying them inside the db */
|
||||
if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'customization` (`id_cart`, `id_product`, `id_product_attribute`, `quantity`) VALUES ('.(int)($this->id).', '.(int)($id_product).', '.(int)($id_product_attribute).', '.(int)($quantity).')'))
|
||||
return false;
|
||||
if (!$id_customization = Db::getInstance()->Insert_ID())
|
||||
return false;
|
||||
$query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`) VALUES ';
|
||||
if (count($files))
|
||||
foreach ($files AS $key => $filename)
|
||||
$exising_customization = Db::getInstance()->getRow('
|
||||
SELECT cu.id_customization, cd.index, cd.value, cd.type, cu.in_cart, cu.quantity FROM `'._DB_PREFIX_.'customization` cu
|
||||
LEFT JOIN `'._DB_PREFIX_.'customized_data` cd
|
||||
ON cu.`id_customization` = cd.`id_customization`
|
||||
WHERE cu.id_cart = '.(int)$this->id.'
|
||||
AND cu.id_product = '.(int)$id_product.'
|
||||
AND type = '.(int)$type.'
|
||||
AND `index` = '.(int)$index.'
|
||||
AND in_cart = 0');
|
||||
|
||||
// If the customization field is alreay filled, delete it
|
||||
if ($exising_customization)
|
||||
{
|
||||
if ($exising_customization['type'] == $type && $exising_customization['index'] == $index)
|
||||
{
|
||||
$tmp = explode('_', $key);
|
||||
$query .= '('.(int)($id_customization).', '._CUSTOMIZE_FILE_.', '.$tmp[2].', \''.$filename.'\'), ';
|
||||
Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'customized_data`
|
||||
WHERE id_customization = '.(int)$exising_customization['id_customization'].'
|
||||
AND type = '.(int)$exising_customization['type'].'
|
||||
AND `index` = '.(int)$exising_customization['index']);
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
{
|
||||
@unlink(_PS_UPLOAD_DIR_.$exising_customization['value']);
|
||||
@unlink(_PS_UPLOAD_DIR_.$exising_customization['value'].'_small');
|
||||
}
|
||||
}
|
||||
if (count($textFields))
|
||||
foreach ($textFields AS $key => $textFieldValue)
|
||||
{
|
||||
$tmp = explode('_', $key);
|
||||
$query .= '('.(int)($id_customization).', '._CUSTOMIZE_TEXTFIELD_.', '.$tmp[2].', \''.$textFieldValue.'\'), ';
|
||||
}
|
||||
$query = rtrim($query, ', ');
|
||||
$id_customization = $exising_customization['id_customization'];
|
||||
}else
|
||||
{
|
||||
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'customization` (`id_cart`, `id_product`, `id_product_attribute`, `quantity`) VALUES ('.(int)($this->id).', '.(int)($id_product).', '.(int)($id_product_attribute).', '.(int)($quantity).')');
|
||||
$id_customization = Db::getInstance()->Insert_ID();
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`) VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSql($field).'\')';
|
||||
|
||||
if (!$result = Db::getInstance()->Execute($query))
|
||||
return false;
|
||||
/* Deleting customized informations from the cart (we just copied them inside the db) */
|
||||
return Cart::deleteCustomizationInformations((int)($id_product));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -777,7 +812,7 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a customization from the cart. If customization is a Picture (type=2),
|
||||
* Delete a customization from the cart. If customization is a Picture,
|
||||
* then the image is also deleted
|
||||
*
|
||||
* @param integer $id_customization
|
||||
@@ -796,8 +831,9 @@ class CartCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'customized_data`
|
||||
WHERE `id_customization` = '.(int)($id_customization));
|
||||
|
||||
// Delete customization picture if necessary
|
||||
if (isset($custData['type']) and $custData['type'] == 0)
|
||||
$result &= $this->deletePictureToProduct($id_product,$custData['value']);
|
||||
$result &= (@unlink(_PS_UPLOAD_DIR_.$custData['value']) && @unlink(_PS_UPLOAD_DIR_.$custData['value'].'_small'));
|
||||
|
||||
$result &= Db::getInstance()->execute('DELETE
|
||||
FROM `'._DB_PREFIX_.'customized_data`
|
||||
@@ -1274,7 +1310,7 @@ class CartCore extends ObjectModel
|
||||
|
||||
if (($discountObj->id_customer OR $discountObj->id_group) AND ($this->id_customer != $discountObj->id_customer AND !in_array($discountObj->id_group, $groups)))
|
||||
{
|
||||
if (!$context->cookie->isLogged())
|
||||
if (!$context->customer->isLogged())
|
||||
return Tools::displayError('You cannot use this voucher.').' - '.Tools::displayError('Please log in.');
|
||||
return Tools::displayError('You cannot use this voucher.');
|
||||
}
|
||||
@@ -1478,26 +1514,6 @@ class CartCore extends ObjectModel
|
||||
return $result['id_cart'];
|
||||
}
|
||||
|
||||
/*
|
||||
* Add customer's pictures
|
||||
*
|
||||
* @return bool Always true
|
||||
*/
|
||||
public function addPictureToProduct($id_product, $index, $identifier, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$varName = 'pictures_'.(int)($id_product).'_'.(int)($index);
|
||||
if ($context->cookie->$varName)
|
||||
{
|
||||
@unlink(_PS_UPLOAD_DIR_.$context->cookie->$varName);
|
||||
@unlink(_PS_UPLOAD_DIR_.$context->cookie->$varName.'_small');
|
||||
}
|
||||
$context->cookie->$varName = $identifier;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add customer's text
|
||||
*
|
||||
@@ -1528,29 +1544,51 @@ class CartCore extends ObjectModel
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add customer's pictures
|
||||
*
|
||||
* @return bool Always true
|
||||
*/
|
||||
public function addPictureToProduct($id_product, $index, $type, $field)
|
||||
{
|
||||
$product_array = $this->getProducts(false, $id_product);
|
||||
$id_customization = $this->_addCustomization($id_product, 0, $index, $type, $field, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove a customer's picture
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deletePictureToProduct($id_product, $index, Context $context = null)
|
||||
public function deletePictureToProduct($id_product, $index)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$varName = 'pictures_'.(int)($id_product).'_'.(int)($index);
|
||||
// if cookie->varName is empty, use index which is the name of the picture
|
||||
$picture = !empty($context->cookie->$varName) ? $context->cookie->$varName : $index;
|
||||
if ($picture)
|
||||
{
|
||||
if (!@unlink(_PS_UPLOAD_DIR_.$picture) OR !@unlink(_PS_UPLOAD_DIR_.$picture.'_small'))
|
||||
return false;
|
||||
unset($context->cookie->$varName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
$product_array = $this->getProducts(false, $id_product);
|
||||
|
||||
if (isset($product_array[0]) && $product = $product_array[0])
|
||||
return $this->_deleteCustomization($product['id_customization'], $id_product, $product['id_product_attribute']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return custom pictures in this cart for a specified product
|
||||
*
|
||||
* @param int $id_product
|
||||
* @return array result rows
|
||||
*/
|
||||
public function getProductCustomization($id_product, $type = null, $in_cart = false)
|
||||
{
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT cu.id_customization, cd.index, cd.value, cd.type, cu.in_cart, cu.quantity FROM `'._DB_PREFIX_.'customization` cu
|
||||
LEFT JOIN `'._DB_PREFIX_.'customized_data` cd
|
||||
ON cu.`id_customization` = cd.`id_customization`
|
||||
WHERE cu.id_cart = '.(int)$this->id.'
|
||||
AND cu.id_product = '.(int)$id_product.
|
||||
($type == 0 ? ' AND type = 0' : '').
|
||||
($type == 1 ? ' AND type = 1' : '').
|
||||
' AND in_cart = '.($in_cart ? '1' : '0')
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function deleteCustomizationInformations($id_product, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
|
||||
+2
-1
@@ -122,7 +122,8 @@ class CountryCore extends ObjectModel
|
||||
{
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT s.*
|
||||
FROM `'._DB_PREFIX_.'state` s
|
||||
|
||||
@@ -94,10 +94,16 @@ class CustomerCore extends ObjectModel
|
||||
public $days;
|
||||
public $months;
|
||||
|
||||
/** @var int customer id_country as determined by geolocation */
|
||||
public $geoloc_id_country;
|
||||
/** @var int customer id_state as determined by geolocation */
|
||||
public $geoloc_id_state;
|
||||
/** @var string customer postcode as determined by geolocation */
|
||||
public $geoloc_postcode;
|
||||
|
||||
/** @var boolean is the customer logged in */
|
||||
public $logged = 0;
|
||||
|
||||
protected $tables = array ('customer');
|
||||
|
||||
protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email');
|
||||
@@ -712,4 +718,22 @@ class CustomerCore extends ObjectModel
|
||||
$this->passwd = Tools::encrypt($passwd);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check customer informations and return customer validity
|
||||
*
|
||||
* @parma boolean $withGuest
|
||||
* @return boolean customer validity
|
||||
*/
|
||||
public function isLogged($withGuest = false)
|
||||
{
|
||||
if (!$withGuest AND $this->is_guest == 1)
|
||||
return false;
|
||||
|
||||
/* Customer is valid only if it can be load and if object password is the same as database one */
|
||||
if ($this->logged == 1 AND $this->id AND Validate::isUnsignedId($this->id) AND self::checkPassword($this->id, $this->passwd))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+31
-30
@@ -28,7 +28,7 @@
|
||||
class FrontControllerCore
|
||||
{
|
||||
public $errors = array();
|
||||
public $smarty;
|
||||
protected static $smarty;
|
||||
protected static $cookie;
|
||||
protected static $link;
|
||||
protected static $cart;
|
||||
@@ -101,6 +101,12 @@ class FrontControllerCore
|
||||
|
||||
$cookie = new Cookie('ps');
|
||||
$context->cookie = $cookie;
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$link = new Link($protocol_link, $protocol_content);
|
||||
$context->link = $link;
|
||||
|
||||
if ($this->auth AND !$cookie->isLogged($this->guestAllowed))
|
||||
Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : ''));
|
||||
|
||||
@@ -132,9 +138,7 @@ class FrontControllerCore
|
||||
}
|
||||
|
||||
$currency = Tools::setCurrency($cookie);
|
||||
|
||||
$_MODULES = array();
|
||||
|
||||
/* Cart already exists */
|
||||
if ((int)$cookie->id_cart)
|
||||
{
|
||||
@@ -204,7 +208,7 @@ class FrontControllerCore
|
||||
setlocale(LC_CTYPE, $locale);
|
||||
setlocale(LC_TIME, $locale);
|
||||
setlocale(LC_NUMERIC, 'en_US.UTF-8');
|
||||
|
||||
|
||||
if (Validate::isLoadedObject($currency))
|
||||
$smarty->ps_currency = $currency;
|
||||
if (!Validate::isLoadedObject($language = new Language($cookie->id_lang)))
|
||||
@@ -223,11 +227,6 @@ class FrontControllerCore
|
||||
$navigationPipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>');
|
||||
$smarty->assign('navigationPipe', $navigationPipe);
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$link = new Link($protocol_link, $protocol_content);
|
||||
$context->link = $link;
|
||||
|
||||
if (!defined('_PS_BASE_URL_'))
|
||||
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
||||
if (!defined('_PS_BASE_URL_SSL_'))
|
||||
@@ -306,10 +305,10 @@ class FrontControllerCore
|
||||
else
|
||||
$smarty->assign($assignKey, $assignValue);
|
||||
|
||||
// setting properties from global var
|
||||
// shortcuts to context objects
|
||||
self::$cookie = $cookie;
|
||||
self::$cart = $cart;
|
||||
$this->smarty = $smarty;
|
||||
self::$smarty = $smarty;
|
||||
self::$link = $link;
|
||||
|
||||
if ($this->maintenance)
|
||||
@@ -326,7 +325,10 @@ class FrontControllerCore
|
||||
$this->setMedia();
|
||||
|
||||
if (isset($cookie->id_customer) && (int)$cookie->id_customer)
|
||||
{
|
||||
$customer = new Customer($cookie->id_customer);
|
||||
$customer->logged = $cookie->logged;
|
||||
}
|
||||
else
|
||||
$customer = new Customer();
|
||||
|
||||
@@ -340,7 +342,6 @@ class FrontControllerCore
|
||||
|
||||
$context->customer = $customer;
|
||||
$context->cart = $cart;
|
||||
$context->cookie = $cookie;
|
||||
$context->currency = $currency;
|
||||
$context->controller = $this;
|
||||
$context->country = $defaultCountry;
|
||||
@@ -352,7 +353,7 @@ class FrontControllerCore
|
||||
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP'))))
|
||||
{
|
||||
header('HTTP/1.1 503 temporarily overloaded');
|
||||
$this->smarty->display(_PS_THEME_DIR_.'maintenance.tpl');
|
||||
self::$smarty->display(_PS_THEME_DIR_.'maintenance.tpl');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -361,7 +362,7 @@ class FrontControllerCore
|
||||
protected function displayRestrictedCountryPage()
|
||||
{
|
||||
header('HTTP/1.1 503 temporarily overloaded');
|
||||
$this->smarty->display(_PS_THEME_DIR_.'restricted-country.tpl');
|
||||
self::$smarty->display(_PS_THEME_DIR_.'restricted-country.tpl');
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -412,7 +413,7 @@ class FrontControllerCore
|
||||
if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_)
|
||||
$this->restrictedCountry = true;
|
||||
elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_)
|
||||
$this->smarty->assign(array(
|
||||
self::$smarty->assign(array(
|
||||
'restricted_country_mode' => true,
|
||||
'geolocation_country' => $record->country_name
|
||||
));
|
||||
@@ -437,7 +438,7 @@ class FrontControllerCore
|
||||
elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_)
|
||||
$this->restrictedCountry = true;
|
||||
elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_)
|
||||
$this->smarty->assign(array(
|
||||
self::$smarty->assign(array(
|
||||
'restricted_country_mode' => true,
|
||||
'geolocation_country' => 'Undefined'
|
||||
));
|
||||
@@ -475,19 +476,19 @@ class FrontControllerCore
|
||||
public function displayContent()
|
||||
{
|
||||
Tools::safePostVars();
|
||||
$this->smarty->assign('errors', $this->errors);
|
||||
self::$smarty->assign('errors', $this->errors);
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (!self::$initialized)
|
||||
$this->init();
|
||||
|
||||
$context = Context::getContext();
|
||||
// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
|
||||
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
|
||||
|
||||
/* Hooks are volontary out the initialize array (need those variables already assigned) */
|
||||
$this->smarty->assign(array(
|
||||
self::$smarty->assign(array(
|
||||
'time' => time(),
|
||||
'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
|
||||
'static_token' => Tools::getToken(false),
|
||||
@@ -497,7 +498,7 @@ class FrontControllerCore
|
||||
'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
|
||||
'content_only' => (int)Tools::getValue('content_only')
|
||||
));
|
||||
$this->smarty->assign(array(
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_HEADER' => Module::hookExec('header'),
|
||||
'HOOK_TOP' => Module::hookExec('top'),
|
||||
'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn')
|
||||
@@ -514,9 +515,9 @@ class FrontControllerCore
|
||||
$this->js_files = Tools::cccJs($this->js_files);
|
||||
}
|
||||
|
||||
$this->smarty->assign('css_files', $this->css_files);
|
||||
$this->smarty->assign('js_files', array_unique($this->js_files));
|
||||
$this->smarty->display(_PS_THEME_DIR_.'header.tpl');
|
||||
self::$smarty->assign('css_files', $this->css_files);
|
||||
self::$smarty->assign('js_files', array_unique($this->js_files));
|
||||
self::$smarty->display(_PS_THEME_DIR_.'header.tpl');
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
@@ -524,16 +525,16 @@ class FrontControllerCore
|
||||
if (!self::$initialized)
|
||||
$this->init();
|
||||
|
||||
$this->smarty->assign(array(
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => self::$cart)),
|
||||
'HOOK_FOOTER' => Module::hookExec('footer'),
|
||||
'content_only' => (int)(Tools::getValue('content_only'))));
|
||||
$this->smarty->display(_PS_THEME_DIR_.'footer.tpl');
|
||||
self::$smarty->display(_PS_THEME_DIR_.'footer.tpl');
|
||||
//live edit
|
||||
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
|
||||
{
|
||||
$this->smarty->assign(array('ad' => $ad, 'live_edit' => true));
|
||||
$this->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
|
||||
self::$smarty->assign(array('ad' => $ad, 'live_edit' => true));
|
||||
self::$smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
|
||||
}
|
||||
else
|
||||
Tools::displayError();
|
||||
@@ -560,7 +561,7 @@ class FrontControllerCore
|
||||
if (!in_array($this->orderWay, $orderWayValues))
|
||||
$this->orderWay = $orderWayValues[0];
|
||||
|
||||
$this->smarty->assign(array(
|
||||
self::$smarty->assign(array(
|
||||
'orderby' => $this->orderBy,
|
||||
'orderway' => $this->orderWay,
|
||||
'orderbydefault' => $orderByValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_BY'))],
|
||||
@@ -596,7 +597,7 @@ class FrontControllerCore
|
||||
$stop = (int)($this->p + $range);
|
||||
if ($stop > $pages_nb)
|
||||
$stop = (int)($pages_nb);
|
||||
$this->smarty->assign('nb_products', $nbProducts);
|
||||
self::$smarty->assign('nb_products', $nbProducts);
|
||||
$pagination_infos = array(
|
||||
'pages_nb' => (int)($pages_nb),
|
||||
'p' => (int)($this->p),
|
||||
@@ -606,7 +607,7 @@ class FrontControllerCore
|
||||
'start' => (int)($start),
|
||||
'stop' => (int)($stop)
|
||||
);
|
||||
$this->smarty->assign($pagination_infos);
|
||||
self::$smarty->assign($pagination_infos);
|
||||
}
|
||||
|
||||
public static function getCurrentCustomerGroups()
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ class MessageCore extends ObjectModel
|
||||
SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname, (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
|
||||
FROM `'._DB_PREFIX_.'message` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer`
|
||||
LEFT JOIN `'._DB_PREFIX_.'message_readed` mr ON (mr.id_message = m.id_message AND mr.id_employee = '.(int)$context->employee->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'message_readed` mr ON (mr.`id_message` = m.`id_message` AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').')
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
|
||||
WHERE id_order = '.(int)$id_order.'
|
||||
'.(!$private ? ' AND m.`private` = 0' : '').'
|
||||
|
||||
@@ -219,6 +219,7 @@ abstract class ObjectModelCore
|
||||
|
||||
if (!$result)
|
||||
return false;
|
||||
|
||||
/* Get object id in database */
|
||||
$this->id = Db::getInstance()->Insert_ID();
|
||||
$assos = Shop::getAssoTables();
|
||||
|
||||
@@ -91,6 +91,8 @@ abstract class PaymentModuleCore extends Module
|
||||
public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
|
||||
{
|
||||
$cart = new Cart((int)($id_cart));
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($cart) AND $cart->OrderExists() == false)
|
||||
{
|
||||
|
||||
+7
-13
@@ -416,11 +416,7 @@ class ProductCore extends ObjectModel
|
||||
public static function initPricesComputation($customer = NULL)
|
||||
{
|
||||
if ($customer)
|
||||
{
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError());
|
||||
self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int)($customer->id_default_group));
|
||||
}
|
||||
else
|
||||
self::$_taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
|
||||
}
|
||||
@@ -1738,7 +1734,7 @@ class ProductCore extends ObjectModel
|
||||
* When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
|
||||
* When called from the back office, cart ID can be inexistant
|
||||
*/
|
||||
if (!$id_cart &&!isset($context->tab))
|
||||
if (!$id_cart &&!isset($context->employee))
|
||||
die(Tools::displayError());
|
||||
$cur_cart = new Cart($id_cart);
|
||||
}
|
||||
@@ -2901,29 +2897,27 @@ class ProductCore extends ObjectModel
|
||||
** Customization management
|
||||
*/
|
||||
|
||||
public static function getAllCustomizedDatas($id_cart, $id_lang = null, Context $context = null)
|
||||
public static function getAllCustomizedDatas($id_cart, $id_lang = null, $only_in_cart = true)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
// No need to query if there isn't any real cart!
|
||||
if (!$id_cart)
|
||||
return false;
|
||||
if (!$id_lang)
|
||||
$id_lang = $context->language->id;
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if (!$result = Db::getInstance()->ExecuteS('
|
||||
SELECT cd.`id_customization`, c.`id_product`, cfl.`id_customization_field`, c.`id_product_attribute`, cd.`type`, cd.`index`, cd.`value`, cfl.`name`
|
||||
FROM `'._DB_PREFIX_.'customized_data` cd
|
||||
NATURAL JOIN `'._DB_PREFIX_.'customization` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'customization_field_lang` cfl ON (cfl.id_customization_field = cd.`index` AND id_lang = '.(int)($id_lang).')
|
||||
WHERE c.`id_cart` = '.(int)$id_cart.'
|
||||
WHERE c.`id_cart` = '.(int)$id_cart.
|
||||
($only_in_cart ? ' AND c.`in_cart` = 1' : '').'
|
||||
ORDER BY `id_product`, `id_product_attribute`, `type`, `index`'))
|
||||
return false;
|
||||
$customizedDatas = array();
|
||||
foreach ($result AS $row)
|
||||
$customizedDatas[(int)($row['id_product'])][(int)($row['id_product_attribute'])][(int)($row['id_customization'])]['datas'][(int)($row['type'])][] = $row;
|
||||
if (!$result = Db::getInstance()->ExecuteS('SELECT `id_product`, `id_product_attribute`, `id_customization`, `quantity`, `quantity_refunded`, `quantity_returned` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)($id_cart)))
|
||||
if (!$result = Db::getInstance()->ExecuteS('SELECT `id_product`, `id_product_attribute`, `id_customization`, `quantity`, `quantity_refunded`, `quantity_returned` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)($id_cart).($only_in_cart ? ' AND `in_cart` = 1' : '')))
|
||||
return false;
|
||||
foreach ($result AS $row)
|
||||
{
|
||||
@@ -3107,7 +3101,7 @@ class ProductCore extends ObjectModel
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify if a product is already in database
|
||||
*
|
||||
|
||||
+3
-4
@@ -1861,7 +1861,7 @@ FileETag INode MTime Size
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
$smarty = $context->controller->smarty;
|
||||
$smarty = $context->smarty;
|
||||
if (!Configuration::get('PS_SMARTY_CACHE'))
|
||||
return;
|
||||
if ($smarty->force_compile == 0 AND $smarty->caching == $level)
|
||||
@@ -1876,12 +1876,11 @@ FileETag INode MTime Size
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
$smarty = $context->controller->smarty;
|
||||
|
||||
if (isset(self::$_forceCompile))
|
||||
$smarty->force_compile = (int)(self::$_forceCompile);
|
||||
$context->smarty->force_compile = (int)(self::$_forceCompile);
|
||||
if (isset(self::$_caching))
|
||||
$smarty->caching = (int)(self::$_caching);
|
||||
$context->smarty->caching = (int)(self::$_caching);
|
||||
}
|
||||
|
||||
public static function isCallable($function)
|
||||
|
||||
Reference in New Issue
Block a user