Assigning Different Roles to Different Groups

Darren Oh - August 13, 2006 - 03:25
Project:OG promote
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

It would be nice to have the ability to maintain different groups with different roles. Could choosing roles for groups be made more like choosing groups for users?

#1

Darren Oh - August 13, 2006 - 03:28

Typo: I meant, Could choosing roles for groups be made more like choosing roles for users?

#2

Darren Oh - August 13, 2006 - 04:03

I've never created a new database table before, but I think that may be required. We'll need a table of groups with associated roles, similar to the users_roles table.

#3

Darren Oh - August 13, 2006 - 15:06
Assigned to:Anonymous» Darren Oh

I'm working on this. Any guidance and suggestions would be appreciated.

#4

Darren Oh - August 18, 2006 - 16:04

Comparison of Current Version with Proposed Change

Current Version

The current version consists of two database values, a settings function, and a user promotion function.

Database

The current version of OG Promote uses two rows from the variables table:
og_promote_role stores a single role to which users can be promoted, and
og_promote_groups stores a list a groups that will promote users to that role.

Settings

The values are set in a settings page. The upper part of the page allows the administrator to choose a role from the list of roles. The lower part of the page allows the administrator to choose groups to add to that role.

User Promotion

When a user joins a group, the module checks to see if the group is found in og_promote_groups. If so, the user is promoted to the role in og_promote_roles.

Proposal

My proposal is to allow roles to be set for each group, just as they can be for users. This would make it possible to use organic groups to manage permissions for all users.

Database

A new database table would be created, name og_roles. It would contain two columns: one for group IDs and one for role IDs. There would be one group ID and one role ID per row. A first draft of the install file is attached.

Settings

Roles for each group would be set in a form, on the group edit page, similar to the form used to set roles on the user edit page. Here is the code from user.module for comparison:

  if (user_access('administer access control')) {
    $roles = user_roles(1);
    unset($roles[DRUPAL_AUTHENTICATED_RID]);
    if ($roles) {
      $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => array_keys((array)$edit['roles']), '#options' => $roles, '#description' => t('The user receives the combined permissions of the %au role, and all roles selected here.', array('%au' => theme('placeholder', t('authenticated user')))));
    }
  }

User Promotion

When a user joins a group, the module checks to see if the group is found in the og_roles table. The user is promoted to the role in each row in which the group appears.

AttachmentSize
og_promote.install 262 bytes

#5

Darren Oh - September 25, 2006 - 01:17
Version:4.7.x-1.x-dev» HEAD

#6

rubenk - September 26, 2006 - 01:08

What is the true advantage of this vs applying roles to the individual users based on which groups they join using the current OG promote? Conceptually it seems like it may be a little bit less messy but then when you view a user's profile what will it say their role is? Does it result in fewer database calls? What can it do that cannot be done now? - One thing this may solve is that with the current release, other nodetypes defined in cck that are group enabled via og do not show up in OG promote, which I am posting as a separate issue.

#7

Darren Oh - September 26, 2006 - 05:37

Ruben, your comment may be meant for another project. OG Promote doesn't have anything to do with node types. I opened this issue because I wanted to have a private administrators group that would promote users to the administrator role and a public group that would promote users to a member role. At the moment, I can't do both. OG Promote requires the site administrator to choose one role that multiple groups can promote users too.

#8

Darren Oh - September 26, 2006 - 05:40

I found issue 86013. I see what you mean about other node types. I don't think these issues would have any effect on each other.

#9

rubenk - September 27, 2006 - 20:16

I see. That does seem useful!

#10

bluecobalt - January 5, 2007 - 00:53

I need this capability for a 4.7 site, and was wondering if anyone had worked on this.

#11

mshaver - February 22, 2007 - 20:53

I was also wondering how this functionality was going? It seems a sham to have only 1 choice. I thought your proposed solution was actually how it would work out of the box.

#12

evan.leonard - April 29, 2007 - 20:20

Yes, I agree! I'm willing to help make this happen. Has anyone worked on this lately? Darren?

#13

Christefano - May 7, 2007 - 20:03

Subscribing.

#14

jonathan_hunt - June 4, 2007 - 03:31

I have modified og_promote to map a distinct role for each group. This can be configured via the settings (admin/og/og_promote). This hasn't been extensively tested yet, but seems to work for me. You might be able to use this until Darren is back on the scene (http://drupal.org/user/30772).

AttachmentSize
og_promote.module.tar_.gz 1.8 KB

#15

raintonr - June 21, 2007 - 21:51

