I was having some problems getting some users who are logged in my Drupal site to gain access to G2. My G2 permissions are to only give access to "Registered Users". One specific user was put in the group "Family" which allows more capabilities. However, G2 could not be accessed at all using this account.

I checked in the database and found in G2_UserGroupMap that users were not properly being mapped to groups. With the user in the "Family" group I found that he was mapped to "Everybody" and "Family" but not "Registered Users". To see if this was the problem I manually entered a field mapping him to "Registered Users". This ended up solving the problem.

I have no idea if this issue is actually a bug or if it is just affecting my installation. Please let me know what you think may be causing this or if it is indeed a bug.

Thank you!

Comments

kiz_0987’s picture

In the UserGroupMap you should see registered users in the Everybody and Registered User groups (4 and 2 respectively). Additional groups (eg family) may also be present. This works on a number of sites that I have, but there seems to be an issue with yours. This would require some debugging (possibly of gallery_sync_groups_for_user in gallery_roles.inc).

You may also want to check the g2_ExternalIdMap to see if the authenticated role in drupal is correctly mapped to the Registered User group in Gallery2 (2 => 2 in my case).

Does this happen if you create a new user?

VENCO’s picture

I figured out a little more after creating a new account.

My site is in two languages, Dutch and English. The Dutch translation is the default for new users. After I created the new user (who I made Family role) I was still not able to access the gallery. I checked G2_UserGroupMap and found that the user did not have 2 (Registered Users) mapped. However, when I logged into the user and changed the language to English, I could get into gallery correctly. The user at this point still did not have Registered Users mapped, but it worked.

Apparently the work around for the people with Dutch language on their account, which is default, is to map Registered Users to each account manually.

VENCO’s picture

It may also be important to note that the user could not access Gallery when I (the administrator) put the language to English on that account. I had to physically log into that account to change the language there.

Thank you

VENCO’s picture

I have still not been able to resolve this problem. Any help to end this new user issue from occurring would be greatly appreciated.

pknag’s picture

I have the same problem. I had two roles defined in drupal before I embedded gallery2. The users are primarily divided between these two roles. These roles that I defined get mapped to groups with correct membership of users from drupal. But the Regsitered Users group in G2 remains empty. I think this a bug but then I have been wrong before.
Does nobody else encounter this situation?

pknag’s picture

followup to the previous post. I am using drupal 4.7.5 and 4.7.x-1.x-dev.

Is there anyone out there that has a members in the G2 'registered users' list? How can I debug this.

pknag’s picture

Tracked this issue down further. The problem is definitely with the galllery module and not with G2.

If a user has a role assigned (one defined by the drupal admin and not the default roles) then that user never gets mapped to the 'Registered Users' in G2. Remove any role for a user and save the profile and that user will be mapped to the 'Registered Users' in G2. I checked this by monitoring the mysql database of G2. I also checked this with test standalone G2 where this problem does not exist -every registered user will always get mapped to 'Registered Users'.

Now if someone can tell where to make this code change or what to look for, I may be able to do this. Otherwise help please.

profix898’s picture

Status: Active » Needs review
StatusFileSize
new4.66 KB

I played a bit with user registration and it seems that the user group mapping is initially correct, but the 'registered user' role is removed immediatly with the (next) call to gallery_sync_groups_for_user(). The attached patch seems to solve this issue for me (and performs a little cleanup of the variables).

profix898’s picture

StatusFileSize
new6.26 KB

... and here a patch for Drupal 4.7 ...

pknag’s picture

Thanks for that patch. It works except when a role for a user is removed and the new profile is submitted it does not remove the user from the corresponding group in G2. Submitting the profile again removes the user from the group in G2. Adding a role to a user in drupal takes immediate effect and the user is added to the group in G2 in one 'Submit'.

profix898’s picture

StatusFileSize
new5.63 KB

Oh yes, but thats not my fault ;) Didnt work before the patch either. But its quite easy to fix that as well. New patch attached. D5 patch will follow if this one is working correctly.

pknag’s picture

Just awesome. Works like a charm. Now I can play with the permissions in G2.

kiz_0987’s picture

profix898 - presumably you added the isset in $user->roles = isset($edit['roles']) ? $edit['roles'] : $user->roles; for E_ALL compliance. There are other places in the code where isset is not used -- is it worth changes these now as well?

profix898’s picture

The isset change is not for E_ALL compliance. It is needed for the code to work. If you have $user->roles = ($edit['roles']) ? $edit['roles'] : $user->roles; the variable $user->roles will be set to $user->roles unless you have a non-empty $edit['roles'] array. But this wrong. When $edit['roles'] is empty it only means that the user has unchecked all roles in the user profile and we want to remove the roles from G2 as well. This isset line is needed to fix what pknag reported in #10.

jgarabot’s picture

How do I set that patch, in what file? I do not have a lot of technical skills. need a little more s plaining.

profix898’s picture

Status: Needs review » Fixed

Committed to Drupal-5 and Drupal-4-7 branches.

Anonymous’s picture

Status: Fixed » Closed (fixed)