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:

  1. ensure that ckeditor_default user setting is retained
  2. use that value as part of the decision making process

I have a patch for this and will upload shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

karenann created an issue. See original summary.

karenann’s picture

This 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.

karenann’s picture

Status: Active » Needs review
FileSize
995 bytes

Resubmitting 7.x-1.16 patch to queue for testing.

karenann’s picture

Submitting an additional patch that applies to the current 7.x-1.x branch.

  • jcisio committed 292de93 on 7.x-1.x authored by karenann
    Issue #2574253 by karenann: User specific "Default state" setting is not...
jcisio’s picture

Status: Needs review » Fixed

Patch 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.