Merge branch 'master' into modules

This commit is contained in:
Franck Allimant
2013-12-06 17:16:14 +01:00
316 changed files with 4064 additions and 1708 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -115,6 +115,8 @@ class Category extends BaseCategory
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this));
}
}

View File

@@ -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()
{

View File

@@ -148,6 +148,8 @@ class Content extends BaseContent
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONTENT, new ContentEvent($this));
}
}

View File

@@ -100,6 +100,8 @@ class Folder extends BaseFolder
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this));
}
}

View File

@@ -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
@@ -263,12 +263,8 @@ class Product extends BaseProduct
*/
public function postDelete(ConnectionInterface $con = null)
{
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getPassedUrlView()
));
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this));
}
}

View File

@@ -29,18 +29,19 @@ use Thelia\Exception\UrlRewritingException;
use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\RewritingUrl;
use Thelia\Tools\URL;
use Thelia\Model\ConfigQuery;
/**
* A trait for managing Rewriten URLs from model classes
* A trait for managing Rewritten URLs from model classes
*/
trait UrlRewritingTrait {
/**
* @returns string the view name of the rewriten object (e.g., 'category', 'product')
* @returns string the view name of the rewritten object (e.g., 'category', 'product')
*/
protected abstract function getRewrittenUrlViewName();
/**
* Get the object URL for the given locale, rewriten if rewriting is enabled.
* Get the object URL for the given locale, rewritten if rewriting is enabled.
*
* @param string $locale a valid locale (e.g. en_US)
*/
@@ -53,7 +54,7 @@ trait UrlRewritingTrait {
}
/**
* Generate a rewriten URL from the object title, and store it in the rewriting table
* Generate a rewritten URL from the object title, and store it in the rewriting table
*
* @param string $locale a valid locale (e.g. en_US)
*/
@@ -112,7 +113,7 @@ trait UrlRewritingTrait {
}
/**
* return the rewriten URL for the given locale
* return the rewritten URL for the given locale
*
* @param string $locale a valid locale (e.g. en_US)
* @return null
@@ -137,7 +138,19 @@ trait UrlRewritingTrait {
}
/**
* Set the rewriten URL for the given locale
* Mark the current URL as obseolete
*/
public function markRewritenUrlObsolete() {
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getObsoleteRewrittenUrlView()
));
}
/**
* Set the rewritten URL for the given locale
*
* @param string $locale a valid locale (e.g. en_US)
* @param $url the wanted url