//Merge branch release

This commit is contained in:
vAugagneur
2013-01-02 09:56:20 +01:00
475 changed files with 23768 additions and 22253 deletions
@@ -126,7 +126,7 @@ class AdminCartRulesControllerCore extends AdminController
$this->errors[] = Tools::displayError('Reduction percent must be between 0% and 100%');
if ((int)Tools::getValue('reduction_amount') < 0)
$this->errors[] = Tools::displayError('Reduction amount cannot be lower than 0');
if (Tools::getValue('code') && ($same_code = (int)CartRule::getIdByCode(Tools::getValue('code'))))
if (Tools::getValue('code') && ($same_code = (int)CartRule::getIdByCode(Tools::getValue('code'))) && $same_code != Tools::getValue('id_cart_rule'))
$this->errors[] = sprintf(Tools::displayError('This cart rule code is already used (conflict with cart rule %d)'), $same_code);
}
+1 -1
View File
@@ -462,7 +462,7 @@ class AdminCartsControllerCore extends AdminController
{
$cart_rule = new CartRule();
$cart_rule->code = 'BO_ORDER_'.(int)$this->context->cart->id;
$cart_rule->name = array(Configuration::get('PS_LANG_DEFAULT') => $this->l('Free Shipping'));
$cart_rule->name = array(Configuration::get('PS_LANG_DEFAULT') => $this->l('Free Shipping', 'AdminTab', false, false));
$cart_rule->id_customer = (int)$this->context->cart->id_customer;
$cart_rule->free_shipping = true;
$cart_rule->quantity = 1;
@@ -31,7 +31,6 @@ class AdminCurrenciesControllerCore extends AdminController
$this->table = 'currency';
$this->className = 'Currency';
$this->lang = false;
$this->multishop_context = Shop::CONTEXT_ALL;
$this->fields_list = array(
'id_currency' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
@@ -69,6 +68,9 @@ class AdminCurrenciesControllerCore extends AdminController
);
parent::__construct();
$this->_select .= 'currency_shop.conversion_rate conversion_rate';
$this->_join .= Shop::addSqlAssociation('currency', 'a');
}
public function renderList()
@@ -184,11 +184,13 @@ class AdminCustomersControllerCore extends AdminController
parent::initToolbar();
if (!$this->can_add_customer)
unset($this->toolbar_btn['new']);
else
else if (!$this->display) //display import button only on listing
{
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table,
'desc' => $this->l('Import')
);
}
}
public function initProcess()
+5 -5
View File
@@ -115,7 +115,7 @@ class AdminImagesControllerCore extends AdminController
'PS_PRODUCT_PICTURE_MAX_SIZE' => array(
'title' => $this->l('Maximum size of product pictures'),
'desc' => $this->l('The maximum size of pictures uploadable by customers (in Bytes)'),
'validation' => 'isUnsignedId',
'validation' => 'isUnsignedInt',
'required' => true,
'cast' => 'intval',
'type' => 'text',
@@ -125,7 +125,7 @@ class AdminImagesControllerCore extends AdminController
'PS_PRODUCT_PICTURE_WIDTH' => array(
'title' => $this->l('Product picture width'),
'desc' => $this->l('The maximum width of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'validation' => 'isUnsignedInt',
'required' => true,
'cast' => 'intval',
'type' => 'text',
@@ -135,7 +135,7 @@ class AdminImagesControllerCore extends AdminController
'PS_PRODUCT_PICTURE_HEIGHT' => array(
'title' => $this->l('Product picture height'),
'desc' => $this->l('The maximum height of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'validation' => 'isUnsignedInt',
'required' => true,
'cast' => 'intval',
'type' => 'text',
@@ -369,14 +369,14 @@ class AdminImagesControllerCore extends AdminController
|| !Configuration::updateValue('PS_PNG_QUALITY', Tools::getValue('PS_PNG_QUALITY')))
$this->errors[] = Tools::displayError('Unknown error.');
else
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
return parent::postProcess();
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
else
parent::postProcess();
return parent::postProcess();
}
public static function printEntityActiveIcon($value, $object)
@@ -323,6 +323,10 @@ class AdminLocalizationControllerCore extends AdminController
public function updateOptionPsCurrencyDefault($value)
{
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
/* Set conversion rate of default currency to 1 */
ObjectModel::updateMultishopTable('Currency', array('conversion_rate' => 1), 'a.id_currency');
Currency::refreshCurrencies();
}
}
+7 -2
View File
@@ -68,6 +68,8 @@ class AdminModulesControllerCore extends AdminController
{
parent::__construct();
register_shutdown_function('displayFatalError');
include_once(_PS_ADMIN_DIR_.'/../tools/tar/Archive_Tar.php');
// Set the modules categories
@@ -316,10 +318,13 @@ class AdminModulesControllerCore extends AdminController
//check if it's a real module
foreach($zip_folders as $folder)
if (!in_array($folder, array('.', '..', '.svn', '.git', '__MACOSX')) && !Module::getInstanceByName($folder))
{
$this->errors[] = Tools::displayError('The module '.$folder.' you uploaded is not a module');
$this->recursiveDeleteOnDisk(_PS_MODULE_DIR_.$folder);
}
@unlink($file);
@unlink($tmp_folder);
$this->recursiveDeleteOnDisk($tmp_folder);
if (!count($this->errors) && $success && $redirect)
Tools::redirectAdmin(self::$currentIndex.'&conf=8'.'&token='.$this->token);
}
@@ -53,11 +53,6 @@ class AdminOrderPreferencesControllerCore extends AdminController
)
);
// Tax list
$taxes[] = array('id' => 0, 'name' => $this->l('None'));
foreach (Tax::getTaxes($this->context->language->id) as $tax)
$taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
$this->fields_options = array(
'general' => array(
'title' => $this->l('General'),
@@ -140,14 +135,14 @@ class AdminOrderPreferencesControllerCore extends AdminController
'cast' => 'floatval',
'type' => 'price'
),
'PS_GIFT_WRAPPING_TAX' => array(
'PS_GIFT_WRAPPING_TAX_RULES_GROUP' => array(
'title' => $this->l('Gift-wrapping tax'),
'desc' => $this->l('Set a tax for gift-wrapping'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $taxes,
'identifier' => 'id'
'list' => array_merge(array(array('id_tax_rules_group' => 0, 'name' => $this->l('None'))), TaxRulesGroup::getTaxRulesGroups(true)),
'identifier' => 'id_tax_rules_group'
),
'PS_RECYCLABLE_PACK' => array(
'title' => $this->l('Offer recycled packaging'),
+16 -8
View File
@@ -1345,15 +1345,23 @@ class AdminProductsControllerCore extends AdminController
{
if (($id_image = Tools::getValue('id_image')) && ($id_shop = (int)Tools::getValue('id_shop')))
if (Tools::getValue('active') == 'true')
$res = Db::getInstance()->execute(
'INSERT INTO '._DB_PREFIX_.'image_shop (`id_image`, `id_shop`)
VALUES('.(int)$id_image.', '.(int)$id_shop.')
');
$res = Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'image_shop (`id_image`, `id_shop`) VALUES('.(int)$id_image.', '.(int)$id_shop.')');
else
$res = Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'image_shop
WHERE `id_image`='.(int)$id_image.' && `id_shop`='.(int)$id_shop
);
$res = Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'image_shop WHERE `id_image` = '.(int)$id_image.' AND `id_shop` = '.(int)$id_shop);
// Clean covers in image table
$count_cover_image = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'image i INNER JOIN '._DB_PREFIX_.'image_shop is ON (i.id_image = is.id_image AND is.id_shop = '.(int)$id_shop.') WHERE i.cover = 1');
if ($count_cover_image < 1)
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'image i, '._DB_PREFIX_.'image_shop is SET i.cover = 1 WHERE i.id_image = is.id_image AND is.id_shop = '.(int)$id_shop.' LIMIT 1');
if ($count_cover_image > 1)
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'image i, '._DB_PREFIX_.'image_shop is SET i.cover = 0 WHERE cover = 1 AND i.id_image = is.id_image AND is.id_shop = '.(int)$id_shop.' LIMIT '.intval($count_cover_image - 1));
// Clean covers in image_shop table
$count_cover_image_shop = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'image_shop is WHERE is.id_shop = '.(int)$id_shop.' AND is.cover = 1');
if ($count_cover_image_shop < 1)
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'image_shop is SET is.cover = 1 WHERE is.id_shop = '.(int)$id_shop.' LIMIT 1');
if ($count_cover_image_shop > 1)
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'image_shop is SET is.cover = 0 WHERE is.cover = 1 AND is.id_shop = '.(int)$id_shop.' LIMIT '.intval($count_cover_image_shop - 1));
if ($res)
$this->jsonConfirmation($this->_conf[27]);
@@ -98,7 +98,7 @@ class AdminShippingControllerCore extends AdminController
else
$array_carrier[] = $carrier['id_carrier'];
$id_carrier = Tools::getValue('id_carrier');
$id_carrier = (int)Tools::getValue('id_carrier');
if (count($carriers) && isset($array_carrier[0]))
{
@@ -298,7 +298,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController
'id' => 'id_tax',
'name' => 'name',
'default' => array(
'value' => 'name',
'value' => 0,
'label' => $this->l('No Tax')
)
),
+105 -10
View File
@@ -249,7 +249,8 @@ class AdminTranslationsControllerCore extends AdminController
$path = dirname($dest);
// If folder wasn't already added
if (!Tools::file_exists_cache($path))
// Do not use Tools::file_exists_cache because it changes over time!
if (!file_exists($path))
if (!mkdir($path, 0777, true))
{
$bool &= false;
@@ -328,14 +329,27 @@ class AdminTranslationsControllerCore extends AdminController
public function submitCopyLang()
{
if (!($from_lang = strval(Tools::getValue('fromLang'))) || !($to_lang = strval(Tools::getValue('toLang'))))
if (!($from_lang = Tools::getValue('fromLang')) || !($to_lang = Tools::getValue('toLang')))
$this->errors[] = $this->l('You must select 2 languages in order to copy data from one to another');
else if (!($from_theme = strval(Tools::getValue('fromTheme'))) || !($to_theme = strval(Tools::getValue('toTheme'))))
else if (!($from_theme = Tools::getValue('fromTheme')) || !($to_theme = Tools::getValue('toTheme')))
$this->errors[] = $this->l('You must select 2 themes in order to copy data from one to another');
else if (!Language::copyLanguageData(Language::getIdByIso($from_lang), Language::getIdByIso($to_lang)))
$this->errors[] = $this->l('An error occurred while copying data');
else if ($from_lang == $to_lang && $from_theme == $to_theme)
$this->errors[] = $this->l('Nothing to copy! (same language and theme)');
else
{
$theme_exists = array('from_theme' => false, 'to_theme' => false);
foreach ($this->themes as $theme)
{
if ($theme->directory == $from_theme)
$theme_exists['from_theme'] = true;
if ($theme->directory == $to_theme)
$theme_exists['to_theme'] = true;
}
if ($theme_exists['from_theme'] == false || $theme_exists['to_theme'] == false)
$this->errors[] = $this->l('Theme(s) not found');
}
if (count($this->errors))
return;
@@ -553,6 +567,7 @@ class AdminTranslationsControllerCore extends AdminController
*/
public static function addNewTabs($iso_code, $files)
{
$errors = array();
foreach ($files as $file)
{
// Check if file is a file theme
@@ -572,12 +587,44 @@ class AdminTranslationsControllerCore extends AdminController
$id_lang = Language::getIdByIso($iso_code);
$tab->name[(int)$id_lang] = $translations;
// Update this tab
$tab->update();
if (!Validate::isGenericName($tab->name[(int)$id_lang]))
$errors[] = sprintf(Tools::displayError('Tab "%s" is not valid'), $tab->name[(int)$id_lang]);
else
$tab->update();
}
}
}
}
return $errors;
}
public static function checkTranslationFile($content)
{
$lines = array_map('trim', explode("\n", $content));
$global = false;
foreach ($lines as $line)
{
if (in_array($line, array('<?php', '?>', '')))
continue;
if (!$global && preg_match('/^global\s+\$([a-z0-9-_]+)\s*;$/i', $line, $matches))
{
$global = $matches[1];
continue;
}
if ($global != false && preg_match('/^\$'.preg_quote($global, '/').'\s*=\s*array\(\s*\)\s*;$/i', $line))
continue;
if (!$global && preg_match('/^\$([a-z0-9-_]+)\s*=\s*array\(\s*\)\s*;$/i', $line, $matches))
{
$global = $matches[1];
continue;
}
if (preg_match('/^\$'.preg_quote($global, '/').'\[\''._PS_TRANS_PATTERN_.'\'\]\s*=\s*\''._PS_TRANS_PATTERN_.'\'\s*;$/i', $line))
continue;
if (preg_match('/^return\s+\$'.preg_quote($global, '/').'\s*;$/i', $line, $matches))
continue;
return false;
}
return true;
}
public function submitImportLang()
@@ -593,11 +640,45 @@ class AdminTranslationsControllerCore extends AdminController
{
$themes_selected = Tools::getValue('theme', array(self::DEFAULT_THEME_NAME));
$files_list = $gz->listContent();
$uniqid = uniqid();
$sandbox = _PS_CACHE_DIR_.'sandbox'.DIRECTORY_SEPARATOR.$uniqid.DIRECTORY_SEPARATOR;
if ($gz->extract($sandbox, false))
{
foreach ($files_list as $file2check)
{
//don't validate index.php, will be overwrite when extract in translation directory
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php')
continue;
if (preg_match('@^[0-9a-z-_/\\\\]+\.php$@i', $file2check['filename']))
{
if (!AdminTranslationsController::checkTranslationFile(file_get_contents($sandbox.$file2check['filename'])))
$this->errors[] = sprintf(Tools::displayError('Validation failed for: %s'), $file2check['filename']);
}
elseif (!preg_match('@^[0-9a-z-_/\\\\]+\.(html|tpl|txt)$@i', $file2check['filename']))
$this->errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']);
}
Tools::deleteDirectory($sandbox, true);
}
if (count($this->errors))
return false;
if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
{
foreach ($files_list as $file2check)
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent()))
continue;
AdminTranslationsController::checkAndAddMailsFiles($iso_code, $files_list);
$this->checkAndAddThemesFiles($files_list, $themes_selected);
AdminTranslationsController::addNewTabs($iso_code, $files_list);
$tab_errors = AdminTranslationsController::addNewTabs($iso_code, $files_list);
if (count($tab_errors))
{
$this->errors += $tab_errors;
return false;
}
if (Validate::isLanguageFileName($filename))
{
if (!Language::checkAndAddLanguage($iso_code))
@@ -629,9 +710,14 @@ class AdminTranslationsControllerCore extends AdminController
if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
{
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list);
if (!Language::checkAndAddLanguage($arr_import_lang[0]))
$conf = 20;
$tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list);
if (count($tab_errors))
$this->errors += $tab_errors;
else
{
if (!Language::checkAndAddLanguage($arr_import_lang[0]))
$conf = 20;
}
if (!unlink($file))
$this->errors[] = Tools::displayError('Cannot delete archive');
@@ -1080,7 +1166,16 @@ class AdminTranslationsControllerCore extends AdminController
// Get folder name of theme
if (($theme = Tools::getValue('theme')) && !is_array($theme))
$this->theme_selected = Tools::safeOutput($theme);
{
$theme_exists = false;
foreach ($this->themes as $existing_theme)
if ($existing_theme->directory == $theme)
$theme_exists = true;
if ($theme_exists)
$this->theme_selected = Tools::safeOutput($theme);
else
throw new PrestaShopException(sprintf(Tools::displayError('Invalid theme "%s"'), $theme));
}
else
$this->theme_selected = self::DEFAULT_THEME_NAME;