Skip to content

Commit

Permalink
Add extended slider permissions (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi authored Jun 21, 2021
1 parent 0b735ae commit a9ad0b4
Show file tree
Hide file tree
Showing 11 changed files with 665 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@

// TODO: Replace with migration services
$GLOBALS['TL_HOOKS']['sqlCompileCommands'][] = array('MadeYourDay\\RockSolidSlider\\SliderRunonce', 'onSqlCompileCommands');

$GLOBALS['TL_PERMISSIONS'][] = 'rsts_sliders';
$GLOBALS['TL_PERMISSIONS'][] = 'rsts_permissions';
16 changes: 14 additions & 2 deletions src/Resources/contao/dca/tl_rocksolid_slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
'ctable' => array('tl_rocksolid_slide'),
'switchToEdit' => true,
'enableVersioning' => true,
'onload_callback' => array(
array('MadeYourDay\\RockSolidSlider\\Slider', 'onloadCallback'),
),
'oncreate_callback' => array(
array('MadeYourDay\\RockSolidSlider\\Slider', 'oncreateCallback')
),
'oncopy_callback' => array(
array('MadeYourDay\\RockSolidSlider\\Slider', 'oncopyCallback')
),
'sql' => array(
'keys' => array(
'id' => 'primary',
Expand All @@ -42,6 +51,7 @@
'href' => 'table=tl_rocksolid_slider_license',
'class' => 'header_icon',
'icon' => 'system/themes/' . \Backend::getTheme() . '/images/settings.gif',
'button_callback' => array('MadeYourDay\\RockSolidSlider\\Slider', 'sliderLicenseButton'),
),
'all' => array(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
Expand All @@ -67,13 +77,15 @@
'copy' => array(
'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_slider']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif',
'icon' => 'copy.svg',
'button_callback' => array('MadeYourDay\\RockSolidSlider\\Slider', 'copySliderIcon'),
),
'delete' => array(
'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_slider']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? '') . '\'))return false;Backend.getScrollOffset()"',
'button_callback' => array('MadeYourDay\\RockSolidSlider\\Slider', 'deleteSliderIcon'),
),
'show' => array(
'label' => &$GLOBALS['TL_LANG']['tl_rocksolid_slider']['show'],
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/contao/dca/tl_rocksolid_slider_license.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
'config' => array(
'dataContainer' => 'File',
'closed' => true,
'onload_callback' => array(
array('MadeYourDay\\RockSolidSlider\\Slider', 'licenseOnloadCallback'),
),
),

'list' => array(
Expand Down
35 changes: 35 additions & 0 deletions src/Resources/contao/dca/tl_user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Contao\CoreBundle\DataContainer\PaletteManipulator;

PaletteManipulator::create()
->addLegend('rsts_slider_legend', 'amg_legend', PaletteManipulator::POSITION_BEFORE)
->addField(array('rsts_sliders', 'rsts_permissions'), 'rsts_slider_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('extend', 'tl_user')
->applyToPalette('custom', 'tl_user')
;

$GLOBALS['TL_DCA']['tl_user']['config']['onload_callback'][] = array('MadeYourDay\\RockSolidSlider\\Slider', 'userOnloadCallback');

$GLOBALS['TL_DCA']['tl_user']['fields']['rsts_sliders'] = array(
'exclude' => true,
'inputType' => 'checkbox',
'foreignKey' => 'tl_rocksolid_slider.name',
'eval' => array('multiple' => true),
'sql' => "blob NULL",
);

$GLOBALS['TL_DCA']['tl_user']['fields']['rsts_permissions'] = array(
'exclude' => true,
'inputType' => 'checkbox',
'options' => array('create', 'delete'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('multiple' => true),
'sql' => "blob NULL",
);
34 changes: 34 additions & 0 deletions src/Resources/contao/dca/tl_user_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Contao\CoreBundle\DataContainer\PaletteManipulator;

PaletteManipulator::create()
->addLegend('rsts_slider_legend', 'amg_legend', PaletteManipulator::POSITION_BEFORE)
->addField(array('rsts_sliders', 'rsts_permissions'), 'rsts_slider_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_user_group')
;

$GLOBALS['TL_DCA']['tl_user_group']['config']['onload_callback'][] = array('MadeYourDay\\RockSolidSlider\\Slider', 'userGroupOnloadCallback');

$GLOBALS['TL_DCA']['tl_user_group']['fields']['rsts_sliders'] = array(
'exclude' => true,
'inputType' => 'checkbox',
'foreignKey' => 'tl_rocksolid_slider.name',
'eval' => array('multiple' => true),
'sql' => "blob NULL",
);

$GLOBALS['TL_DCA']['tl_user_group']['fields']['rsts_permissions'] = array(
'exclude' => true,
'inputType' => 'checkbox',
'options' => array('create', 'delete'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('multiple' => true),
'sql' => "blob NULL",
);
19 changes: 19 additions & 0 deletions src/Resources/contao/languages/de/tl_user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* RockSolid Slider module translations
*
* @author Martin Auswöger <[email protected]>
*/

$GLOBALS['TL_LANG']['tl_user']['rsts_slider_legend'] = 'RockSolid Slider';
$GLOBALS['TL_LANG']['tl_user']['rsts_sliders'][0] = 'Erlaubte Slider';
$GLOBALS['TL_LANG']['tl_user']['rsts_sliders'][1] = 'Hier können Sie den Zugriff auf einen oder mehrere Slider erlauben.';
$GLOBALS['TL_LANG']['tl_user']['rsts_permissions'][0] = 'Sliderrechte';
$GLOBALS['TL_LANG']['tl_user']['rsts_permissions'][1] = 'Hier können Sie die Sliderrechte festlegen.';
19 changes: 19 additions & 0 deletions src/Resources/contao/languages/de/tl_user_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* RockSolid Slider module translations
*
* @author Martin Auswöger <[email protected]>
*/

$GLOBALS['TL_LANG']['tl_user_group']['rsts_slider_legend'] = 'RockSolid Slider';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_sliders'][0] = 'Erlaubte Slider';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_sliders'][1] = 'Hier können Sie den Zugriff auf einen oder mehrere Slider erlauben.';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_permissions'][0] = 'Sliderrechte';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_permissions'][1] = 'Hier können Sie die Sliderrechte festlegen.';
19 changes: 19 additions & 0 deletions src/Resources/contao/languages/en/tl_user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* RockSolid Slider module translations
*
* @author Martin Auswöger <[email protected]>
*/

$GLOBALS['TL_LANG']['tl_user']['rsts_slider_legend'] = 'RockSolid Slider';
$GLOBALS['TL_LANG']['tl_user']['rsts_sliders'][0] = 'Allowed sliders';
$GLOBALS['TL_LANG']['tl_user']['rsts_sliders'][1] = 'Here you can grant access to one or more sliders.';
$GLOBALS['TL_LANG']['tl_user']['rsts_permissions'][0] = 'Slider permissions';
$GLOBALS['TL_LANG']['tl_user']['rsts_permissions'][1] = 'Here you can define the slider permissions.';
19 changes: 19 additions & 0 deletions src/Resources/contao/languages/en/tl_user_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/*
* Copyright MADE/YOUR/DAY OG <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* RockSolid Slider module translations
*
* @author Martin Auswöger <[email protected]>
*/

$GLOBALS['TL_LANG']['tl_user_group']['rsts_slider_legend'] = 'RockSolid Slider';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_sliders'][0] = 'Allowed sliders';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_sliders'][1] = 'Here you can grant access to one or more sliders.';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_permissions'][0] = 'Slider permissions';
$GLOBALS['TL_LANG']['tl_user_group']['rsts_permissions'][1] = 'Here you can define the slider permissions.';
Loading

0 comments on commit a9ad0b4

Please sign in to comment.