I was experiencing the behavior that while editing a user profile, changing the "Rich text editor settings" > "Default state" between Enabled and Disabled had no effect and behaved as if it was always enabled.
On the edit screen for users (user/%uid/edit
), there is a grouping of 5 settings under Rich text editor settings. These settings are stored in the data field of the given user's row in the users table. (SELECT data FROM users WHERE uid = %uid)
- Default state (ckeditor_default)
- Show the disable/enable rich text editor toggle (ckeditor_show_toggle)
- Editor width (ckeditor_width)
- Language (ckeditor_lang)
- Auto-detect language (ckeditor_auto_lang)
I traced all 5 settings through the process and made the following discoveries.
1. Fetching Settings
In includes/ckeditor.lib.inc at line 817, we populate $conf
with the user's selected settings. These values match what are defined on user/%uid/edit
. No problem here.
if (user_access('customize ckeditor')) {
foreach (array('default', 'show_toggle', 'width', 'lang', 'auto_lang') as $setting) {
$conf[$setting] = ckeditor_user_get_setting($user, $profile, $setting);
}
}
2. Persisting Settings
In includes/ckeditor.lib.inc at line 854, we copy the value of $conf['width']
with the user's selected setting for that. In subsequent lines, we also work with $conf['show_toggle']
(863), $conf['lang']
(846), and $conf['auto_lang']
(924). We do not see any occurrence of $conf['default']
being used and, since only $settings
is returned, we lose that setting. This is our first problem.
$settings['width'] = $conf['width'];
...
$settings['show_toggle'] = $conf['show_toggle'];
3. Referencing Settings
In includes/ckeditor.lib.inc at line 1431, we have the following:
if ($settings = ckeditor_profiles_compile($format)) {
$ckeditor_on = ($profile->settings['default'] == 't') ? TRUE : FALSE;
}
At first, I thought $profile->settings
would refer to the user profile settings. That is an incorrect assumption. In this context, $profile->settings['default']
calls for the value of the CKEditor Profile as listed on admin/config/content/ckeditor.
In looking for confirmation of this finding, line 1450 shows a fellow setting, show_toggle, getting it's value from $settings
:
if ($settings['show_toggle'] == 't' && $show_toggle) {
It appears that $profile
holds the CKEditor Profile settings while $settings
holds the default, user and custom (ckeditor.config.js) settings.
So, line 1432's call to $profile->settings['default'] is our second problem.
4. Summary
To fix this issue, we need to:
- ensure that ckeditor_default user setting is retained
- use that value as part of the decision making process
I have a patch for this and will upload shortly.
Comment | File | Size | Author |
---|---|---|---|
#4 | user_rich_text_default_state_obey-2574253-4.patch | 995 bytes | karenann |
#3 | user_rich_text_default_state_obey-2574253-3.patch | 995 bytes | karenann |
Comments
Comment #2
karenann CreditAttribution: karenann as a volunteer commentedThis patch should apply cleanly to 7.x-1.16 if I did everything correctly.
I do not believe it will apply cleanly after 7.x-1.16 and I am looking in to that.
Comment #3
karenann CreditAttribution: karenann as a volunteer commentedResubmitting 7.x-1.16 patch to queue for testing.
Comment #4
karenann CreditAttribution: karenann as a volunteer commentedSubmitting an additional patch that applies to the current 7.x-1.x branch.
Comment #6
jcisio CreditAttribution: jcisio at Axess Open Web Services commentedPatch looks good. I was wondering if we should only show CKEditor when it is enabled by BOTH admin and user. This is a behavior change, and I think the answer is YES because the CKEditor should not be enabled by default if user does not want it (and site admin allows user to configure that setting).
Committed and pushed, thanks.