Merge remote-tracking branch 'origin/ticket/r13756-slider' into dev

This commit is contained in:
Michael RICOIS 2017-08-28 16:33:18 +02:00
commit f62d1d511f
3 changed files with 50 additions and 3 deletions

View File

@ -105,7 +105,11 @@ class AdvSlide extends ObjectModel
// Check user group
if (Configuration::get('ADVSLIDER_RESTRICT_GROUP')) {
$groups = Customer::getGroupsStatic($context->customer->id);
$sql.= ' AND EXISTS(SELECT * FROM `'._DB_PREFIX_.'advslider_group` ag WHERE ag.id_group IN('.join(',', $groups).')';
if ($context->customer->logged == 0) {
$groups = array(Configuration::get('ADVSLIDER_DEFAULT_GROUP'));
}
$sql.= ' AND EXISTS(SELECT * FROM `'._DB_PREFIX_.'advslider_group` ag WHERE ag.id_group IN('.join(',', $groups).'))';
}
// Check date

View File

@ -14,14 +14,30 @@ class AdvSliderGetContentController
if (Tools::isSubmit('submitAdvsliderconfig')) {
$enable_date = Tools::getValue('enable_date');
$enable_groups = Tools::getValue('enable_groups');
$default_group = Tools::getValue('default_group');
Configuration::updateValue('ADVSLIDER_RESTRICT_DATE', $enable_date);
Configuration::updateValue('ADVSLIDER_RESTRICT_GROUP', $enable_groups);
Configuration::updateValue('ADVSLIDER_DEFAULT_GROUP', $default_group);
$this->context->smarty->assign('confirmation', 'ok');
}
}
public function renderForm()
{
$groups = Group::getGroups($this->context->language->id);
$optionGroups = array();
if (count($groups) > 0) {
foreach ($groups as $group) {
if (in_array($group['id_group'], array(1,2))) {
continue;
}
$optionGroups[] = array(
'id_group' => $group['id_group'],
'name' => $group['name'],
);
}
}
$fields_form = array(
'form' => array(
'legend' => array(
@ -50,8 +66,34 @@ class AdvSliderGetContentController
),
),
array(
'type' => 'checkbox',
'label' => $this->module->l('User group to display for restriction'),
'name' => 'groups',
'values' => array(
'query' => $optionGroups,
'id' => 'id_group',
'name' => 'name',
),
'submit' => array('title' => $this->module->l('Save'))
'expand' => array(
'default' => 'show',
'show' => array('text' => $this->module->l('show'), 'icon' => 'plus-sign-alt'),
'hide' => array('text' => $this->module->l('hide'), 'icon' => 'minus-sign-alt')
),
),
array(
'type' => 'select',
'label' => $this->module->l('Default group to display:'),
'name' => 'default_group',
'desc' => $this->module->l('Set a Default group to display slider with unauthenticated user.'),
'options' => array(
'query' => $optionGroups,
'id' => 'id_group',
'name' => 'name',
),
),
),
'submit' => array('title' => $this->module->l('Save')),
)
);
@ -66,6 +108,7 @@ class AdvSliderGetContentController
'fields_value' => array(
'enable_date' => Tools::getValue('enable_date', Configuration::get('ADVSLIDER_RESTRICT_DATE')),
'enable_groups' => Tools::getValue('enable_groups', Configuration::get('ADVSLIDER_RESTRICT_GROUP')),
'default_group' => Tools::getValue('default_group', Configuration::get('ADVSLIDER_DEFAULT_GROUP')),
),
'languages' => $this->context->controller->getLanguages()
);

View File

@ -54,7 +54,7 @@ $(document).ready(function() {
</div>
<div class="mon-nouveau-slider">
{hook h='displaySlider'}
{hook h='displaySlider' mod='advslider'}
</div>
<h3 class="sale-title-type col-xs-12 smobile"><span>{l s='Nos ventes en cours' mod='privatesales'}</span></h3>