First off I think the new version of og_user_roles is great, much easier to configure because of it's simplicity. That said, there were features in the 1.x line that I am interested in. More specifically the "restricted roles" functionality. I can't find any mention of it outside the message about the initial fork. Is that because no one has taken it on yet?

Comments

sun’s picture

Status: Active » Postponed (maintainer needs more info)

What's the "restricted roles" functionality?

pgillis’s picture

It gives you the ability to set OG specific roles that apply to a given group that are not managed by group admins. So for example you have the following two roles:

publisher
layout-editor

You want the group admin to be able to designate publishers for their group at will, which they can do with the module at present.

Now, layout-editor is a far more powerful role and you want your site admins to control who gets it yet limit it to a group context. If I grant it outside og_user_roles, the role will apply site wide.

I hope that makes sense.

sun’s picture

Not sure I fully understand. Like,

Currently, additionally roles within a group context are granted by group admins individually for each group member. The site admin globally configures, which roles can be assigned by group admins.

You want:

Additionally, site admins should be able to do the same as group admins (already the case?). But a site admin is able to grant any role, not only those that can be granted by group admins.

Visually just meaning that everything stays the same for group admins. Site admins, unlike group admins, will see all available (or a globally configurable list of) user roles on og/users/%/roles.

Technically, requires to

- make group user role assignments relative instead of absolute. When group admins are changing a user's roles, there are not checkboxes for all possible roles in the form. Before revoking a role, form handling needs to check whether the role could be selected in the form in the first place.

- either add a globally configured list of roles available to grant for site admins, or alternatively and perhaps cleaner, add new permissions in the kind of "grant %name role". Perhaps the permission idea should be a separate issue, but I find it interesting, because it might be able to replace the current global selection of available roles per group content type.

pgillis’s picture

Yes, you have it.

You are correct site admins can already do the same as group admins. Regarding the list of roles, perhaps a separate tab with the extra "restricted" roles that only site admins can see that shows any role in the system, or a second set of roles configured as restricted.

Group admins would see no change and only the site admins would see an extra tab and perhaps have to configure another set of available roles, the ones restricted to their control.

sun’s picture

Title: Missing functionality from 1.x line...where is this work being done? » Allow site admins to grant any role
Version: 6.x-4.1 » 6.x-4.x-dev
Status: Postponed (maintainer needs more info) » Active

Why a separate tab?

pgillis’s picture

You don't need a separate tab. It just seems like an easy way to filter out the restricted roles from the regular role list for the group admins. Could use other UI techniques to make it obvious they can't manage some of the roles in the original tab.

sun’s picture

Do we need to display other roles for group admins? I don't think so. What I effectively have in mind is pretty simple:

1) You are group admin. On og/users/%/roles, you see the user list and can grant group-specific roles to individual users. You can grant the available/shown roles only.

2) You are site admin. On og/users/%/roles, you see the user list and can grant group-specific roles to individual users. You see all roles that exist and can grant any roles.

Though really not sure about the "all roles". We'd have to limit to certain globally configured ones.

--

Now that we know what we want and can be done, I have to amend that I won't have time to work on this feature. However, happy to review and commit patches.

pgillis’s picture

Yeah, that would work. I agree, there should be a way to limit "all roles" to some globally defined list.

I should be able to put some time into this, although it'll take me a little time to get my head around how everything works. I'm an experienced programmer that is new to Drupal. Hopefully I have something for you to look at in the next few weeks...thanks.

pgillis’s picture

Title: Allow site admins to grant any role » Allow site admins to grant any role to group context
Assigned: Unassigned » pgillis
sun’s picture

Cool, ok. If you're new to Drupal development, I'd highly recommend to "post early post often" patches. I.e., instead of ramping up a giant patch after days of work, post your steps here and ask/wait for feedback on whether the changes are way to go. :)

pgillis’s picture

Status: Active » Needs review
StatusFileSize
new1.75 KB

I have attached a patch for this feature. It does three things:

1. It adds a new permission required for the user to see this new functionality. I named it "grant any role for group" Not too happy with that name, but it's the best I could come up with.
2. When the user has that permission it adds all the other roles(excluding anonymous and authenticated user) to the Configure Roles page.
3. Depending on whether the user has "override group default role" it tries to behave like the original.

I have set the status to needs review. Let me know what you think. Thanks!!

sun’s picture

Status: Needs review » Needs work

Thanks!

+++ og_user_roles-LOCAL/og_user_roles.module	2010-08-19 11:21:09.000000000 -0400
@@ -31,6 +31,7 @@ function og_user_roles_perm() {
+    'grant any role for group',

Do we need a new permission for this? Currently, the global administration options are accessible through the "administer organic groups" permission (of OG) only. I'd prefer to re-use that permission for this enhancement, unless your use-case requirements actually demand for a separate permission.

+++ og_user_roles-LOCAL/og_user_roles.pages.inc	2010-08-19 15:29:11.000000000 -0400
@@ -1,4 +1,5 @@
 <?php
+
 // $Id: og_user_roles.pages.inc,v 1.5 2009/12/06 19:26:37 sun Exp $

Please revert :)

