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

This commit is contained in:
Gregory Roussac
2013-02-26 19:25:05 +01:00
4 changed files with 116 additions and 131 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ class SearchCore
$string = preg_replace('/[^\s]-+/', '', $string); $string = preg_replace('/[^\s]-+/', '', $string);
} }
$blacklist = Configuration::get('PS_SEARCH_BLACKLIST', $id_lang); $blacklist = Tools::strtolower(Configuration::get('PS_SEARCH_BLACKLIST', $id_lang));
if (!empty($blacklist)) if (!empty($blacklist))
{ {
$string = preg_replace('/(?<=\s)('.$blacklist.')(?=\s)/Su', '', $string); $string = preg_replace('/(?<=\s)('.$blacklist.')(?=\s)/Su', '', $string);
+81 -97
View File
@@ -277,58 +277,95 @@ class AdminLanguagesControllerCore extends AdminController
return parent::renderForm(); return parent::renderForm();
} }
public function postProcess() public function processDelete()
{ {
if (isset($_GET['delete'.$this->table])) $object = $this->loadObject();
if (!$this->checkDeletion($object))
return false;
if (!$this->deleteNoPictureImages((int)$object->id))
$this->errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> ';
return parent::processDelete();
}
protected function processBulkDelete()
{ {
if ($this->tabAccess['delete'] === '1') $can_bulk = true;
if (is_array($this->boxes) && !empty($this->boxes))
{ {
if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) foreach ($this->boxes as $id_lang)
{
$object = new Language((int)$id_lang);
if (!$this->checkDeletion($object))
return false;
if (!$this->deleteNoPictureImages((int)$object->id))
{
$this->errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> ';
return false;
}
}
}
return parent::processBulkDelete();
}
protected function checkDeletion($object)
{
if (Validate::isLoadedObject($object))
{ {
if ($object->id == Configuration::get('PS_LANG_DEFAULT')) if ($object->id == Configuration::get('PS_LANG_DEFAULT'))
$this->errors[] = $this->l('You cannot delete the default language.'); $this->errors[] = $this->l('You cannot delete the default language.');
elseif ($object->id == $this->context->language->id) elseif ($object->id == $this->context->language->id)
$this->errors[] = $this->l('You cannot delete the language currently in use. Please change languages before deleting.'); $this->errors[] = $this->l('You cannot delete the language currently in use. Please change languages before deleting.');
else if ($this->deleteNoPictureImages((int)Tools::getValue('id_lang')) && $object->delete()) else
{ return true;
$this->checkEmployeeIdLang($object->id); }
Tools::redirectAdmin(self::$currentIndex.'&conf=1'.'&token='.$this->token); else
$this->errors[] = Tools::displayError('(cannot load object)');
return false;
} }
} protected function checkDisableStatus($object)
else
$this->errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> '.
Tools::displayError('(cannot load object)');
}
else
$this->errors[] = Tools::displayError('You do not have permission to delete here.');
}
else if (Tools::getValue('submitDel'.$this->table) && isset($_POST[$this->table.'Box']))
{ {
if ($this->tabAccess['delete'] === '1') if (!Validate::isLoadedObject($object))
{ $this->errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
if (in_array(Configuration::get('PS_LANG_DEFAULT'), $_POST[$this->table.'Box']))
$this->errors[] = $this->l('You cannot delete the default language.');
else if (in_array($this->context->language->id, $_POST[$this->table.'Box']))
$this->errors[] = $this->l('You cannot delete the language currently in use. Please change languages before deleting.');
else else
{ {
foreach ($_POST[$this->table.'Box'] as $language) if ($object->id == (int)Configuration::get('PS_LANG_DEFAULT'))
$this->deleteNoPictureImages($language); $this->errors[] = Tools::displayError('You cannot change the status of the default language.');
if (Validate::isLoadedObject($object = $this->loadObject())) else
return true;
}
return false;
}
public function processStatus()
{
$object = $this->loadObject();
if ($this->checkDisableStatus($object))
{
$this->checkEmployeeIdLang($object->id); $this->checkEmployeeIdLang($object->id);
parent::postProcess(); return parent::processStatus();
} }
return false;
} }
else
$this->errors[] = Tools::displayError('You do not have permission to delete here.'); protected function processBulkDisableSelection()
}
else if (Tools::isSubmit('submitAddlang'))
{ {
/* New language */ if (is_array($this->boxes) && !empty($this->boxes))
if ((int)Tools::getValue('id_'.$this->table) == 0)
{ {
if ($this->tabAccess['add'] === '1') foreach ($this->boxes as $id_lang)
{
$object = new Language((int)$id_lang);
if (!$this->checkDisableStatus($object))
return false;
$this->checkEmployeeIdLang($object->id);
}
}
return parent::processBulkDisableSelection();
}
public function processAdd()
{ {
if (isset($_POST['iso_code']) && !empty($_POST['iso_code']) && Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Language::getIdByIso($_POST['iso_code'])) if (isset($_POST['iso_code']) && !empty($_POST['iso_code']) && Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Language::getIdByIso($_POST['iso_code']))
$this->errors[] = Tools::displayError('This ISO code is already linked to another language.'); $this->errors[] = Tools::displayError('This ISO code is already linked to another language.');
@@ -336,23 +373,16 @@ class AdminLanguagesControllerCore extends AdminController
{ {
if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK) if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK)
$this->copyNoPictureImage(strtolower(Tools::getValue('iso_code'))); $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
// class AdminTab deal with every $_FILES content, don't do that for no-picture
unset($_FILES['no-picture']); unset($_FILES['no-picture']);
parent::postProcess(); return parent::processAdd();
} }
else else
{
$this->validateRules();
$this->errors[] = Tools::displayError('Flag and "No picture" image fields are required.'); $this->errors[] = Tools::displayError('Flag and "No picture" image fields are required.');
return false;
} }
}
else public function processUpdate()
$this->errors[] = Tools::displayError('You do not have permission to add here.');
}
/* Language edition */
else
{
if ($this->tabAccess['edit'] === '1')
{ {
if (( isset($_FILES['no-picture']) && !$_FILES['no-picture']['error'] || isset($_FILES['flag']) && !$_FILES['flag']['error']) if (( isset($_FILES['no-picture']) && !$_FILES['no-picture']['error'] || isset($_FILES['flag']) && !$_FILES['flag']['error'])
&& Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) && Validate::isLanguageIsoCode(Tools::getValue('iso_code')))
@@ -361,43 +391,14 @@ class AdminLanguagesControllerCore extends AdminController
$this->copyNoPictureImage(strtolower(Tools::getValue('iso_code'))); $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
// class AdminTab deal with every $_FILES content, don't do that for no-picture // class AdminTab deal with every $_FILES content, don't do that for no-picture
unset($_FILES['no-picture']); unset($_FILES['no-picture']);
parent::postProcess();
} }
$object = $this->loadObject();
if (Tools::getValue('active') != (int)$object->active)
if (!$this->checkDisableStatus($object))
return false;
if (!Validate::isLoadedObject($object = $this->loadObject()))
$this->errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
if ((int)$object->id == (int)Configuration::get('PS_LANG_DEFAULT') && (int)$_POST['active'] != (int)$object->active)
$this->errors[] = Tools::displayError('You cannot change the status of the default language.');
else
parent::postProcess();
$this->validateRules();
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
else if (isset($_GET['status'.$this->table]) && isset($_GET['id_lang']))
{
if ($this->tabAccess['edit'] === '1')
{
if (!Validate::isLoadedObject($object = $this->loadObject()))
$this->errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
if ((int)$object->id == (int)Configuration::get('PS_LANG_DEFAULT'))
$this->errors[] = Tools::displayError('You cannot change the status of the default language.');
else
{
if (Validate::isLoadedObject($object))
$this->checkEmployeeIdLang($object->id); $this->checkEmployeeIdLang($object->id);
return parent::postProcess(); return parent::processUpdate();
}
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
else
return parent::postProcess();
} }
/** /**
@@ -515,21 +516,4 @@ class AdminLanguagesControllerCore extends AdminController
//update employee lang if current id lang is disabled //update employee lang if current id lang is disabled
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'employee` set `id_lang`='.(int)Configuration::get('PS_LANG_DEFAULT').' WHERE `id_lang`='.(int)$current_id_lang); Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'employee` set `id_lang`='.(int)Configuration::get('PS_LANG_DEFAULT').' WHERE `id_lang`='.(int)$current_id_lang);
} }
protected function processBulkStatusSelection($status)
{
if (!$status)//only check if status == 0 (disable)
{
if (is_array($this->boxes) && !empty($this->boxes))
foreach ($this->boxes as $id)
if (Configuration::get('PS_LANG_DEFAULT') == $id)
$this->errors[] = $this->l('You cannot change the status of the default language.');
if (!count($this->errors))
parent::processBulkStatusSelection($status);
} }
else
parent::processBulkStatusSelection($status);
}
}
+1
View File
@@ -68,6 +68,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp
Context::getContext()->language = new Language(Configuration::get('PS_LANG_DEFAULT')); Context::getContext()->language = new Language(Configuration::get('PS_LANG_DEFAULT'));
Context::getContext()->country = new Country('PS_COUNTRY_DEFAULT'); Context::getContext()->country = new Country('PS_COUNTRY_DEFAULT');
Context::getContext()->cart = new Cart(); Context::getContext()->cart = new Cart();
Context::getContext()->employee = new Employee(1);
define('_PS_SMARTY_FAST_LOAD_', true); define('_PS_SMARTY_FAST_LOAD_', true);
require_once _PS_ROOT_DIR_.'/config/smarty.config.inc.php'; require_once _PS_ROOT_DIR_.'/config/smarty.config.inc.php';