diff --git a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini index a1722886bef08..ec9ef674f4cd8 100644 --- a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini +++ b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini @@ -137,6 +137,7 @@ PLG_TINY_FIELD_VISUALCHARS_DESC="See invisible characters, specifically non-brea PLG_TINY_FIELD_VISUALCHARS_LABEL="Visualchars" PLG_TINY_FIELD_WORDCOUNT_DESC="Turn on/off Wordcount." PLG_TINY_FIELD_WORDCOUNT_LABEL="Wordcount" +PLG_TINY_LEGACY_WARNING="The TinyMCE Editor Plugin has been updated. At the moment, it uses your legacy configuration. By editing the plugin, you can now assign various layouts to specific user groups." PLG_TINY_SET_TITLE="Set %s" PLG_TINY_SET_PRESET_BUTTON_ADVANCED="Use advanced preset" PLG_TINY_SET_PRESET_BUTTON_MEDIUM="Use medium preset" diff --git a/media/editors/tinymce/js/tinymce-builder.js b/media/editors/tinymce/js/tinymce-builder.js index 25e45e85eaef8..f08418fda5f60 100644 --- a/media/editors/tinymce/js/tinymce-builder.js +++ b/media/editors/tinymce/js/tinymce-builder.js @@ -283,5 +283,34 @@ event.preventDefault(); $(this).tab("show"); }); + + // Allow to select the group only once per the set + var $accessSelects = $('#joomla-tinymce-builder').find('.access-select'); + toggleAvailableOption(); + $accessSelects.on('change', function () { + toggleAvailableOption(); + }); + + function toggleAvailableOption () { + $accessSelects.find('option[disabled]').removeAttr('disabled'); + + // Disable already selected options + $accessSelects.each(function () { + var $select = $(this), val = $select.val(), query = [], + $options = $accessSelects.not(this).find('option'); + + for (var i = 0, l = val.length; i < l; i++ ) { + if (!val[i]) continue; + query.push('[value="' + val[i] + '"]'); + } + + if (query.length) { + $options.filter(query.join(',')).attr('disabled', 'disabled'); + } + }); + + // Update Chosen + $accessSelects.trigger('liszt:updated'); + } }); }(jQuery)); diff --git a/plugins/editors/tinymce/field/tinymcebuilder.php b/plugins/editors/tinymce/field/tinymcebuilder.php index 216ccd5d6cca8..550ca742eb30a 100644 --- a/plugins/editors/tinymce/field/tinymcebuilder.php +++ b/plugins/editors/tinymce/field/tinymcebuilder.php @@ -44,8 +44,8 @@ class JFormFieldTinymceBuilder extends JFormField protected function getLayoutData() { $data = parent::getLayoutData(); - $valueAll = (object) $this->form->getValue('params'); - $setsAmount = empty($valueAll->sets_amount) ? 3 : $valueAll->sets_amount; + $paramsAll = (object) $this->form->getValue('params'); + $setsAmount = empty($paramsAll->sets_amount) ? 3 : $paramsAll->sets_amount; // Get the plugin require_once JPATH_PLUGINS . '/editors/tinymce/tinymce.php'; @@ -78,11 +78,18 @@ protected function getLayoutData() $setsForms = array(); $formsource = JPATH_PLUGINS . '/editors/tinymce/form/setoptions.xml'; - // Check the old values for B/C - $valueOld = new stdClass; - if ($this->value && empty($this->value['setoptions'])) + // Preload an old params for B/C + $setParams = new stdClass; + if (!empty($paramsAll->html_width) && empty($paramsAll->configuration['setoptions'])) { - $valueOld = $valueAll; + $plugin = JPluginHelper::getPlugin('editors', 'tinymce'); + + JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_TINY_LEGACY_WARNING', '#'), 'warning'); + + if (is_object($plugin) && !empty($plugin->params)) + { + $setParams = (object) json_decode($plugin->params); + } } foreach (array_keys($data['setsNames']) as $num) @@ -92,20 +99,24 @@ protected function getLayoutData() $setsForms[$num] = JForm::getInstance($formname, $formsource, array('control' => $control)); - // Bind the values - + // Check whether we already have saved values or it first time or even old params if (empty($this->value['setoptions'][$num])) { - $formValues = $valueOld; - - // Predefine access: 0 for special, 1 for registered, all else is public - $formValues->access = !$num ? 3 : ($num === 1 ? 2 : 1); + $formValues = $setParams; + + /* + * Predefine group: + * Set 0: for Administrator, Editor, Super Users (4,7,8) + * Set 1: for Registered, Manager (2,6), all else are public + */ + $formValues->access = !$num ? array(4,7,8) : ($num === 1 ? array(2,6) : 1); } else { $formValues = $this->value['setoptions'][$num]; } + // Bind the values $setsForms[$num]->bind($formValues); } diff --git a/plugins/editors/tinymce/form/setoptions.xml b/plugins/editors/tinymce/form/setoptions.xml index bc1cd781215b6..c3ef877471890 100644 --- a/plugins/editors/tinymce/form/setoptions.xml +++ b/plugins/editors/tinymce/form/setoptions.xml @@ -2,7 +2,9 @@