+++ og_user_roles-LOCAL/og_user_roles.pages.inc	2010-08-19 15:29:11.000000000 -0400
@@ -76,7 +77,21 @@ function og_user_roles_admin_settings() 
+    $roles = user_roles(true);

All Booleans (TRUE/FALSE/NULL) are written all-uppercase in Drupal.

+++ og_user_roles-LOCAL/og_user_roles.pages.inc	2010-08-19 15:29:11.000000000 -0400
@@ -76,7 +77,21 @@ function og_user_roles_admin_settings() 
+    // Remove roles that do not belong in the list
+    $default_member = og_user_roles_get_group_default_role($node->nid);
+    $default_admin = null;
+    foreach ($roles as $rid => $name) {
+      if ($rid == DRUPAL_AUTHENTICATED_RID || (($rid == $default_member || $rid == $default_admin) && !user_access('override group default role'))) {

I'm not sure whether I understand the logic applied here (the comment doesn't help much either [but should]), and, it seems like $default_admin will be always be NULL?

Additionally, I think that the "override group default role" permission only applies to the default role for members, not for group admins.

Powered by Dreditor.

pgillis’s picture

Thanks for all the feedback!

Hmm, you may be right about not needing the new permission, let me give it another go.

I will clean up the other format errors along with removing the "default_admin" code. I thought there was going to be analogous functionality to default role role functionality. Suffice to say, the logic is attempting to remove roles that should not be managed:

1. Anonymous is filtered in the original list
2. Authenticated user
3. Default role is filtered out unless then have the permission to override(to be consistent with the stock behavior)

I'll upload another patch later today...thanks!

pgillis’s picture

Status: Needs work » Needs review
StatusFileSize
new806 bytes

I have attached a new patch. You were right, I can just use the "administer organic groups" groups permission. Hope the rest makes sense now as well...thanks!

EDIT: Bad patch file...see next comment...

pgillis’s picture

StatusFileSize
new1.24 KB

Attached is the proper patch. Forgot some options on my diff command line:(

pgillis’s picture

StatusFileSize
new1.24 KB

Attached is the proper patch. Forgot some options on my diff command line:(

sun’s picture

Thanks for working on this issue, pgillis!

I think we are pretty close already. Did you test this manually, using different users with varying group admin privileges? That said, do you know how to write simpletests? OGUR already implements some first tests in ./tests/og_user_roles.test, and normally, every new feature has to come along with corresponding tests... writing them is pretty easy. If existing test code is not sufficient, then there are plenty of docs here: http://drupal.org/simpletest

+++ og_user_roles/og_user_roles.pages.inc	2010-08-23 11:59:50.000000000 -0400
@@ -76,7 +76,20 @@ function og_user_roles_admin_settings() 
+  //If the user can administer orgranic groups, give them access to more roles
...
+    // Filter out special system roles along with the default group role, unless override is enabled

Minor stylistic issues, as mentioned on http://drupal.org/node/1354:

1) There should be a single space after //

2) Comments should not exceed 80 chars. (Except of phpDoc function summaries.)

3) All code comments should form proper sentences, i.e., end with a period (full-stop).

4) Typo in "orgranic".

Major issue:

5) Reading these comments, they merely explain what the code more or less tells me, too. Code comments should explain the non-obvious and non-trivial only:

- Why are we doing this here? (What's the goal after all?)

- Why only for users with "administer organic groups" permission?

- Why do we filter out the default group role?

- Why do we NOT filter out the default group role if override is enabled? Also, what kind of override, and where?

+++ og_user_roles/og_user_roles.pages.inc	2010-08-23 11:59:50.000000000 -0400
@@ -76,7 +76,20 @@ function og_user_roles_admin_settings() 
+      if ($rid == DRUPAL_AUTHENTICATED_RID || ($rid == $default_member && !user_access('override group default role'))) {

Hm. This feature has to presume that not all roles may be contained in the form that is submitted. In turn, we can only change roles relatively.

Here, the default member role is excluded from the roles that can be assigned. What happens if the default member role is changed? --- Just a unverified consideration, which we should double-check.

Powered by Dreditor.

pgillis’s picture

I'll work on the tests and the comments...

Regarding your last 2 comments...

This feature has to presume that not all roles may be contained in the form that is submitted. In turn, we can only change roles relatively.

Do you mean there is a limit that may potentially be hit based on the number of roles in the system?

Here, the default member role is excluded from the roles that can be assigned. What happens if the default member role is changed?

In my mind, what used to be default role will be displayed and the new default role hidden. Or more accurately, shown as read-only. Perhaps it's best to not bother treating the default role in any different manner? I struggle with this piece because it is probably more useful to make it available across the board. In the current system, when you change the default role, it does not get assigned to existing members and this would provide a way to solve that. What do you think?

sun’s picture

Default role handling is a pretty complex topic, which is discussed over in #614024: Default roles are not applied to existing group members/admins currently.

For this patch, we just need to ensure that we don't break nothing of the current default role functionality. (which I'd have to review in detail myself first -- thus my question for ensuring our expectations via tests ;)

pgillis’s picture

Status: Needs review » Needs work
held69’s picture

subscribing

pgillis’s picture

Assigned: pgillis » Unassigned

Removed myself as assignee. This module doesn't exist in drupal 7, so I don't think it will be added.

pgillis’s picture

Status: Needs work » Active