Skip to content

Commit

Permalink
added default category rights
Browse files Browse the repository at this point in the history
  • Loading branch information
marebe1602 committed Dec 16, 2015
1 parent 281afc3 commit b281d79
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions classes/MaeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* Namespace
*/
namespace MaeEventCategories;
use Contao\Database;
use Contao\DataContainer;
use Contao\Input;
use Contao\System;


/**
Expand Down
33 changes: 33 additions & 0 deletions classes/MaeEventBe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Created by PhpStorm.
* User: martineberhardt
* Date: 16.12.15
* Time: 14:41
*/

namespace MaeEventCategories;


use Contao\Backend;
use Contao\Database;

class MaeEventBe extends Backend
{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
$this->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);
}
}
}
1 change: 1 addition & 0 deletions config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
));
Expand Down
1 change: 1 addition & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Add permissions
*/
$GLOBALS['TL_PERMISSIONS'][] = 'maeEventCat';
$GLOBALS['TL_PERMISSIONS'][] = 'maeEventCatDefault';

/**
* Front end modules
Expand Down
3 changes: 2 additions & 1 deletion dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
// new categories blob field
$GLOBALS['TL_DCA']['tl_calendar_events']['config']['oncreate_callback'][] = array("MaeEventCategories\\MaeEventBe", "setDefaultCategories");

$GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default'] = str_replace(";{date_legend}", ";{cat_legend:hide},categories;{date_legend}", $GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['default']);

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['categories'] = array
Expand Down
14 changes: 12 additions & 2 deletions dca/tl_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
/**
* Add a palette to tl_user
*/
$GLOBALS['TL_DCA']['tl_user']['palettes']['extend'] = str_replace('{calendars_legend}', '{calendars_legend},maeEventCat', $GLOBALS['TL_DCA']['tl_user']['palettes']['extend']);
$GLOBALS['TL_DCA']['tl_user']['palettes']['custom'] = str_replace('{calendars_legend}', '{calendars_legend},maeEventCat', $GLOBALS['TL_DCA']['tl_user']['palettes']['custom']);
$GLOBALS['TL_DCA']['tl_user']['palettes']['extend'] = str_replace('{calendars_legend}', '{mae_evt_cat_legend},maeEventCat,maeEventCatDefault;{calendars_legend}', $GLOBALS['TL_DCA']['tl_user']['palettes']['extend']);
$GLOBALS['TL_DCA']['tl_user']['palettes']['custom'] = str_replace('{calendars_legend}', '{mae_evt_cat_legend},maeEventCat,maeEventCatDefault;{calendars_legend}', $GLOBALS['TL_DCA']['tl_user']['palettes']['custom']);

/**
* Add a new field to tl_user
Expand All @@ -25,4 +25,14 @@
'exclude' => 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"
);
12 changes: 11 additions & 1 deletion dca/tl_user_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
);
4 changes: 3 additions & 1 deletion languages/de/tl_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/**
* Fields
*/
$GLOBALS['TL_LANG']['tl_user']['maeEventCat'] = array('Veranstaltungskategorien verwalten', 'Benutzer erlauben, Veranstaltungskategorien zu verwalten');
$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";
3 changes: 2 additions & 1 deletion languages/de/tl_user_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/**
* Load tl_user language file
*/
\System::loadLanguageFile('tl_user');
\System::loadLanguageFile('tl_user');
$GLOBALS['TL_LANG']['tl_user_group']['mae_evt_cat_legend'] = "Veranstaltungskategorien";
4 changes: 3 additions & 1 deletion languages/en/tl_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/**
* Fields
*/
$GLOBALS['TL_LANG']['tl_user']['maeEventCat'] = array('Manage event categories', 'enable the user to manage event categories');
$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";
3 changes: 2 additions & 1 deletion languages/en/tl_user_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/**
* Load tl_user language file
*/
\System::loadLanguageFile('tl_user');
\System::loadLanguageFile('tl_user');
$GLOBALS['TL_LANG']['tl_user_group']['mae_evt_cat_legend'] = "Event categories";

0 comments on commit b281d79

Please sign in to comment.