From cf980aeb89233a46b9258d430c288efaa37b6b44 Mon Sep 17 00:00:00 2001 From: stephaniepinet Date: Thu, 5 Dec 2013 11:01:50 +0100 Subject: [PATCH 1/7] Update CHANGELOG.txt --- CHANGELOG.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 57daada08..06373ecc5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,7 +5,7 @@ allow to create a customer in admin panel translation is implemented : - I18n directory in template or module. - - multiple extensions are available. We choose to used php but you can use other. + - multiple extensions are available. We choose to use php but you can use other. - You can translate your template or module from the admin. - Admin hook exists. With this hooks, a module can insert code in admin pages + Admin hooks exist. With this hooks, a module can insert code in admin pages From e262bbc9ea23664a6240afc1f1aad98f341a93a7 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 5 Dec 2013 12:57:28 +0100 Subject: [PATCH 2/7] Added config variable titles --- install/insert.sql | 47 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/install/insert.sql b/install/insert.sql index 86fe7847b..5a90a8284 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -5,13 +5,12 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`date_format`,`time_format (4, 'Italiano', 'it', 'it_IT', '', 'd/m/Y', 'H:i:s', 'd/m/y H:i:s', ',', ' ', '2', '0', NOW(), NOW()); INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES -('session_config.default', '1', 1, 1, NOW(), NOW()), -('verifyStock', '1', 0, 0, NOW(), NOW()), +('session_config.handlers', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler', 0, 0, NOW(), NOW()), +('check-available-stock', '1', 0, 0, NOW(), NOW()), ('active-front-template', 'default', 0, 0, NOW(), NOW()), ('active-admin-template', 'default', 0, 0, NOW(), NOW()), ('active-pdf-template', 'default', 0, 0, NOW(), NOW()), ('active-mail-template', 'default', 0, 0, NOW(), NOW()), -('default_lang_without_translation', '1', 1, 1, NOW(), NOW()), ('rewriting_enable', '0', 0, 0, NOW(), NOW()), ('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()), ('default_images_quality_percent', '75', 0, 0, NOW(), NOW()), @@ -23,27 +22,55 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat ('document_cache_dir_from_web_root', 'cache/documents', 0, 0, NOW(), NOW()), ('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()), ('page_not_found_view', '404.html', 0, 0, NOW(), NOW()), -('passed_url_view', 'passed-url', 0, 0, NOW(), NOW()), +('obsolete_rewriten_url_view', 'obsolete-rewritten-url', 0, 0, NOW(), NOW()), ('use_tax_free_amounts', 0, 0, 0, NOW(), NOW()), ('process_assets', '1', 0, 0, NOW(), NOW()), ('thelia_admin_remember_me_cookie_name', 'tarmcn', 0, 0, NOW(), NOW()), ('thelia_admin_remember_me_cookie_expiration', 2592000, 0, 0, NOW(), NOW()), ('thelia_customer_remember_me_cookie_name', 'tcrmcn', 0, 0, NOW(), NOW()), ('thelia_customer_remember_me_cookie_expiration', 31536000, 0, 0, NOW(), NOW()), -('session_config.handlers', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler', 0, 0, NOW(), NOW()), -('store_name','', 0, 1, NOW(), NOW()), -('store_email','', 0, 1, NOW(), NOW()), ('url_site','', 0, 0, NOW(), NOW()), -('one_domain_foreach_lang','0', 1, 1, NOW(), NOW()), ('pdf_invoice_file', 'invoice', 0, 0, NOW(), NOW()), ('pdf_delivery_file', 'delivery', 0, 0, NOW(), NOW()), +('session_config.default', '1', 1, 1, NOW(), NOW()), +('default_lang_without_translation', '1', 1, 1, NOW(), NOW()), +('store_name','', 0, 1, NOW(), NOW()), +('store_email','', 0, 1, NOW(), NOW()), +('one_domain_foreach_lang','0', 1, 1, NOW(), NOW()), ('thelia_version','2.0.0-beta1', 1, 1, NOW(), NOW()), ('thelia_major_version','2', 1, 1, NOW(), NOW()), ('thelia_minus_version','0', 1, 1, NOW(), NOW()), ('thelia_release_version','0', 1, 1, NOW(), NOW()), -('thelia_extra_version','beta1', 1, 1, NOW(), NOW()) -; +('thelia_extra_version','beta1', 1, 1, NOW(), NOW()); +INSERT INTO `config_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES +(1, 'en_US', 'Class name of the session handler', NULL, NULL, NULL), +(2, 'en_US', 'Check available product stock (1) or ignore it (0) when displaying and changing ordered quantity', NULL, NULL, NULL), +(3, 'en_US', 'Name of the active front-office template', NULL, NULL, NULL), +(4, 'en_US', 'Name of the active back-office template', NULL, NULL, NULL), +(5, 'en_US', 'Name of the active PDF template', NULL, NULL, NULL), +(6, 'en_US', 'Name of the active mailing template', NULL, NULL, NULL), +(7, 'en_US', 'Enable (1) or disable (0) URL rewriting', NULL, NULL, NULL), +(8, 'en_US', 'Name of the graphic driver used by the Imagine library (see https://imagine.readthedocs.org)', NULL, NULL, NULL), +(9, 'en_US', 'The default quality (in %) of the generated images', NULL, NULL, NULL), +(10, 'en_US', 'How original (full resolution) images are delivered in the web space (symlink or copy)', NULL, NULL, NULL), +(11, 'en_US', 'How document files are delivered in the web space (symlink or copy)', NULL, NULL, NULL), +(12, 'en_US', 'Path to the directory where images are stored', NULL, NULL, NULL), +(13, 'en_US', 'Path to the directory where documents are stored', NULL, NULL, NULL), +(14, 'en_US', 'The path to the image cache directory in the web space', NULL, NULL, NULL), +(15, 'en_US', 'The path to the document cache directory in the web space', NULL, NULL, NULL), +(16, 'en_US', 'The URL to update exchange rates', NULL, NULL, NULL), +(17, 'en_US', 'File name of the 404 (not found) view in the current template (with extension, e.g. 404.html)', NULL, NULL, NULL), +(18, 'en_US', 'Name of the template view returned when an obsolete (or inactive) product URL is invoked', NULL, NULL, NULL), +(19, 'en_US', 'Display and process prices with (0) or without (1) taxes.', NULL, NULL, NULL), +(20, 'en_US', 'Compile templates assets automatically upon asset source change (1 = yes, 0 = no)', NULL, NULL, NULL), +(21, 'en_US', '"Remember me" cookie name for administration users', NULL, NULL, NULL), +(22, 'en_US', '"Remember me" cookie expiration time, in seconds, for administration users', NULL, NULL, NULL), +(23, 'en_US', '"Remember me" cookie name for customer users', NULL, NULL, NULL), +(24, 'en_US', '"Remember me" cookie expiration time, in seconds, for customer users', NULL, NULL, NULL), +(25, 'en_US', 'Base URL of the shop (e.g. http://www.yourshopdomain.com)', NULL, NULL, NULL), +(26, 'en_US', 'Name of the invoice view in the current PDF template (without extension)', NULL, NULL, NULL), +(27, 'en_US', 'Name of the delivery view in the current PDF template (without extension)', NULL, NULL, NULL); INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES (1, 'TheliaDebugBar', 1, 1, 1, 'TheliaDebugBar\\TheliaDebugBar', NOW(), NOW()), From 97a8d6d3bfd892287b5883df40239545b9c77da5 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 5 Dec 2013 12:57:47 +0100 Subject: [PATCH 3/7] Fixed button wrapping when in tight spaces (e.g, tables) --- .../default/assets/less/thelia/thelia.less | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/templates/backOffice/default/assets/less/thelia/thelia.less b/templates/backOffice/default/assets/less/thelia/thelia.less index 2189b9307..41b37d4ca 100755 --- a/templates/backOffice/default/assets/less/thelia/thelia.less +++ b/templates/backOffice/default/assets/less/thelia/thelia.less @@ -138,17 +138,6 @@ } } - .Blocmoncompte { - float: right; - margin: 0px; - padding: 0px; - margin-top: 35px; - - color: white; - font-size: 13px; - text-shadow: 0px 1px 0px rgba(0,0,0,0.8); - } - dt { float: left; margin-right: 15px; @@ -172,6 +161,16 @@ width: 100%; } +.btn-group { + white-space: nowrap; // prevent buttons from wrapping when in tight spaces (e.g., the table on the tests page) + > .btn { + float: inherit; + } + > .btn + .btn { + margin-left: -4px; + } +} + // -- Login form -------------------------------------------------------------- .form-signin { From 0a7b8f05d0f2fb66ce3c84fdcafa68dd62e86c28 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 5 Dec 2013 13:01:09 +0100 Subject: [PATCH 4/7] Added checkAvailableStock(), changed getPassedUrlView() to getObsoleteRewrittenUrlView() --- core/lib/Thelia/Model/ConfigQuery.php | 9 +++++++-- core/lib/Thelia/Model/Product.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Model/ConfigQuery.php b/core/lib/Thelia/Model/ConfigQuery.php index e2f6a3975..e34ae5e16 100755 --- a/core/lib/Thelia/Model/ConfigQuery.php +++ b/core/lib/Thelia/Model/ConfigQuery.php @@ -77,9 +77,9 @@ class ConfigQuery extends BaseConfigQuery { return self::read("page_not_found_view", '404.html'); } - public static function getPassedUrlView() + public static function getObsoleteRewrittenUrlView() { - return self::read('passed_url_view', 'passed-url'); + return self::read('obsolete_rewriten_url_view', 'obsolete-rewritten-url'); } public static function useTaxFreeAmounts() @@ -87,6 +87,11 @@ class ConfigQuery extends BaseConfigQuery { return self::read('use_tax_free_amounts', 'default') == 1; } + public static function checkAvailableStock() + { + return self::read('check-available-stock', 1) != 0; + } + /* smtp config */ public static function isSmtpEnable() { diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 1b3f1eefa..f2e838be2 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -267,7 +267,7 @@ class Product extends BaseProduct ->filterByView($this->getRewrittenUrlViewName()) ->filterByViewId($this->getId()) ->update(array( - "View" => ConfigQuery::getPassedUrlView() + "View" => ConfigQuery::getObsoleteRewrittenUrlView() )); $this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this)); } From 8e56fcc651721a1578b48bd820d6a19b30e8c114 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 5 Dec 2013 13:01:43 +0100 Subject: [PATCH 5/7] Fixed exception when log file could not be renamed --- core/lib/Thelia/Log/Destination/TlogDestinationFile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php index 5d9089ebe..80aa3ec25 100755 --- a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php @@ -78,10 +78,10 @@ class TlogDestinationFile extends AbstractTlogDestination } while (file_exists($file_path_bk)); - rename($file_path, $file_path_bk); + @rename($file_path, $file_path_bk); - touch($file_path); - chmod($file_path, 0666); + @touch($file_path); + @chmod($file_path, 0666); } $this->fh = fopen($file_path, $mode); From de0542b33c57cd5a4d364c12f68ffa2d2098815f Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 5 Dec 2013 13:02:13 +0100 Subject: [PATCH 6/7] Changed direct accesses to verifyStok by calls to checkAvailableStock --- core/lib/Thelia/Form/CartAdd.php | 2 +- core/lib/Thelia/Model/Cart.php | 2 +- core/lib/Thelia/Model/CartItem.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php index 59d13765d..98e12acde 100755 --- a/core/lib/Thelia/Form/CartAdd.php +++ b/core/lib/Thelia/Form/CartAdd.php @@ -141,7 +141,7 @@ class CartAdd extends BaseForm ->filterByProductId($data["product"]) ->findOne(); - if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) { + if ($productSaleElements->getQuantity() < $value && ConfigQuery::checkAvailableStock()) { $context->addViolation("quantity value is not valid"); } } diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 36b604258..c1f28bc3d 100755 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -36,7 +36,7 @@ class Cart extends BaseCart if ($product && $productSaleElements && $product->getVisible() == 1 && - ($productSaleElements->getQuantity() > $cartItem->getQuantity() || ! ConfigQuery::read("verifyStock", 1))) + ($productSaleElements->getQuantity() > $cartItem->getQuantity() || ! ConfigQuery::checkAvailableStock())) { $item = new CartItem(); diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 5432bd1ab..ef72c070c 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -51,7 +51,7 @@ class CartItem extends BaseCartItem $value = $currentQuantity; } - if(ConfigQuery::read("verifyStock", 1) == 1) + if(ConfigQuery::checkAvailableStock()) { $productSaleElements = $this->getProductSaleElements(); @@ -75,7 +75,7 @@ class CartItem extends BaseCartItem $value = $currentQuantity; } - if(ConfigQuery::read("verifyStock", 1) == 1) + if(ConfigQuery::checkAvailableStock()) { $productSaleElements = $this->getProductSaleElements(); From 5857c07ef0b70a6fd5addb25cb6741dd3bd863ad Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 5 Dec 2013 15:57:56 +0100 Subject: [PATCH 7/7] Fixed issue 118 --- core/lib/Thelia/Action/Product.php | 4 ++++ core/lib/Thelia/Action/ProductSaleElement.php | 2 +- .../Controller/Admin/ProductController.php | 2 +- .../Event/Product/ProductSetTemplateEvent.php | 20 +++++++++++++++---- .../Thelia/Core/Template/Loop/Attribute.php | 7 +++++++ .../lib/Thelia/Core/Template/Loop/Feature.php | 7 +++++++ core/lib/Thelia/Model/Product.php | 2 +- 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index f51d95f28..4fccbf3f6 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -282,8 +282,12 @@ class Product extends BaseAction implements EventSubscriberInterface $product->setTemplateId($template_id)->save($con); + // Create a new default product sale element + $product->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true); + // Store all the stuff ! $con->commit(); + } catch (\Exception $ex) { $con->rollback(); diff --git a/core/lib/Thelia/Action/ProductSaleElement.php b/core/lib/Thelia/Action/ProductSaleElement.php index 9c40025d8..cad3be374 100644 --- a/core/lib/Thelia/Action/ProductSaleElement.php +++ b/core/lib/Thelia/Action/ProductSaleElement.php @@ -67,7 +67,7 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface if ($salesElement == null) { // Create a new default product sale element - $salesElement = $event->getProduct()->createDefaultProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true); + $salesElement = $event->getProduct()->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true); } else { // This (new) one is the default $salesElement->setIsDefault(true)->save($con); diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 9aa2d279e..d415317c0 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -652,7 +652,7 @@ class ProductController extends AbstractCrudController $this->dispatch( TheliaEvents::PRODUCT_SET_TEMPLATE, - new ProductSetTemplateEvent($product, $template_id) + new ProductSetTemplateEvent($product, $template_id, $this->getCurrentEditionCurrency()->getId()) ); } diff --git a/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php index 1847ca48f..af28ca73f 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php @@ -22,18 +22,19 @@ /*************************************************************************************/ namespace Thelia\Core\Event\Product; - use Thelia\Model\Product; class ProductSetTemplateEvent extends ProductEvent { - public $template_id = null; + protected $template_id = null; + protected $currency_id = 0; - public function __construct(Product $product = null, $template_id) + public function __construct(Product $product = null, $template_id, $currency_id) { parent::__construct($product); $this->template_id = $template_id; + $this->currency_id = $currency_id; } public function getTemplateId() @@ -48,4 +49,15 @@ class ProductSetTemplateEvent extends ProductEvent return $this; } -} + public function getCurrencyId() + { + return $this->currency_id; + } + + public function setCurrencyId($currency_id) + { + $this->currency_id = $currency_id; + + return $this; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index 97b540f96..2225ced66 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -120,6 +120,12 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface if (! is_null($tpl_id)) $template[] = $tpl_id; } } + + // franck@cqfdev.fr - 05/12/2013 : if the given product has no template + // or if the product cannot be found, do not return anything. + if (empty($template)) { + return null; + } } if (! empty($template)) { @@ -175,6 +181,7 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface break; } } +echo "s=".$search->toString(); return $search; diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 6f7f12c71..74d165562 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -110,6 +110,7 @@ class Feature extends BaseI18nLoop implements PropelSearchLoopInterface $this->useFeaturePosition = true; if (null !== $product) { + // Find all template assigned to the products. $products = ProductQuery::create()->findById($product); @@ -125,6 +126,12 @@ class Feature extends BaseI18nLoop implements PropelSearchLoopInterface if (! is_null($tpl_id)) $template[] = $tpl_id; } } + + // franck@cqfdev.fr - 05/12/2013 : if the given product has no template + // or if the product cannot be found, do not return anything. + if (empty($template)) { + return null; + } } if (! empty($template)) { diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index f2e838be2..3855c46c1 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -202,7 +202,7 @@ class Product extends BaseProduct ->save($con) ; - // Create an empty product price in the default currency + // Create an empty product price in the provided currency $product_price = new ProductPrice(); $product_price