Hi everybody,

I'd need OGUR Filters and Fields available in Views filters and fields: is it possible?

I noticed that someone has already done something similar for 6.x-1.x-dev (see http://drupal.org/node/406762#comment-1404274 ): this can be useful?

Specifically I need this feature to retrieve all users with a specific OGUR role (ATTENTION: not core roles, but OGUR roles that are different) starting from a content node ID belonging to a group.

Thank you very much!

MXT
(sorry for my bad english)

Comments

sun’s picture

Title: Views OGUR filters and fields needed » Views integration
henrijs.seso’s picture

a must feature. for sites that use their own user lists made in views and build group nodes with panels.

views integration will allow better/custom ui, f. ex. for groups with 1000 members needs some filter, no problem to add that with views

users needs to know who is who in group, so label by users name in list is important.

jbizzay’s picture

I too need this, is there any work on this? i can contribute

jbizzay’s picture

For filtering by user roles in specific groups, we will need views integration. I've built this out in a custom module and it is working well. Sometimes I just speak too soon when I think something is working.

Basically what i need is to show a view for a user that has every group node that they are a specific role in. I've built a views filter for this. Can provide a patch if needed. There might be other use cases that are useful as well, though.

mxt’s picture

Basically what i need is to show a view for a user that has every group node that they are a specific role in. I've built a views filter for this. Can provide a patch if needed. There might be other use cases that are useful as well, though.

If I have correctly understood your need, I think the solution is using "Views's Access Restriction by role" feature, but unfortunately this doesn't work with OGUR due to this bug: http://drupal.org/node/737292

Can you helping in this?

Thank you!

henrijs.seso’s picture

needed

- Views's Access Restriction by role
- Role name fields and promote/demote buttons in Fields
- Sorting by role in Sort criteria
- Role filters for showing only administrators of current group or all groups where user is administrator
- help me out here with this list...

j.helmer’s picture

For view's access restriction by role, I point you to my recently posted comment in a different issue: http://drupal.org/node/737292#comment-3284452

dejan.maric.max’s picture

StatusFileSize
new2.11 KB

Hi guys,

I've wrote a og_user_roles_views module that integrates og user roles into views.

It doesn't cover the `view's access restriction by role` that j.helmer elaborated in his post.

It Exposes OG user role as:
- Field
- Filter
- Sort

(to see it action view has to be a `user` type)

dejan.maric.max’s picture

StatusFileSize
new3.44 KB

Update I've integrated the j.helmer access plugin into module so no need for patching the OGUR module

and it has all the features in one module

sun’s picture

Status: Active » Needs work

Thanks for working on this, destination_node! However, we don't need another/new module, we need a patch for this module. :)

dejan.maric.max’s picture

OK,

but it is not uncommon that views integration is a separate module, but it's your call,

Also I want to point out that I also resolved a `allow default role to be different by content type` http://drupal.org/node/837866
so maybe can you look at the code and make a patch (If you think that new approach is OK, for sure).

apdp300’s picture

Thanks, destination_node I tried this module - it works great - I can make a view of og members giving their og roles on og home page. But I also want to make a view of the og group and roles each user has on each user's own page. Is there a way I can do this? Thanks.

mxt’s picture

I've tried the module in #9 but "views access restrictions by OGUR roles" doesn't work for me.

I'm using views views-6.x-2.11: I have to use views 3 instead? Let me know please.

Thank you!

MXT

henrijs.seso’s picture

deleted comment, wrong issue

henrijs.seso’s picture

deleted comment, wrong issue

henrijs.seso’s picture

StatusFileSize
new2.03 KB
new2.09 KB
new10.82 KB

deleted comment, wrong issue

Do not test these files, there is a bug. I opened a new issue #915920: ctools integration and will post updated files there, they will eventually be for ctools integration. I am still very much interested in this issue thou :)

carma -3 for messing up issue queue. my bad.

henrijs.seso’s picture

@destination_node

i found no bugs after all in your code, it was some other problem :) It works good, but am I missing something? If I add exposed filter it will provide all roles as an option. Many use cases have multiple group types and multiple role sets per group. But view is usually placed in one particular group page, so role list in filter should be limited to group roles.

Relationships support would be great so that one could choose a group node from which roles could be loaded. Do you have any plans for this or should I investigate?

dejan.maric.max’s picture

Hi, sorry for the response time, holiday and stuff, anyway no I'm not planing any new features for this and after all this is not a proper module (not registered) and was just `patch like` module while maintainer is one that should decide what will be with this code.

Regarding filters current implementation uses `views_handler_filter_user_roles` which is the default one for roles, you need to write OGUR specific one.

You should try to write that on your own, writing views extension is fun (it's quite different form any other drupal stuff).

gmclelland’s picture

subscribing

sanktity’s picture

Category: feature » bug

Sorry for the post, I figured it out.

mtndan’s picture

Thanks destination_node!

Is there a way to utilize this filter on views of node type rather than user views?

I'm trying to get a list of groups where the currently logged in user has the og role of "content manager".

Thanks

xqbzzr’s picture

subscribe
Views integration is a must

jzornig’s picture

I tried the module from #9 and get the following error when i try to add a field to my view that is the users og roles.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 110, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ' at line 1 query: SELECT u.uid, u.rid, r.name FROM role r INNER JOIN og_users_roles u ON u.rid = r.rid WHERE u.uid IN (2643, 2650, 3618, 3660, 3178, 3560, 3687, 3428, 3009, 2850, 3147, 2980, 3570, 3169, 3503, 2974, 3083, 3674, 2955, 3164, 3383, 3438, 2695, 3192, 3340, 3389, 3099, 3353, 2786, 2788, 3187, 3226, 3344, 3437, 3634, 3755, 3434, 3046, 3333, 3261, 3463, 3418, 3158, 3194, 2699, 3596, 2843, 2804, 3186, 2957, 3123, 3700, 3135, 3115, 3026, 3188, 2748, 2970, 3655, 3132, 3652, 3030, 3160, 3552, 3191, 2740, 3339, 2899, 3590, 2972, 3366, 2831, 2914, 2839, 3506, 3162, 2868, 2994, 3315, 2958, 3086, 3150, 3707, 2998, 3189, 3148, 2772, 3024, 3543, 3477) AND u.gid IN (, 110, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ) ORDER BY r.name in /var/www/teamwork/sites/all/modules/og_user_roles_views/views_handler_field_og_user_roles.inc on line 28.
jzornig’s picture

I made the following change to the code from #9 to fix the issue #23.


--- views_handler_field_og_user_roles.inc-orig	2011-03-25 16:00:27.000000000 +1000
+++ views_handler_field_og_user_roles.inc	2011-03-25 15:52:28.000000000 +1000
@@ -25,7 +25,7 @@
     }
 
     if ($uids) {
-      $result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {og_users_roles} u ON u.rid = r.rid WHERE u.uid IN (" . implode(', ', $uids) . ") AND u.gid IN (" . implode(', ', $gids) . ") ORDER BY r.name");
+      $result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {og_users_roles} u ON u.rid = r.rid WHERE u.uid IN (" . implode(', ', $uids) . ") AND u.gid IN (" . implode(', ', array_filter($gids)) . ") ORDER BY r.name");
       while ($role = db_fetch_object($result)) {
         $this->items[$role->uid][$role->rid]['role'] = check_plain($role->name);
         $this->items[$role->uid][$role->rid]['rid'] = $role->rid;

yrocq’s picture

I took the code from the previous comments, fixed a duplicate problem and made a patch for OGUR. It doesn't include the access plugin, however.

yrocq’s picture

StatusFileSize
new3.7 KB
yrocq’s picture

Status: Needs work » Needs review

Sorry for multiple comments.

hefox’s picture

Category: bug » feature

Hm, how is views intergration a bug? Going to be looking into this so sub

hefox’s picture

Status: Needs review » Needs work

INNER JOIN og_users_roles users_comments__og_users_roles ON users_comments__og_uid.uid = users_comments__og_users_roles.uid AND ( og_uid.nid = og_users_roles.gid )

Extra like that won't work and respect relationships, going to see what does.

hefox’s picture

Status: Needs work » Needs review
StatusFileSize
new4.5 KB

Adding a custom join handler seems to work

hefox’s picture

StatusFileSize
new4.53 KB

views_join_complex example is outdated, copied construct from it :(!

hefox’s picture

StatusFileSize
new4.75 KB

Argument handler for rid

sun’s picture

This looks very appealing already, and I'd be tempted to commit; only the coding style and comments could use some love here and there.

timefor’s picture

Applied, but I'm not seeing this work at all. Can you explain what I should see? Using Views 3 btw.

jvieille’s picture

patch #32 works great!
+1 for committing this

btopro’s picture

@TimeFor you need to reload the module and it shows up.

+1 for committing #32 nice patch!

jzornig’s picture

+1 for commiting

j.helmer’s picture

Hey guys I'm the one who originally wrote the views plugin way back, the one MXT references in the description of this ticket.

I'm currently using it on multiple production sites and it works great.

Was wondering if anyone has enhanced it so that providing the og context argument is not necessary in views?

It would be nice if this plugin could be used on other pages that don't have a group id argument, but just grab the group id from the context of the page.

bsandor’s picture

Hi Guys,

Is there anyone here who is happy to summarise the results here please?

I am completly lost.

Is #8 working fine?
Which is the best version of patches that is doing exactly what?

Thanks folks.

jvieille’s picture

Status: Needs review » Needs work

#32 does not seem to work anymore (from OG update?)
Shows in field Groups
Array
Organic groups Roles
Organic groups Roles
and nothing when selected

j.helmer’s picture

@bsandor -

Talk to the maintainer of og_user_roles.

I believe he phased in a version of my views plugin into the dev branch, but I can't be sure.

I can try to provide help, but don't have the resources to fix any issues with newer versions of OGUR.

jvieille’s picture

Status: Needs work » Reviewed & tested by the community

Actually, this patch works fine.
My issue #40 was my fault : I had activated the module version #8 at the same time,, hence the conflict.

By the way, this module does not appear to be maintained anymore

jlbellido’s picture

#32 works for me like a charm! Thanks a lot!