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.

General Questions

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

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

_config.php Permission::check


Reply

3 Posts   946 Views

Avatar
dacar

22 March 2011 at 11:58pm Community Member, 168 Posts

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

23 March 2011 at 6:11am Community Member, 215 Posts

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

23 March 2011 at 10:52am Community Member, 168 Posts

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!