Permalink
Browse files

ENHANCEMENT Only show 'HTML Editor Config' dropdown in Group->getCMSF…

…ields() if more than one option exists

BUGFIX Fixed bogus HTMLEditorConfig instance when get() is called without a valid identifier (due to NULL database columns)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@99599 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 9c00cac commit 09de9f7834444e2817384633d28a604454867905 @chillu chillu committed Feb 22, 2010
Showing with 21 additions and 6 deletions.
  1. +13 −2 security/Group.php
  2. +8 −4 security/Member.php
View
@@ -65,7 +65,6 @@ public function getCMSFields() {
) .
"</p>"
),
- new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', HtmlEditorConfig::get_available_configs_map()),
new PermissionCheckboxSetField(
'Permissions',
singleton('Permission')->i18n_plural_name(),
@@ -90,7 +89,19 @@ public function getCMSFields() {
)
);
-
+ // Only add a dropdown for HTML editor configurations if more than one is available.
+ // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
+ $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
+ if(count($editorConfigMap) > 1) {
+ $fields->addFieldToTab('Root.Permissions',
+ new DropdownField(
+ 'HtmlEditorConfig',
+ 'HTML Editor Configuration',
+ $editorConfigMap
+ ),
+ 'Permissions'
+ );
+ }
if(!Permission::check('EDIT_PERMISSIONS')) {
$fields->removeFieldFromTab('Root', 'Permissions');
View
@@ -1164,7 +1164,9 @@ function registerFailedLogin() {
/**
* Get the HtmlEditorConfig for this user to be used in the CMS.
- * This is set by the group.
+ * This is set by the group. If multiple configurations are set,
+ * the one with the highest priority wins.
+ *
* @return string
*/
function getHtmlEditorConfigForCMS() {
@@ -1173,9 +1175,11 @@ function getHtmlEditorConfigForCMS() {
foreach($this->Groups() as $group) {
$configName = $group->HtmlEditorConfig;
- $config = HtmlEditorConfig::get($group->HtmlEditorConfig);
- if($config && $config->getOption('priority') > $currentPriority) {
- $currentName = $configName;
+ if($configName) {
+ $config = HtmlEditorConfig::get($group->HtmlEditorConfig);
+ if($config && $config->getOption('priority') > $currentPriority) {
+ $currentName = $configName;
+ }
}
}

0 comments on commit 09de9f7

Please sign in to comment.