The Roles form is deleting roles not listed on the form. This happens in og_user_roles_page_form_submit.

How to reproduce:
- Add two roles.
- In the config at admin/og/og_user_roles add one role to the form and auto assign the other role to new group admins.
- When you use the roles form on the group og_user_roles_page_form_submit will remove the admin role as well.

og_user_roles_page_form_submit should only process the roles on the form itself.

Comments

pwolanin’s picture

I'm seeing this too, though it's frustrating that the automatic roles don't appear in the form at all at ?q=og/users/$gid/roles

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new2.98 KB

Here's a patch that fixes the bug and the usability issue of the automatic roles not being visible. Just the changes to function og_user_roles_page_form_submit() are enough to fix the bug of the roles being removed.

re-used a t() string, so no alteration to .po files needed.

pwolanin’s picture

StatusFileSize
new46.51 KB

Here's a screen shot showing the altered table.

sun’s picture

Thanks!

Unfortunately, it seems like the whole default roles functionality is not tested yet. :-/ Would it be too much to ask you to also enhance the tests?

+++ og_user_roles.pages.inc	13 Nov 2009 21:13:26 -0000
@@ -109,12 +110,24 @@ function og_user_roles_page_form($form_s
+    $auto_role_names = array();
...
+    $form['user_roles'][$account->uid]['automatic_roles'] = array(

This variable + form structure key should be named $default_roles.

+++ og_user_roles.pages.inc	13 Nov 2009 21:13:26 -0000
@@ -109,12 +110,24 @@ function og_user_roles_page_form($form_s
+      '#type' => 'markup',

We can skip the #type here.

+++ og_user_roles.pages.inc	13 Nov 2009 21:13:26 -0000
@@ -143,12 +158,13 @@ function og_user_roles_page_form_submit(
+  $header = array_merge(array('', '<em>'. t('Default role assignments') .'</em>'), $form['#roles']);

Please remove the <em> and shorten to "Default roles".

This review is powered by Dreditor.

pwolanin’s picture

I tested the defaults by hand - and mfer is using them. I can re-roll the patch, but don't really have the time to code up tests right now.

hmm, I guess there are no translations yet - I was trying to re-use the t() string t('Default role assignments')

I used the EM tags to highlight the fact that this heading was not a role name - some other approach?

pwolanin’s picture

StatusFileSize
new3 KB

Here's a re-roll. Moves the check_plain() of role names to an array_map() call so as to keep doing it for the same strings for many users.

mfer’s picture

Status: Needs review » Reviewed & tested by the community

I've tested the patch and it works.

sun’s picture

Version: 6.x-4.x-dev » 6.x-4.0
StatusFileSize
new11.93 KB

ok, I took the time to parse the original post into a test that does exactly the same.

And, indeed, the last assertion is failing.

I committed attached patch to HEAD. Let's see whether this patch makes it work. :)

sun’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new4.26 KB

Thanks for reporting, reviewing, and testing! Committed attached patch to HEAD.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status: Fixed » Closed (fixed)

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

sun’s picture

Title: og_user_roles_page_form_submit deleting admin roles. » og_user_roles_page_form_submit deleting admin roles
Status: Closed (fixed) » Needs work

Looking at the resulting screen by coincidence in http://localize.drupal.org/node/616...

Only local images are allowed.

It looks like we should skip the "Default roles" column entirely when no default roles have been assigned?

sun’s picture

Status: Needs work » Closed (fixed)

well, let it be a different issue.