I'm adding a 'me too please' to track this issue.

FWIW, how I envisaged this working/being configured would be a single DB table which have two columns: group name/role to promote group members to.

The admin screen would list all the roles with associated groups next to each (working on the premise you would have more groups than roles normally), but visa-versa would also be nice. Each group name would have checkbox next to it to remove it from the group it's next to.

Bottom of the list there would be a 'Add new' section with dropdown for role, with multiple select box of groups next to it. This would add new row(s) in the db table.

This may or may not be what you've done - will take a look and see!

#16

raintonr - June 21, 2007 - 23:48

Works for me. The patch from June 4 works for me. Had to comment out a couple of debug function calls, but aside from that seems fine.

Thanks :)

#17

rvk - June 23, 2007 - 22:41

I love this new functionality! I had been waiting for it for a while and unfortunately I am not a big coder. So ... I feel a bit guilty when suggesting this, but I think this module would be even more powerful if it would be possible to promote users to a certain role if they are a member of say group A AND group B.

e.g. members of group 1 (or group 2) would be promoted to role 'forum-1-user' (or 'forum-2-user'); members of group 1 AND group 'trustedusers' would be promoted to role 'forum-1-moderator'.

On the admin screen that would mean adding an AND/OR pulldown (or something more intuitive if someone can think of a more elegant solution). In the DB table you would need an extra column at the very least or perhaps it's more elegant to add an extra table?

Anyway, the added possibilities so far are very cool!
Thanks!!!
Robin

#18

Darren Oh - June 28, 2007 - 03:27
Version:HEAD» 5.x-1.0
Status:active» needs review

Here is an actual patch.

AttachmentSize
og_promote_3.patch 5.85 KB

#19

markfoodyburton - August 8, 2007 - 13:12

That patch seems to fail for me (1 out of the 6 hunks)
Which version of og_module are you working from? Seems the module code has been removed from the cvs (indeed, your patch is against the attic!!!!!)

#20

atuyo60 - January 13, 2008 - 17:03

Is this working? I was just about to ask if such a feature could be included... anyone had success with this patch and the module for Drupal 5 or is the June 4 post a better solution?

Does anyone have a modified drop-in file instead of a patch as I have problems with using patches on files... its becoming a headache for me. Thanks a lot.

This module is great but it doesn't seem like its being maintained... I have been trying to find an alternative but this was the closest I could find that met my needs (if the additional function here was included in an official release or dev).

#21

markfoodyburton - January 14, 2008 - 08:45

I'm not sure this helps, but I've just put an og_gpromote module out there. I wonder if this would work for some people.
I guess you would have a og_promote set for a small number of groups. Like an "admin" group might be promoted to an admin role just using og_promote as normal. Now, you can set up, using og_gpromote, a hierarchy of groups, which means, if somebody joins group "Joe's friends" and Joe's friends is a member group of Harry's friends and Harry's friends is a member group of admin - hey presto, it should work.

The downer is, the og_gpromote module isn't quite as good as it should be, it doesn't keep track of groups a member has specifically asked to (or not to) join, hence it takes "default" decisions.

Anyway - it MIGHT help somebody

Cheers

Mark.

#22

atuyo60 - January 14, 2008 - 14:33

mm.. I think I saw your module as well... is it able to do what you just said like anyone who joins a group gets promoted to this special role, one group one role but all are within the same content type?

I also wonder if there is a module that can create a new role for any new group created and make everyone in the group promoted to that role automatically such that organic groups can work with other modules that only use roles for access control.

#23

markfoodyburton - January 14, 2008 - 14:35

I'm not sure I fully follow your question?
I'll try and explain what it does:

On a group home page, you add a content type (which is "blessed", you have to say which type it is in the admin section of og_gpromote - and it has to be a node-reference type).

This content type "points" to a list of "sub groups" (actually it works both ways - you can point at parents too, but lets just think about one way for now)

So, now, anybody joining the sub groups that you "point" to will also join this group.
Whatever happens when you join this group, should happen. So, if you have set up a og_promote on this group, it should happen.

Not easy to explain!

Cheers

Mark.

#24

atuyo60 - January 14, 2008 - 16:30

mm.. I dun think that is what I need... all I want is to give each group a role as described in the issue here. Did you manage to get the patch or the June 4 file working?

#25

raintonr - July 1, 2009 - 08:39
Version:5.x-1.0» 6.x-1.x-dev
Assigned to:Darren Oh» Anonymous
Status:needs review» fixed

This has been incorporated into the D6 version.

#26

System Message - July 15, 2009 - 08:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.