--- tinymce.module 2006-07-25 22:36:11.000000000 -0400 +++ tinymce.new.module 2006-07-26 01:52:46.000000000 -0400 @@ -85,13 +85,28 @@ function tinymce_process_textarea($eleme // Since tinymce_config() makes a db hit, only call it when we're pretty sure // we're gonna render tinymce. if (!$profile_name) { - $profile_name = db_result(db_query('SELECT s.name FROM {tinymce_settings} s INNER JOIN {tinymce_role} r ON r.name = s.name WHERE r.rid IN (%s)', implode(',', array_keys($user->roles)))); + $profile_count = 0; + $profile = NULL; + $profiles = db_query('SELECT DISTINCT(s.name) FROM {tinymce_settings} s INNER JOIN {tinymce_role} r ON r.name = s.name WHERE r.rid IN (%s)', implode(',', array_keys($user->roles))); + while ($data = db_fetch_object($profiles)) { + if (_tinymce_page_match($test_profile = tinymce_profile_load($data->name))) { + $profile = $test_profile; + $profile_count++; + } + } + + if ($profile_count > 1) { + drupal_set_message(t('More than one tinymce profile was configured to show on this page.'), 'error'); + } } - $profile = tinymce_profile_load($profile_name); + else { + $profile = tinymce_profile_load($profile_name); + } + $init = tinymce_config($profile); $init['elements'] = 'edit-'. $textarea_name; - if (_tinymce_page_match($profile)) { + if ($profile != NULL) { // Merge user-defined TinyMCE settings. $init = (array) theme('tinymce_theme', $init, $textarea_name, $init['theme'], $is_running); @@ -626,8 +641,8 @@ function tinymce_profile_delete($name) { function tinymce_profile_form($edit) { $edit = (object) $edit; - // Only display the roles that currently don't have a tinymce profile. One - // profile per role. + // Display all roles because there can be more than one profile per role + // Display a warning when roles can overlap $orig_roles = user_roles(FALSE, 'access tinymce'); $roles = $orig_roles; if (arg(3) == 'add') { @@ -640,11 +655,8 @@ function tinymce_profile_form($edit) { if (!$orig_roles) { drupal_set_message(t('You must assign at least one role with the \'access tinymce\' permission before creating a profile.', array('%access-control-url' => url('admin/access'))), 'error'); } - else if (!$roles) { - drupal_set_message(t('You will not be allowed to create a new profile since all user roles have already been assigned profiles. Either remove an existing tinymce profile from at least one role or assign another role the \'access tinymce\' permission.'), 'error'); - } else if (count($orig_roles) != count($roles)) { - drupal_set_message(t('Not all user roles are shown since they already have tinymce profiles. You must first unassign profiles in order to add them to a new one.')); + drupal_set_message(t('Some roles have already been used in a different profile. You should only select the same roles for two or more profiles when you are positive the profiles will not be accesible on the same page because of your visibility options.')); } $btn = t('Create profile'); } @@ -674,7 +686,7 @@ function tinymce_profile_form($edit) { '#type' => 'checkboxes', '#title' => t('Roles allowed to use this profile'), '#default_value' => array_keys((array) $edit->rids), - '#options' => $roles, + '#options' => $orig_roles, '#description' => t('Check at least one role. Only roles with \'access tinymce\' permission will be shown here.'), '#required' => TRUE );