Allow to remove every item

Removing every Top Menu item will raise a `Unable to update settings.` error.  
If `$items` is empty, we should consider it as a user request to clear the Top Menu.
This commit is contained in:
Samuel Marchal
2014-05-26 15:25:07 +02:00
parent 51afc886b6
commit db18e52fb7
+5 -1
View File
@@ -146,7 +146,11 @@ class Blocktopmenu extends Module
if (Tools::isSubmit('submitBlocktopmenu')) if (Tools::isSubmit('submitBlocktopmenu'))
{ {
$items = Tools::getValue('items'); $items = Tools::getValue('items');
if (is_array($items) && count($items) && Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items))) if (is_array($items) && count($items))
$updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items));
else
$updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', '');
if ($updated)
$this->_html .= $this->displayConfirmation($this->l('The settings have been updated.')); $this->_html .= $this->displayConfirmation($this->l('The settings have been updated.'));
else else
$this->_html .= $this->displayError($this->l('Unable to update settings.')); $this->_html .= $this->displayError($this->l('Unable to update settings.'));