diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 799bcdd..b304f6a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,7 @@ mae_event_categories Changelog ============================== +Version 1.2.0 (2015-12-16) added default categories in user/group Version 1.1.0 (2015-08-25) added filter module Version 1.0.3 (2015-06-02) hotfix model / namespace Version 1.0.1 (2015-06-01) added model class diff --git a/README.md b/README.md index ba7db42..367f2d3 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ The category filter module allows visitors to filter the displayed events by cat customized places within contao ------------------------------- - Account Manager / [Users, User groups]: - new field "Manage event categories" on top of "Calendar permissions" fieldset + new legend "event categories" on top of "Calendar permissions" + allow edit categories and specify default categories for new events - Content / Events: new global operation "Categories" diff --git a/classes/MaeEvent.php b/classes/MaeEvent.php index a9f3170..7106351 100644 --- a/classes/MaeEvent.php +++ b/classes/MaeEvent.php @@ -15,7 +15,10 @@ * Namespace */ namespace MaeEventCategories; +use Contao\Database; +use Contao\DataContainer; use Contao\Input; +use Contao\System; /** diff --git a/classes/MaeEventBe.php b/classes/MaeEventBe.php new file mode 100644 index 0000000..0f5681e --- /dev/null +++ b/classes/MaeEventBe.php @@ -0,0 +1,33 @@ +import('BackendUser', 'User'); + } + + public function setDefaultCategories($table, $id) + { + $catDefault = $this->User->maeEventCatDefault; + if(is_array($catDefault) && count($catDefault) > 0) { + Database::getInstance()->prepare("UPDATE tl_calendar_events SET categories=? WHERE id=?")->execute(serialize($catDefault), $id); + } + } +} \ No newline at end of file diff --git a/config/autoload.php b/config/autoload.php index 1796380..b50b12c 100644 --- a/config/autoload.php +++ b/config/autoload.php @@ -4,6 +4,7 @@ ClassLoader::addClasses(array ( 'MaeEventCategories\MaeEvent' => 'system/modules/mae_event_categories/classes/MaeEvent.php', + 'MaeEventCategories\MaeEventBe' => 'system/modules/mae_event_categories/classes/MaeEventBe.php', 'MaeEventCategories\MaeEventCatModel' => 'system/modules/mae_event_categories/models/MaeEventCatModel.php', 'MaeEventCategories\ModuleFilter' => 'system/modules/mae_event_categories/modules/ModuleFilter.php' )); diff --git a/config/config.php b/config/config.php index eeaea1e..3435402 100644 --- a/config/config.php +++ b/config/config.php @@ -26,6 +26,7 @@ * Add permissions */ $GLOBALS['TL_PERMISSIONS'][] = 'maeEventCat'; +$GLOBALS['TL_PERMISSIONS'][] = 'maeEventCatDefault'; /** * Front end modules diff --git a/dca/tl_calendar_events.php b/dca/tl_calendar_events.php index d7400d4..2eaa182 100644 --- a/dca/tl_calendar_events.php +++ b/dca/tl_calendar_events.php @@ -1,5 +1,6 @@ true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''" +); + +$GLOBALS['TL_DCA']['tl_user']['fields']['maeEventCatDefault'] = array +( + 'label' => &$GLOBALS['TL_LANG']['tl_user']['default_event_categories'], + 'exclude' => true, + 'inputType' => 'checkboxWizard', + 'foreignKey' => 'tl_mae_event_cat.title', + 'eval' => array('tl_class'=>'clr', 'multiple'=>true, 'fieldType'=>'checkbox', 'foreignTable'=>'tl_mae_event_cat', 'titleField'=>'title', 'searchField'=>'title'), + 'sql' => "blob NULL" ); \ No newline at end of file diff --git a/dca/tl_user_group.php b/dca/tl_user_group.php index 9f202a2..3ea5697 100644 --- a/dca/tl_user_group.php +++ b/dca/tl_user_group.php @@ -18,7 +18,7 @@ /** * Add a palette to tl_user_group */ -$GLOBALS['TL_DCA']['tl_user_group']['palettes']['default'] = str_replace('{calendars_legend}', '{calendars_legend},maeEventCat', $GLOBALS['TL_DCA']['tl_user_group']['palettes']['default']); +$GLOBALS['TL_DCA']['tl_user_group']['palettes']['default'] = str_replace('{calendars_legend}', '{mae_evt_cat_legend},maeEventCat,maeEventCatDefault;{calendars_legend}', $GLOBALS['TL_DCA']['tl_user_group']['palettes']['default']); /** * Add a new field to tl_user_group @@ -29,4 +29,14 @@ 'exclude' => true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''" +); + +$GLOBALS['TL_DCA']['tl_user_group']['fields']['maeEventCatDefault'] = array +( + 'label' => &$GLOBALS['TL_LANG']['tl_user']['default_event_categories'], + 'exclude' => true, + 'inputType' => 'checkboxWizard', + 'foreignKey' => 'tl_mae_event_cat.title', + 'eval' => array('tl_class'=>'clr', 'multiple'=>true, 'fieldType'=>'checkbox', 'foreignTable'=>'tl_mae_event_cat', 'titleField'=>'title', 'searchField'=>'title'), + 'sql' => "blob NULL" ); \ No newline at end of file diff --git a/languages/de/tl_user.php b/languages/de/tl_user.php index f919186..d6fe0a8 100644 --- a/languages/de/tl_user.php +++ b/languages/de/tl_user.php @@ -2,4 +2,6 @@ /** * Fields */ -$GLOBALS['TL_LANG']['tl_user']['maeEventCat'] = array('Veranstaltungskategorien verwalten', 'Benutzer erlauben, Veranstaltungskategorien zu verwalten'); \ No newline at end of file +$GLOBALS['TL_LANG']['tl_user']['maeEventCat'] = array('Veranstaltungskategorien verwalten', 'Benutzer erlauben, Veranstaltungskategorien zu verwalten'); +$GLOBALS['TL_LANG']['tl_user']['default_event_categories'] = array('Standard Veranstaltungskategorien', 'Veranstaltungskategorien, die autom. bei von diesem User erstellten Events gesetzt werden sollen.'); +$GLOBALS['TL_LANG']['tl_user']['mae_evt_cat_legend'] = "Veranstaltungskategorien"; \ No newline at end of file diff --git a/languages/de/tl_user_group.php b/languages/de/tl_user_group.php index b04477d..a287407 100644 --- a/languages/de/tl_user_group.php +++ b/languages/de/tl_user_group.php @@ -2,4 +2,5 @@ /** * Load tl_user language file */ -\System::loadLanguageFile('tl_user'); \ No newline at end of file +\System::loadLanguageFile('tl_user'); +$GLOBALS['TL_LANG']['tl_user_group']['mae_evt_cat_legend'] = "Veranstaltungskategorien"; \ No newline at end of file diff --git a/languages/en/tl_user.php b/languages/en/tl_user.php index aee61a3..46ffafc 100644 --- a/languages/en/tl_user.php +++ b/languages/en/tl_user.php @@ -2,4 +2,6 @@ /** * Fields */ -$GLOBALS['TL_LANG']['tl_user']['maeEventCat'] = array('Manage event categories', 'enable the user to manage event categories'); \ No newline at end of file +$GLOBALS['TL_LANG']['tl_user']['maeEventCat'] = array('Manage event categories', 'enable the user to manage event categories'); +$GLOBALS['TL_LANG']['tl_user']['default_event_categories'] = array('Default event categories', 'event categories which should be automatically assigned to new events, created by this user/group.'); +$GLOBALS['TL_LANG']['tl_user']['mae_evt_cat_legend'] = "Event categories"; \ No newline at end of file diff --git a/languages/en/tl_user_group.php b/languages/en/tl_user_group.php index b04477d..b0b78d3 100644 --- a/languages/en/tl_user_group.php +++ b/languages/en/tl_user_group.php @@ -2,4 +2,5 @@ /** * Load tl_user language file */ -\System::loadLanguageFile('tl_user'); \ No newline at end of file +\System::loadLanguageFile('tl_user'); +$GLOBALS['TL_LANG']['tl_user_group']['mae_evt_cat_legend'] = "Event categories"; \ No newline at end of file