Download & Extend

roles lost after hook_menu (flag module, maybe Voting API and others)

Project:OG User Roles
Version:6.x-4.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:Unassigned
Status:needs work

Issue Summary

I opened issue with Flag module #951944: check roles before rendering flag link. Maybe somebody could join discussion there to find solution to problem?

I saw closed issue here for 1.x, but I agree, it's not a problem of OG User Roles.

Comments

#1

Title:roles lost after hook_menu (flags won't work, maybe others)» roles lost after hook_menu (flag module, maybe Voting API and others)
Priority:normal» minor

I was trying to create feature where group administrators could flag group post as 'featured' and it would display in group page in special block from View.

Workaround for that would be to allow flagging as 'featured' for any authenticated user, dislpay link only for administrators and in view set arguments so that group post is in 'featured' block only if user flagging group post is administrator for particular group.

#2

subscribing.

#3

Category:support request» bug report
Priority:minor» major
Status:active» needs review

Maybe same problem. I found og_user_roles was simply blowing away a user's roles. This patch fixes the case I had trouble with.

AttachmentSize
og_user_roles_fix.diff 742 bytes

#4

I applied the patch in #3 and it didn't solve my problem of not being able to remove a flag that was removable by a role that UG User Roles is allocating. I added the following line just after the 'if' block where you recommended the change:

<?php
watchdog
('debug', print_r($account->roles, true));
?>

The result was:

Array ( [2] => authenticated user [4] => Member(18+) [19] => Community Administrator )

I then reverted the code to be what it was before the patch and added the watchdog code again and got exactly the same output -- "community administrator" -- the OGUR role that was allocated is there.

By reading the code, I can only presume that your $roles var *was* set and yes, I see how it would be blowing the roles away.

#5

Status:needs review» needs work

#4 sounds like #3 doesn't fix this issue, so needs work.

#6

Hello everyone!

I am also having a problem where I am using both the Flag module and the OG User Roles module.

I am trying to allow a user to flag content only if he or she has a particular role, and that role is only given by the owner of an OG group, who assigns the role using the OG User Roles tab for that particular group.
Obviously the flag I am discussing is configured to be allowed to be activated by users with the specified role.
What is interesting is that a user with the role is able to see the flag option on group content, but when he or she attempts to mark the content as flagged, they get the message "You are not allowed to flag, or unflag, this content." displayed at the top of the page.

I have been searching posts on d.o but have been unable to get to the root of this issue.
I solved the issue for me by modifying function flag in flag.module, replacing the line

<?php
return $flag->flag($action, $content_id, $account);
?>

with
<?php
return $flag->flag($action, $content_id, $account, TRUE);
?>

According to the definition of flag in flag.inc, this changes the call to flag so that the skip_permission_check flag is set to true, which will "Flag the item even if the account user don't have permission to do so."

I am certainly unhappy with this resolution, I don't wish to hack other modules, and I don't know what repercussions this change entails, but all I know is that now the functionality works as I desire: only users with the specified role can now see and click my flag on content.

Does anyone have any thoughts on what the problem is here? Looking at the code and having done some debugging, my initial thought is that I have permissions to view the flag option on group content, as it is in the context of the group, but I don't have that group context on the page triggered by the clicked flag link. If this is indeed the case, I am not sure which module, Flag or OG user roles, would need to change in order to resolve the problem.

Dave Cohen's fix did not resolve my issue.

I would be willing to add debug statements and return results to others if it would help resolve this issue.
Thanks!

nobody click here