Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

_config.php Permission::check


Go to End


3 Posts   1404 Views

Avatar
dacar

Community Member, 173 Posts

22 March 2011 at 11:58pm

Hi,

does anybody know, how to set a permission check in _config.php to give different settings to different groups?
Permission::check doesn't work?

if(Permission::check('administrators')) {
HtmlEditorConfig::get('cms')->enablePlugins('safari','spellchecker','pagebreak','style','layer','table',
'save','advhr','advimage','advlink','emotions','iespell','inlinepopups','insertdatetime','preview','media',
'searchreplace','print','contextmenu','paste','directionality','fullscreen','noneditable','visualchars',
'nonbreaking','xhtmlxtras','template');
} else {

}

Greetings, Carsten

Avatar
Devlin

Community Member, 344 Posts

23 March 2011 at 6:11am

Well, if it's just the HTMLEditorConfig.

There is a "HTML Editor Configuration" field in the permission tab in security to select the config for this group.... if you specified another HTMLEditorConfig in your _config.php:

// default config
HTMLEditorConfig::get('cms')->setOption('language','de');
// config for group editors
HTMLEditorConfig::get('reduced')->setOption('friendly_name','reduced');
HTMLEditorConfig::get('reduced')->setButtonsForLine(1,'bold');

Avatar
dacar

Community Member, 173 Posts

23 March 2011 at 10:52am

Perfekto! Works great. But you have to be careful to enable the required plugins again.

// config for group editors 
HtmlEditorConfig::get('reduced')->setOption('language', 'de');
HtmlEditorConfig::get('reduced')->setOptions(array(
	'friendly_name' => 'Simple CMS',
	'priority' => '50',
	'mode' => 'none',
	'content_css' => 'themes/xxx/css/editor.css, '.(SSViewer::current_theme() ? THEMES_DIR . "/" . SSViewer::current_theme() : project()) . "/css/editor.css",
	'body_class' => 'content'
));
HtmlEditorConfig::get('reduced')->enablePlugins(array('ssbuttons' => '../../../cms/javascript/tinymce_ssbuttons/editor_plugin_src.js')); 
HTMLEditorConfig::get('reduced')->setOption('friendly_name','reduced'); 
HtmlEditorConfig::get('reduced')->disablePlugins('safari','spellchecker','pagebreak','style','layer','table','save','advhr','advimage','emotions','iespell','inlinepopups','insertdatetime','preview','media','searchreplace','print','contextmenu','paste','directionality','fullscreen','noneditable','visualchars','nonbreaking','xhtmlxtras','template'); 
HTMLEditorConfig::get('reduced')->setButtonsForLine(1,'save','bold','separator','cut','copy','paste','pastetext','pasteword','separator','bullist','numlist','separator','sslink','unlink','anchor');
HtmlEditorConfig::get('reduced')->setButtonsForLine(2,'');

Thanks a lot Devlin!