[-] FO: Fix: many fixes - domain for cookies with different url for ssl / add to cart button for minimal quantities with product attributes

This commit is contained in:
Rémi Gaillard
2012-11-20 19:05:21 +01:00
parent 91a4a4955e
commit 3e2de4986b
11 changed files with 87 additions and 23 deletions
+1 -1
View File
@@ -608,7 +608,7 @@ class CategoryCore extends ObjectModel
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`,
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`id_product_attribute`, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image`,
il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
+1 -1
View File
@@ -92,7 +92,7 @@ class CookieCore
return false;
if (!strstr(Tools::getHttpHost(false, false), '.'))
return false;
$domain = false;
if ($shared_urls !== null)
{
+11 -1
View File
@@ -385,6 +385,15 @@ class DispatcherCore
{
$context = Context::getContext();
// Load custom routes from modules
$modules_routes = Hook::exec('moduleRoutes', array(), null, true, false);
if (is_array($modules_routes) && count($modules_routes))
foreach($modules_routes as $module_route)
foreach($module_route as $route => $route_details)
if (array_key_exists('controller', $route_details) && array_key_exists('rule', $route_details)
&& array_key_exists('keywords', $route_details) && array_key_exists('params', $route_details))
$this->addRoute($route, $route_details['rule'], $route_details['controller'], null, $route_details['keywords'], $route_details['params']);
// Set default routes
foreach (Language::getLanguages() as $lang)
foreach ($this->default_routes as $id => $route)
@@ -579,7 +588,8 @@ class DispatcherCore
if (!array_key_exists($key, $params))
die('Dispatcher::createUrl() miss required parameter "'.$key.'" for route "'.$route_id.'"');
$query_params[$this->default_routes[$route_id]['keywords'][$key]['param']] = $params[$key];
if (isset($this->default_routes[$route_id]))
$query_params[$this->default_routes[$route_id]['keywords'][$key]['param']] = $params[$key];
}
// Build an url which match a route
+17 -11
View File
@@ -358,7 +358,7 @@ class HookCore extends ObjectModel
* @param int $id_module Execute hook for this module only
* @return string modules output
*/
public static function exec($hook_name, $hook_args = array(), $id_module = null)
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true)
{
// Check arguments validity
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
@@ -397,11 +397,14 @@ class HookCore extends ObjectModel
continue;
// Check permissions
$exceptions = $moduleInstance->getExceptions($array['id_hook']);
if (in_array(Dispatcher::getInstance()->getController(), $exceptions))
continue;
if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee))
continue;
if ($check_exceptions)
{
$exceptions = $moduleInstance->getExceptions($array['id_hook']);
if (in_array(Dispatcher::getInstance()->getController(), $exceptions))
continue;
if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee))
continue;
}
// Check which / if method is callable
$hook_callable = is_callable(array($moduleInstance, 'hook'.$hook_name));
@@ -416,19 +419,22 @@ class HookCore extends ObjectModel
else if ($hook_retro_callable)
$display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args);
// Live edit
if ($array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
if ($array_return && $array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
{
$live_edit = true;
$output .= self::wrapLiveEdit($display, $moduleInstance, $array['id_hook']);
}
else if ($array_return)
$output[] = $display;
else
$output .= $display;
}
}
// Return html string
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\'); </script>
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');
if ($array_return)
return $output;
else
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\'); </script>
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');// Return html string
}
public static function wrapLiveEdit($display, $moduleInstance, $id_hook)
-4
View File
@@ -322,10 +322,7 @@ class LinkCore
// If the module has its own route ... just use it !
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang))
{
unset($params['module']);
return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
}
else
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow);
}
@@ -413,7 +410,6 @@ class LinkCore
$request = urlencode($request);
parse_str($request, $request);
}
unset($request['controller']);
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request);
$url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
+1 -1
View File
@@ -325,7 +325,7 @@ class MediaCore
$ui_tmp[] = Media::getJqueryUIPath($dependency, $theme, false);
if (self::$jquery_ui_dependencies[$dependency]['theme'])
$dep_css = Media::getCSSPath($folder.'themes/'.$theme.'/jquery.'.$dependency.'.css');
if (!empty($dep_css) || $dep_css)
if (isset($dep_css) && (!empty($dep_css) || $dep_css))
$ui_path['css'] = array_merge($ui_path['css'], $dep_css);
}
}
+4 -2
View File
@@ -3191,7 +3191,8 @@ class ProductCore extends ObjectModel
{
if (!array_key_exists($row['id_product'].'-'.$id_lang, self::$_frontFeaturesCache))
self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang] = array();
self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][] = $row;
if (!isset(self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][$row['id_product']]))
self::$_frontFeaturesCache[$row['id_product'].'-'.$id_lang][$row['id_product']] = $row;
}
}
@@ -3588,8 +3589,9 @@ class ProductCore extends ObjectModel
$cache_key = $row['id_product'].'-'.$row['id_product_attribute'].'-'.$id_lang.'-'.(int)$usetax;
if (isset($row['id_product_pack']))
$cache_key .= '-pack'.$row['id_product_pack'];
if (isset(self::$producPropertiesCache[$cache_key]))
return self::$producPropertiesCache[$cache_key];
return array_merge($row, self::$producPropertiesCache[$cache_key]);
// Datas
$row['category'] = Category::getLinkRewrite((int)$row['id_category_default'], (int)$id_lang);
+1 -1
View File
@@ -240,7 +240,7 @@ class SupplierCore extends ObjectModel
$order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`';
}
$alias = '';
if ($order_by == 'price')
if (in_array($order_by, array('price', 'date_add', 'date_upd')))
$alias = 'product_shop.';
elseif ($order_by == 'id_product')
$alias = 'p.';
+8 -1
View File
@@ -110,6 +110,7 @@ Context::getContext()->country = $defaultCountry;
/* Instantiate cookie */
$cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : 1)* 3600));
if (defined('_PS_ADMIN_DIR_'))
$cookie = new Cookie('psAdmin', '', $cookieLifetime);
else
@@ -117,7 +118,13 @@ else
if (Context::getContext()->shop->getGroup()->share_order)
$cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime, Context::getContext()->shop->getUrlsSharedCart());
else
$cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);
{
$domains = null;
if(Context::getContext()->shop->domain != Context::getContext()->shop->domain_ssl)
$domains = array(Context::getContext()->shop->domain_ssl, Context::getContext()->shop->domain);
$cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime, $domains);
}
}
Context::getContext()->cookie = $cookie;
+7
View File
@@ -183,6 +183,13 @@ class CategoryControllerCore extends FrontController
else
// Pagination must be call after "getProducts"
$this->pagination($this->nbProducts);
foreach ($this->cat_products as &$product)
{
if ($product['id_product_attribute'])
$product['minimal_quantity'] = $product['product_attribute_minimal_quantity'];
}
$this->context->smarty->assign('nb_products', $this->nbProducts);
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;