Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
what happens if a user is member of more than one group and say one of this group has access to a more advanced profile.
Which one does tinymce load?
the one which is in the first line of a sql query.
you can find it at tinymce_process_textarea() on line 88.
$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))));
I came up with two solutions:
- add a new field "weight" to tinymce_settings and let us specify priorities for our profiles
- use role_weights.module which loads the tinymce profile of the role with the highest weight.
I think both solutions have a right to stay...
so please tell me what YOU think would be the best solution...
Comment | File | Size | Author |
---|---|---|---|
#8 | multiple_roles.patch.txt | 3.49 KB | andrewlevine |
#4 | profile_weight.patch_0.txt | 4.09 KB | Tobias Maier |
#2 | profile_weight.patch.txt | 3.18 KB | Tobias Maier |
Comments
Comment #1
buddaI vote for use of the new role-weights module. I need to do the same for my path_access module too.
Comment #2
Tobias Maier CreditAttribution: Tobias Maier commentedI had a little bit time and was lazy so I did the first way...
here is a patch
we need an update for the .install file too but I have no time anymore (for today)
you have to add a new column to the table tinymce_settings
called "weight" type: tinyint length: 1
Comment #3
m3avrck CreditAttribution: m3avrck commentedTobia, I like your patch, that seems to make the most sense.
I'm not entirely sold on the role_weights module, so let's here some more thought on that. I'll commit a patch that fixes it once we decide :)
Comment #4
Tobias Maier CreditAttribution: Tobias Maier commentedhere it comes with the update path :)
i think its ready
Comment #5
pwolanin CreditAttribution: pwolanin commentedI have a patch posted here for what I think is the same problem:
http://drupal.org/node/66014
I took an even simpler approach- I just load the profile associated with the highest Role ID.
I think this will address 95% of the use cases, since it easily allows one to use different profiles for:
I'd appreciate your feedback on this approach.
Comment #6
Tobias Maier CreditAttribution: Tobias Maier commentedI want to know if there is any interest to get this in?
I dont like the idea to use the role_weigths.module, because
1. It depends on another module
2. the user has to grock out that he has to give a specific role a specific weight somewhere which effects which one of the text editors loads... not really user friendly and not really wide spread at drupal to do so...
I'm using this since months on three sites without any problem.
Comment #7
pwolanin CreditAttribution: pwolanin commentedI think that there is a real problem, and inluding one of these solutions in the module is important. I don't have particularly strong feelsings about which is the "best" solution.
Comment #8
andrewlevine CreditAttribution: andrewlevine commentedThis patch is a solution to this problem that I believe will be much more flexible.
I came across this problem when I was trying to have two tinymce profiles for the same role, one for a specific node-type that required less buttons and one for every other node-type. My patch allows as many profiles as needed per role and checks them all with _tinymce_page_match (visibility option in admin/settings). Only one profile should match and be displayed. If more or less than 1 profile matches, tinymce is disabled.
This allows users to configure profiles to be displayed by role-weights or node-types or ANYTHING else as defined in the Visibility options.
Comment #9
AlanT CreditAttribution: AlanT commentedJust installed the patch file "profile_weight.patch_0.txt" and have to report that this is exactly what I wanted!
Thank you very much. Hopefully this will get into the main distribution.
Comment #10
NickHBO CreditAttribution: NickHBO commentedandrewlevine, I like your patch the best, it is the most functional. I really hope your patch gets into the next release of TinyMCE because it fixes all the problems I've run into related to roles and profiles.
There is one minor problem that is more of an annoyance than a problem. I'll explain my setup first, so this is easier to understand.
I have a role called "writer", it is automatically an "authenticated user" because Drupal doesn't let you deselect that role for a user. I have two profiles setup, one for "authenticated user" and another for "writer"; the "writer" role has more TinyMCE features than the "authenticated user". Both of these roles need to be able to post comments using TinyMCE so I have configured them to show up on "comments/*" in the Visibility section.
Here's where the annoyance comes in. Since a "writer" is also an "authenticated user", the "More than one tinymce profile was configured to show on this page." message is displayed on the comments page. This message is irrelevant because the profiles are intended for two completely different sets of users.
It's my opinion that if a user has a custom role (a role that is not "anonymous user" or "authenticated user"), then the "authenticated user" role (and all profiles setup with no custom roles) should be ignored by TinyMCE's profiles for that user. This would ensure that the custom role user is always getting the proper profile and it would stop the message from appearing unnecessarily.
Thanks for the great patch, besides that one minor issue it's working great for me! Hopefully you or someone capable (I'm sure not) can fix up the custom role / "authenticated user" situation.
Nick
Comment #11
pwolanin CreditAttribution: pwolanin commentedYes, this problem needs to be fixed in some way- did you look at the extremely simple fixed I came up with: http://drupal.org/node/66014
Comment #12
andrewlevine CreditAttribution: andrewlevine commentedNickHBO,
The best part of my patch is that you don't have to remember defaults or orders of roles. If you configure in the visibility options for two different profiles to both show up on the same page under the same conditions, that is wrong.
Here is what you would do with my patch (I haven't ran the code so there may be an error or two):
Put this under Visibility options in "Show if the PHP code returns TRUE" in the authenticated user tinymce profile:
This will prevent the profile from matching when the user has the writer role.
Comment #13
NickHBO CreditAttribution: NickHBO commentedpwolanin, I did take a look at your patch but I didn't install it. From what I read, it seemed like your patch only handled picking the highest role number (for example "writer" [3] over "authenticated user" [2]) and had no way to determining what profile to use in the instance that one role had more than one profile (for different pages on the site, of course).
Having more than one profile is necessary if you want to have a "simple" profile for "writer" to use on comments/* and an "advanced" profile for "writer" to use on node/* - that's my full setup (I said I only had 2 profiles in my previous reply to keep the point concise). If your patch handles this case, I'll give it a shot as well.
andrewlevine, I tried that code in the Visibility settings (and made sure I changed the radio button to PHP), but it had no effect. The code produced no errors on the pages or in watchdog, it still showed the conflict error.
I realize that having two different roles show up on the same page under the same conditions is wrong. However, that's my whole point; it is not desirable to evaluate the "authenticated user" role if a user has a higher role. There is no way to remove the "authenticated user" role from users with custom roles and this leads to the error message showing when it does not have to.
I've got Profile 1 that is for "authenticated user" and it has very simple buttons; Profile 2 is for "writer" and it has additional buttons (thus why it is a separate profile). Each role needs to see their respective profile on the comments page (the second radio button and comments/* are set for each profile), but the error message will always be displayed because "writer" is also an "authenticated user".
That's the reason why I suggested ignoring "authenticated user" status when a custom role (anything >2?) exists, I can't think of a situation where you would want to take the "authenticated user" permissions over those you setup for a custom role.
I hope I'm communicating the issue clearly enough, it's a bit hard to explain with just words.
Nick
Comment #14
andrewlevine CreditAttribution: andrewlevine commentedNickHBO,
The code I gave you not working and the problem of dealing with the authenticated role in general are two separate problems.
With the solution I have proposed the "authenticated role problem" does not exist. In my opinion adding more complexity in the form of defaults is counter-productive.
Whether my patch or code snippet has bugs is another question. I'd love to try to debug if you contact me via my contact page on this site (as I believe this is not the place for this). We can scratch each others backs.
Comment #15
andrewlevine CreditAttribution: andrewlevine commentedNickHBO,
I just tested my patch and the code I gave you in a configuration similar to the one you described and it worked.
So I'm not sure what's wrong. Contact me through my contact form if you still need help.
Comment #16
bbnet CreditAttribution: bbnet commentedWhile not a fix, a quick workaround for a simple scenario with only an 'advanced' and 'default' profile is to setup the advanced first then the default profile in drupal/admin/settings/tinymce/
Comment #17
matt@antinomia CreditAttribution: matt@antinomia commentedReporting: I just patched with andrewlevine's multiple_roles.patch.txt and used the visibility code provided. Everything seems to be working great. I'll report back with any problems.
Comment #18
AdrianB CreditAttribution: AdrianB commentedHas anyone used these patches with the current 5.x-1.x-dev?
Comment #19
flanderz CreditAttribution: flanderz commentedI haven't used the "multiple roles" patch but I have looked at the code. I still think it falls short. My usecase (and I think its a common one) is when you want the TinyMCE buttons to match up with your HTML filter rules. If you have a series of filter rules that are less and less restrictive, then you should be able to use the corresponding TinyMCE profile.
I don't know what the weighted roles module is but I don't think its necessary to have a dependency on another module. We just need a simple weight field similar to that used in many other modules. If multiple modules are associated with the user's role(s) then the one with the lowest weight is selected.
Comment #20
m3avrck CreditAttribution: m3avrck commentedDarren has another approach that is similar: http://drupal.org/node/132198 -- what do ya'll think?
Comment #21
Darren OhLet's consolidate our work in one place.
Comment #22
Darren OhThis issue is older. Marked mine as duplicate.
Comment #23
Darren OhComment #24
sunBetter title.
IMHO this might be a show-stopper for custom Drupal setups, but basically it is a feature.
Comment #25
Darren OhI'd say we already have the feature and it's not working. What's the use of profiles for roles if every user is using the authenticated user profile no matter what his role?
Comment #26
Vallenwood CreditAttribution: Vallenwood commentedHere are my thoughts on this subject. There are two separate needs being addressed in this thread, both important:
In my judgment, TinyMCE needs to recognize role weights, and without requiring another plugin. That, I think we all agree on here.
Here is my summary of the pros and cons of each approach so far:
comment/*
under "Show on only the listed pages" for the "Simple Profile," andnode/*
under "Show on only the listed pages" for the "Complicated Profile." Now if you are an Administrator, you'll get the simple editor when commenting and the complicated one when adding a node. This will guarantee they won't conflict. But you are perfectly free to put in Visibility rules which do conflict, in which case you get an error message and no tinyMCE editor shows up at all on that page! Therefore, andrewlevine's solution is merely a workaround. Here are my thoughts on it:tinymce_process_textarea
! In many cases, no tinyMCE is loaded at all an no error message thrown.My conclusion?
This issue remains UNSOLVED. In the meantime, Tobias's solution is a solid one which I believe the maintainers should roll into the module right away because it is a non-destructive improvement.
However, ultimately, the solution this module needs is one which successfully addresses both of the following needs:
It occurs to me that this would require a very good interface; I propose a separate primary-task tab. I propose that you detach the access and visibility settings from profiles and have them managed separately.
So you'd have "TinyMCE settings" page, an the first (and default) tab would be "Profiles." Then the second tab would be "Access." The "Profiles" tab would look very much like it does now--but when you edit a Profile, there are no longer select boxes for roles or a Visibility box. All of that would be moved to the "Access" page.
Under "Access," you would have a list of the Profiles you've created, each as a collapsible fieldset you click on to expand. So if you created a Profile called "Site Editor," you'd click on it, expand it, and see a bunch of form options. For each profile you would see:
Because Profiles are detached from Access, you can apply profiles at will to roles and pages, regardless of multiple types assigned to the same role. To manage profile collision (a problem that ultimately dooms andrewlevine's solution), each profile on the Access page would have its own weight, as specified in point one above. So when a page is loaded which had two profiles set for the same user level, it picks the one with the lower weight! This would allow for some pretty complicated setups without ever breaking.
(To make all this work easier, you could have a "duplicate" or "clone" link next to each profile, so you can quickly fill up profiles and apply them to different pages on the Access tab.)
This would also allow for future expandability, in case you wanted to add more complicated rules to the "Access" page, such as only showing the tinymce editor on one textarea but not to another on the same page.
That's my proposal!
Comment #27
sunLet me try a simpler approach for this issue:
- Profiles differ in the amount of features TinyMCE offers.
- The problem here is, that a user with more permissions gets a profile intended for users with lesser permissions.
- Profile weights are nasty.
Instead of weighting profiles, weighting roles or sorting after ids, we want to get the profile with the maximum amount of features for a specific user.
Thus, why don't we count the number of enabled plugins in a profile, save this count for each profile in the database and add
ORDER BY plugin_count DESC
?Comment #28
weimeng CreditAttribution: weimeng commentedSubscribing.
Comment #29
jetojedno CreditAttribution: jetojedno commentedI like the suggestion except that it's too complex, and the number of options in the "Access" tab are likely to confuse people. Can I suggest two possible solutions:
- that item 2 on the tab is dropped, as changing the weighting under specific circumstances is the same as making the demoted profiles not visible under those circumstances. Or make item 3 return a weighting rather than visible / not-visible.
or
- the Profiles have two separate sets of information in them, those that affect TinyMCE's behaviour and integration with other modules and those that affect the button's etc. available. These need to be controlled separately. The buttons etc. are "additive" in the sense that you can create a basic profile and then add more features as people are either more expert or more trusted. The behaviour and integration stuff tends to be about how the site is set up, so less likely to change in different circumstances.
Comment #30
trumpcar CreditAttribution: trumpcar commentedHello everyone,
This is a great thread. Thanks to everyone for their hard work.
I am attempting to patch the most recent development snapshot of TinyMCE via Tobias' patch in comment #4. I first attempted the patch on the most recent stable release, 5.x-1.9. Attempting the patch of both resulted in patch errors.
Please excuse me if this is obvious, but can someone recommend an approach to patch the most recent version of the TinyMCE module with this patch?
Many thanks...
Comment #31
OliverColeman CreditAttribution: OliverColeman commentedI've been running the patch in http://drupal.org/node/132198#comment-534721 for about a year now on a dev release of TinyMCE for many sites without a single issue. I can't/won't upgrade to the latest version (1.9) as this breaks the patch. I suppose that's what you get for using patches, but it's the only solution that nicely addresses the very common case of a user with multiple roles being randomly shown a less featureful TinyMCE interface than intended, which is a common "show-stopper" (hence change to bug report and critical).
When is this problem going to be addressed in a release? This has been an issue for about 2 years now...
I'm unassigning it from Tobias as his last post on this was 9 months ago, he's not in the developer list, and perhaps having no-one assigned will get some attention. :P
Comment #32
husztisanyi CreditAttribution: husztisanyi commentedhttp://drupal.org/node/181798#comment-792447
Comment #33
guillem CreditAttribution: guillem commentedhusztisanyi: you're the best!!!
But, this still a bug for developers!!!!
Comment #34
sun#27 has been implemented in Wysiwyg Editor module now. (see http://drupal.org/cvs?commit=120098)
Comment #35
OliverColeman CreditAttribution: OliverColeman commentedAlso, I've posted an updated version of the patch in http://drupal.org/node/132198#comment-534721 for tinyMCE 5.x-1.9 at http://drupal.org/node/132198#comment-1181848
Comment #36
sunThis is no longer needed, since the overall approach of defining multiple, unrelated profiles was wrong. Please read the announcement on http://drupal.org/project/tinymce and upgrade to http://drupal.org/project/wysiwyg
Comment #37
Aren Cambre CreditAttribution: Aren Cambre commented[oops, put this in the wrong issue. deleting]