';
}
$this->displayListFooter();
}
public function displayForm($isMainTab = true)
{
if (!Feature::isFeatureActive())
{
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').''.$this->l('Performances').'');
return;
}
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
echo '
'.$this->l('Add a new feature').'
';
}
public function displayErrors()
{
$this->adminFeaturesValues->displayErrors();
parent::displayErrors();
}
public function postProcess()
{
if (!Feature::isFeatureActive())
return ;
$this->adminFeaturesValues->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id);
if (Tools::isSubmit('submitAddfeature_value') || Tools::isSubmit('submitDelfeature_value'))
$this->adminFeaturesValues->postProcess($this->token);
Module::hookExec('postProcessFeature',
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeature to stop saving process
if(Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
{
if (isset($_POST[$this->table.'Box']))
{
$object = new $this->className();
if ($object->deleteSelection($_POST[$this->table.'Box']))
Tools::redirectAdmin(self::$currentIndex.'&conf=2'.'&token='.$this->token);
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
}
else
$this->_errors[] = Tools::displayError('You must select at least one element to delete.');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
else if (Tools::isSubmit('submitAdd'.$this->table))
{
if ($this->tabAccess['add'] === '1')
{
$id_feature = (int)Tools::getValue('id_feature');
// Adding last position to the feature if not exist
if ($id_feature <= 0)
{
$sql = 'SELECT `position`+1
FROM `'._DB_PREFIX_.'feature`
ORDER BY position DESC';
// set the position of the new feature in $_POST for postProcess() method
$_POST['position'] = DB::getInstance()->getValue($sql);
}
// clean \n\r characters
foreach ($_POST as $key => $value)
if (preg_match('/^name_/Ui', $key))
$_POST[$key] = str_replace ('\n', '', str_replace('\r', '', $value));
parent::postProcess();
}
}
else
parent::postProcess();
}
/**
* Modifying initial getList method to display position feature (drag and drop)
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if ($order_by && $this->context->cookie->__get($this->table.'Orderby'))
$order_by = $this->context->cookie->__get($this->table.'Orderby');
else
$order_by = 'position';
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
}
}