// AdminCurrencies refactoring
This commit is contained in:
@@ -677,7 +677,7 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change object statuts (active, inactive)
|
* Change object status (active, inactive)
|
||||||
*
|
*
|
||||||
* @param string $token
|
* @param string $token
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -251,46 +251,70 @@ class AdminCurrenciesControllerCore extends AdminController
|
|||||||
return parent::renderForm();
|
return parent::renderForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postProcess()
|
/**
|
||||||
|
* @see AdminController::processDelete()
|
||||||
|
* @param $token
|
||||||
|
*/
|
||||||
|
public function processDelete($token)
|
||||||
{
|
{
|
||||||
if ($this->action == 'delete')
|
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||||
{
|
{
|
||||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||||
{
|
$this->_errors[] = $this->l('You can\'t delete the default currency');
|
||||||
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
else if ($object->delete())
|
||||||
$this->_errors[] = $this->l('You can\'t delete the default currency');
|
Tools::redirectAdmin(self::$currentIndex.'&conf=1'.'&token='.$this->token);
|
||||||
else if ($object->delete())
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=1'.'&token='.$this->token);
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').'
|
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
||||||
<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
|
||||||
}
|
|
||||||
else if ($this->action == 'status')
|
|
||||||
{
|
|
||||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
|
||||||
{
|
|
||||||
if ($object->active && $object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
|
||||||
$this->_errors[] = $this->l('You can\'t disable the default currency');
|
|
||||||
else if ($object->toggleStatus())
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category =
|
|
||||||
(int)Tools::getValue('id_category')) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$this->token);
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').'
|
|
||||||
<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
|
||||||
}
|
|
||||||
else if (Tools::isSubmit('submitExchangesRates'))
|
|
||||||
{
|
|
||||||
if (!$this->_errors[] = Currency::refreshCurrencies())
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
parent::postProcess();
|
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').'
|
||||||
|
<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AdminController::processStatus()
|
||||||
|
* @param $token
|
||||||
|
*/
|
||||||
|
public function processStatus($token)
|
||||||
|
{
|
||||||
|
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||||
|
{
|
||||||
|
if ($object->active && $object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||||
|
$this->_errors[] = $this->l('You can\'t disable the default currency');
|
||||||
|
else if ($object->toggleStatus())
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category =
|
||||||
|
(int)Tools::getValue('id_category')) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$this->token);
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').'
|
||||||
|
<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update currency exchange rates
|
||||||
|
* @param $token
|
||||||
|
*/
|
||||||
|
public function processExchangeRates($token)
|
||||||
|
{
|
||||||
|
if (!$this->_errors[] = Currency::refreshCurrencies())
|
||||||
|
Tools::redirectAdmin(self::$currentIndex . '&conf=6' . '&token=' . $this->token);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AdminController::initProcess()
|
||||||
|
*/
|
||||||
|
public function initProcess()
|
||||||
|
{
|
||||||
|
if (Tools::isSubmit('submitExchangesRates'))
|
||||||
|
{
|
||||||
|
if ($this->tabAccess['edit'] === '1')
|
||||||
|
$this->action = 'exchangeRates';
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||||
|
}
|
||||||
|
parent::initProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateOptionPsCurrencyDefault($value)
|
public function updateOptionPsCurrencyDefault($value)
|
||||||
|
|||||||
Reference in New Issue
Block a user