Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development

This commit is contained in:
Jerome Nadaud
2013-10-30 16:48:26 +01:00
6 changed files with 39 additions and 27 deletions
+12
View File
@@ -1593,6 +1593,18 @@ abstract class ModuleCore
return Cache::retrieve('Module::isInstalled'.$module_name); return Cache::retrieve('Module::isInstalled'.$module_name);
} }
public function isEnabledForShopContext()
{
$shop_list = Shop::getContextListShopID();
return (bool)Db::getInstance()->getValue('
SELECT COUNT(*) n
FROM `'._DB_PREFIX_.'module_shop`
WHERE id_module='.(int)$this->id.' AND id_shop IN ('.implode(',', array_map('intval', Shop::getContextListShopID())).')
GROUP BY id_module
HAVING n='.(int)count(Shop::getContextListShopID())
);
}
public static function isEnabled($module_name) public static function isEnabled($module_name)
{ {
if (!Cache::isStored('Module::isEnabled'.$module_name)) if (!Cache::isStored('Module::isEnabled'.$module_name))
+1 -1
View File
@@ -799,7 +799,7 @@ class ShopCore extends ObjectModel
{ {
if (Shop::getContext() == Shop::CONTEXT_SHOP) if (Shop::getContext() == Shop::CONTEXT_SHOP)
$list = ($share) ? Shop::getSharedShops(Shop::getContextShopID(), $share) : array(Shop::getContextShopID()); $list = ($share) ? Shop::getSharedShops(Shop::getContextShopID(), $share) : array(Shop::getContextShopID());
else if (Shop::getContext() == Shop::CONTEXT_GROUP) elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
$list = Shop::getShops(true, Shop::getContextShopGroupID(), true); $list = Shop::getShops(true, Shop::getContextShopGroupID(), true);
else else
$list = Shop::getShops(true, null, true); $list = Shop::getShops(true, null, true);
+21 -21
View File
@@ -525,11 +525,11 @@ class AdminImportControllerCore extends AdminController
if (isset($this->context->cookie->iso_lang_selected) && $this->context->cookie->iso_lang_selected) if (isset($this->context->cookie->iso_lang_selected) && $this->context->cookie->iso_lang_selected)
$id_lang_selected = (int)Language::getIdByIso(base64_decode($this->context->cookie->iso_lang_selected)); $id_lang_selected = (int)Language::getIdByIso(base64_decode($this->context->cookie->iso_lang_selected));
$separator_selected = $this->multiple_value_separator; $separator_selected = $this->separator;
if (isset($this->context->cookie->separator_selected) && $this->context->cookie->separator_selected) if (isset($this->context->cookie->separator_selected) && $this->context->cookie->separator_selected)
$separator_selected = base64_decode($this->context->cookie->separator_selected); $separator_selected = base64_decode($this->context->cookie->separator_selected);
$multiple_value_separator_selected = $this->separator; $multiple_value_separator_selected = $this->multiple_value_separator;
if (isset($this->context->cookie->multiple_value_separator_selected) && $this->context->cookie->multiple_value_separator_selected) if (isset($this->context->cookie->multiple_value_separator_selected) && $this->context->cookie->multiple_value_separator_selected)
$multiple_value_separator_selected = base64_decode($this->context->cookie->multiple_value_separator_selected); $multiple_value_separator_selected = base64_decode($this->context->cookie->multiple_value_separator_selected);
@@ -1989,9 +1989,6 @@ class AdminImportControllerCore extends AdminController
$addresses = $customer->getAddresses((int)Configuration::get('PS_LANG_DEFAULT')); $addresses = $customer->getAddresses((int)Configuration::get('PS_LANG_DEFAULT'));
} }
if (!isset($customer_groups) || count($customer_groups) == 0)
$customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
// Group Importation // Group Importation
if (isset($info['group']) && !empty($info['group'])) if (isset($info['group']) && !empty($info['group']))
{ {
@@ -2064,6 +2061,7 @@ class AdminImportControllerCore extends AdminController
//set temporally for validate field //set temporally for validate field
$customer->id_shop = $default_shop->id; $customer->id_shop = $default_shop->id;
$customer->id_shop_group = $default_shop->getGroup()->id; $customer->id_shop_group = $default_shop->getGroup()->id;
$customer_groups[] = $customer->id_default_group;
$customer_groups = array_flip(array_flip($customer_groups)); $customer_groups = array_flip(array_flip($customer_groups));
$res = true; $res = true;
if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true &&
@@ -2596,34 +2594,32 @@ class AdminImportControllerCore extends AdminController
$date_delivery_expected = pSQL($info['date_delivery_expected']); $date_delivery_expected = pSQL($info['date_delivery_expected']);
$discount_rate = (float)$info['discount_rate']; $discount_rate = (float)$info['discount_rate'];
$is_template = (bool)$info['is_template']; $is_template = (bool)$info['is_template'];
$error = '';
// checks parameters // checks parameters
if (!Supplier::supplierExists($id_supplier)) if (!Supplier::supplierExists($id_supplier))
$this->errors[] = sprintf($this->l('Supplier ID (%d) is not valid (at line %d).'), $id_supplier, $current_line + 1); $error = sprintf($this->l('Supplier ID (%d) is not valid (at line %d).'), $id_supplier, $current_line + 1);
if (!Language::getLanguage($id_lang)) if (!Language::getLanguage($id_lang))
$this->errors[] = sprintf($this->l('Lang ID (%d) is not valid (at line %d).'), $id_lang, $current_line + 1); $error = sprintf($this->l('Lang ID (%d) is not valid (at line %d).'), $id_lang, $current_line + 1);
if (!Warehouse::exists($id_warehouse)) if (!Warehouse::exists($id_warehouse))
$this->errors[] = sprintf($this->l('Warehouse ID (%d) is not valid (at line %d).'), $id_warehouse, $current_line + 1); $error = sprintf($this->l('Warehouse ID (%d) is not valid (at line %d).'), $id_warehouse, $current_line + 1);
if (!Currency::getCurrency($id_currency)) if (!Currency::getCurrency($id_currency))
$this->errors[] = sprintf($this->l('Currency ID (%d) is not valid (at line %d).'), $id_currency, $current_line + 1); $error = sprintf($this->l('Currency ID (%d) is not valid (at line %d).'), $id_currency, $current_line + 1);
if (empty($supply_order->reference) && SupplyOrder::exists($reference)) if (empty($supply_order->reference) && SupplyOrder::exists($reference))
$this->errors[] = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1); $error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1);
if (!empty($supply_order->reference) && ($supply_order->reference != $reference && SupplyOrder::exists($reference))) if (!empty($supply_order->reference) && ($supply_order->reference != $reference && SupplyOrder::exists($reference)))
$this->errors[] = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1); $error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1);
if (!Validate::isDateFormat($date_delivery_expected)) if (!Validate::isDateFormat($date_delivery_expected))
$this->errors[] = sprintf($this->l('Date (%s) is not valid (at line %d). Format: %s.'), $date_delivery_expected, $error = sprintf($this->l('Date (%s) is not valid (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD'));
$current_line + 1, $this->l('YYYY-MM-DD'));
else if (new DateTime($date_delivery_expected) <= new DateTime('yesterday')) else if (new DateTime($date_delivery_expected) <= new DateTime('yesterday'))
$this->errors[] = sprintf($this->l('Date (%s) cannot be in the past (at line %d). Format: %s.'), $date_delivery_expected, $error = sprintf($this->l('Date (%s) cannot be in the past (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD'));
$current_line + 1, $this->l('YYYY-MM-DD'));
if ($discount_rate < 0 || $discount_rate > 100) if ($discount_rate < 0 || $discount_rate > 100)
$this->errors[] = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $error = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $current_line + 1, $this->l('Format: Between 0 and 100'));
$current_line + 1, $this->l('Format: Between 0 and 100'));
if ($supply_order->id > 0 && !$supply_order->isEditable()) if ($supply_order->id > 0 && !$supply_order->isEditable())
$this->errors[] = sprintf($this->l('Supply Order (%d) is not editable (at line %d).'), $supply_order->id, $current_line + 1); $error = sprintf($this->l('Supply Order (%d) is not editable (at line %d).'), $supply_order->id, $current_line + 1);
// if no errors, sets supply order // if no errors, sets supply order
if (empty($this->errors)) if (empty($error))
{ {
// adds parameters // adds parameters
$info['id_ref_currency'] = (int)Currency::getDefaultCurrency()->id; $info['id_ref_currency'] = (int)Currency::getDefaultCurrency()->id;
@@ -2640,8 +2636,10 @@ class AdminImportControllerCore extends AdminController
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order); AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order);
// updatesd($supply_order); // updatesd($supply_order);
$res = true; $res = true;
if ($supply_order->id > 0)
if ((int)$supply_order->id && ($supply_order->exists((int)$supply_order->id) || $supply_order->exists($supply_order->reference)))
$res &= $supply_order->update(); $res &= $supply_order->update();
else else
$res &= $supply_order->add(); $res &= $supply_order->add();
@@ -2650,6 +2648,8 @@ class AdminImportControllerCore extends AdminController
if (!$res) if (!$res)
$this->errors[] = sprintf($this->l('Supply Order could not be saved (at line %d).'), $current_line + 1); $this->errors[] = sprintf($this->l('Supply Order could not be saved (at line %d).'), $current_line + 1);
} }
else
$this->errors[] = $error;
} }
// closes // closes
+1 -1
View File
@@ -714,7 +714,7 @@ class AdminModulesControllerCore extends AdminController
$activateOnclick = 'onclick="location.href = \''.$this->getCurrentUrl('enable').'&enable=\'+(($(this).attr(\'checked\')) ? 1 : 0)"'; $activateOnclick = 'onclick="location.href = \''.$this->getCurrentUrl('enable').'&enable=\'+(($(this).attr(\'checked\')) ? 1 : 0)"';
$toolbar .= '<tr> $toolbar .= '<tr>
<th colspan="4"> <th colspan="4">
<input type="checkbox" name="activateModule" value="1" '.(($module->active) ? 'checked="checked"' : '').' '.$activateOnclick.' /> '.$this->l('Activate module for').' '; <input type="checkbox" name="activateModule" value="1" '.($module->isEnabledForShopContext() ? 'checked="checked"' : '').' '.$activateOnclick.' /> '.$this->l('Activate module for').' ';
if (Shop::getContext() == Shop::CONTEXT_SHOP) if (Shop::getContext() == Shop::CONTEXT_SHOP)
$toolbar .= 'shop <b>'.$this->context->shop->name.'</b>'; $toolbar .= 'shop <b>'.$this->context->shop->name.'</b>';
elseif (Shop::getContext() == Shop::CONTEXT_GROUP) elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
+3 -3
View File
@@ -1,3 +1,3 @@
id;Active (0/1);Gender ID (Mr=1, Ms=2, else 9);E-mail*;Password*;Birthday;Lastname*;Firstname*;Newletter (0/1);Opt-in (0/1) id;Active (0/1);Gender ID (Mr=1, Ms=2, else 9);E-mail*;Password*;Birthday;Lastname*;Firstname*;Newletter (0/1);Opt-in (0/1);Groups (x,y,z...);Default group ID;ID / Name of shop
1;1;1;johndoe@prestashop.com;#res152EDRF;1987-09-21;Doe;John;1;1 1;1;1;johndoe@prestashop.com;#res152EDRF;1987-09-21;Doe;John;1;1;1,2;1;1
2;1;2;mariedoe@prestashop.com;58@ret26#;1986-10-14;Doe;Marie;0;1 2;1;2;mariedoe@prestashop.com;58@ret26#;1986-10-14;Doe;Marie;0;1;1,3;3;1
1 id Active (0/1) Gender ID (Mr=1, Ms=2, else 9) E-mail* Password* Birthday Lastname* Firstname* Newletter (0/1) Opt-in (0/1) Groups (x,y,z...) Default group ID ID / Name of shop
2 1 1 1 johndoe@prestashop.com #res152EDRF 1987-09-21 Doe John 1 1 1,2 1 1
3 2 1 2 mariedoe@prestashop.com 58@ret26# 1986-10-14 Doe Marie 0 1 1,3 3 1
+1 -1
View File
@@ -27,7 +27,7 @@
ob_start(); ob_start();
// Check PHP version // Check PHP version
if (version_compare(PHP_VERSION, '5.1.3', '<')) if (version_compare(preg_replace('/[^0-9.]/', '', PHP_VERSION), '5.1.3', '<'))
die('You need at least PHP 5.1.3 to run PrestaShop. Your current PHP version is '.PHP_VERSION); die('You need at least PHP 5.1.3 to run PrestaShop. Your current PHP version is '.PHP_VERSION);
// Generate common constants // Generate common constants