mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FEATURE: Allow different user groups to have different HtmlEditorConfigs
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@84085 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
047d17d512
commit
38846653a2
@ -41,10 +41,27 @@ class HtmlEditorConfig {
|
||||
return self::get($identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available configurations as a map of friendly_name to
|
||||
* configuration name.
|
||||
* @return array
|
||||
*/
|
||||
static function get_available_configs_map() {
|
||||
$configs = array();
|
||||
|
||||
foreach(self::$configs as $identifier => $config) {
|
||||
$configs[$identifier] = $config->getOption('friendly_name');
|
||||
}
|
||||
|
||||
return $configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holder for all TinyMCE settings _except_ plugins and buttons
|
||||
*/
|
||||
protected $settings = array(
|
||||
'friendly_name' => '(Please set a friendly name for this config)',
|
||||
'priority' => 0,
|
||||
'mode' => "specific_textareas",
|
||||
'editor_selector' => "htmleditor",
|
||||
'width' => "100%",
|
||||
|
@ -14,6 +14,7 @@ class Group extends DataObject {
|
||||
"Locked" => "Boolean",
|
||||
"Sort" => "Int",
|
||||
"IPRestrictions" => "Text",
|
||||
"HtmlEditorConfig" => "Varchar"
|
||||
);
|
||||
|
||||
static $has_one = array(
|
||||
@ -63,6 +64,7 @@ class Group extends DataObject {
|
||||
) .
|
||||
"</p>"
|
||||
),
|
||||
new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', HtmlEditorConfig::get_available_configs_map()),
|
||||
new TableField(
|
||||
"Permissions",
|
||||
"Permission",
|
||||
|
@ -982,6 +982,27 @@ class Member extends DataObject {
|
||||
user_error('Member::isInGroup() is deprecated. Please use inGroup() instead.', E_USER_NOTICE);
|
||||
return $this->inGroup($groupID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HtmlEditorConfig for this user to be used in the CMS.
|
||||
* This is set by the group.
|
||||
* @return string
|
||||
*/
|
||||
function getHtmlEditorConfigForCMS() {
|
||||
$currentName = '';
|
||||
$currentPriority = 0;
|
||||
|
||||
foreach($this->Groups() as $group) {
|
||||
$configName = $group->HtmlEditorConfig;
|
||||
$config = HtmlEditorConfig::get($group->HtmlEditorConfig);
|
||||
if($config && $config->getOption('priority') > $currentPriority) {
|
||||
$currentName = $configName;
|
||||
}
|
||||
}
|
||||
|
||||
// If can't find a suitable editor, just default to cms
|
||||
return $currentName ? $currentName : 'cms';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1452,4 +1473,4 @@ class Member_Validator extends RequiredFields {
|
||||
// Initialize the static DB variables to add the supported encryption
|
||||
// algorithms to the PasswordEncryption Enum field
|
||||
Member::init_db_fields();
|
||||
?>
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user