CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • CiviMember Role Sync lets you choose smart group, but does't work w smart groups
Pages: [1]

Author Topic: CiviMember Role Sync lets you choose smart group, but does't work w smart groups  (Read 2632 times)

GregoryHeller

  • I post occasionally
  • **
  • Posts: 73
  • Karma: 3
CiviMember Role Sync lets you choose smart group, but does't work w smart groups
April 04, 2011, 06:05:37 pm
Use Case: Assign drupal role based on civicrm relationship record.

Method Attempted:
  • Create a Smart group based on the relationship (in this case, an active employment relationship with a particular organization)
  • Create a staff role in drupal
  • Enable CiviMember Role Sync
  • Create a sync rule for the smart group and the drupal role

Tested by adding the relationship to a contact. Checked to ensure that contact appeared in the smart group. Logged in as the user for that contact. Checked as the admin to see if that user had the staff role in drupal.  The user did not have the staff role.  Logged the test user in and out a few times. No change.

Changed the rule to work with a static group.  add the contact to a static group.  logged in as the user. checked as admin to see that the user WAS INDEED granted the staff role.

If the intention is that CiviMember CiviGroup Role Sync should work with smart groups, then there is a problem. If the module is not intended to work with smart groups then there should be a notice about that, AND smart groups should not appear in the module's drop down list of groups.

Does anyone know what the intended behavior is?
« Last Edit: April 05, 2011, 10:19:12 am by GregoryHeller »

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
April 04, 2011, 06:24:07 pm
Hi Greg - yeah we just hit this recently too. And to add a further bit that confused our testing for a while - if you manually add a person to a Smart Group then they do seem to be picking up the Role via the synch - so it may not be the 'smart group' per se - but whether contacts are in it due to the 'saved search' (which is obviously how the majority will be in there) or added directly.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
April 04, 2011, 07:43:55 pm

took a quick look at the code and the sync does not deal with smart groups. I assume u mean civicrm_group_roles rather than member_roles

This is pretty closely related to the MIH "Smart Groups in Contact Tabs" (http://civicrm.org/mih34) which did not get funded

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

GregoryHeller

  • I post occasionally
  • **
  • Posts: 73
  • Karma: 3
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
April 05, 2011, 10:20:05 am
Yes, i meant CiviGroup Roles in that last sentence.

So Lobo, you are saying that if smart groups showed up in a tab, then Group Roles Sync would work?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
April 05, 2011, 10:23:25 am

kinda yes.

Since the fix would be to make contacts aware of being part of a "smart group" (and use the smart group cache), which in turn would allow the api to retrieve both normal groups and smart groups

the big issue in there is how/where/when does this impact performance for large numbers of smart groups

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jtbayly

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 0
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
May 16, 2011, 03:05:17 pm
based on the conversation here and in this thread: http://forum.civicrm.org/index.php?action=post;topic=18657.0 and the documentation of the civigroup role sync module here: http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviGroup+Roles+Sync I don't have a clue what to believe.

I've even done my own testing, and I'm *still* not sure what to believe. Infuriatingly, the CiviGroup Roles Sync module doesn't work *at all* in the 3.4.1 (and presumably 4.0.1). You can find a patch to fix it here: http://issues.civicrm.org/jira/browse/CRM-8058 (Sidenote, does CiviCRM not have automated regression testing before stable releases go out?)

After applying that patch, I'm pretty sure that syncing with smart groups *did* work for me. But can anybody confirm this? I see no evidence that the MIH mentioned above ever made it into this version, nor that the module was updated to take advantage of that change. So I'm wondering if maybe it just works *sometimes*, or maybe just after you manually view the contacts in a smartgroup.

Can anybody tell me definitively whether this works? Much obliged if you can.

Thanks,
-Joseph

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
May 16, 2011, 04:29:42 pm

I'm pretty sure (and i did a quick code walk thru) that smart groups are not considered in the role sync.

Note that smart groups also have a static part (i.e. a  few contacts could be "manually" added to the smart group. If so, then those contacts will be part of the "role sync", since they are always part of the group and present in the table civicrm_group_contact

with regard to your sidenote: civicrm does have a test suite, results are here:

http://tests.dev.civicrm.org/

Two areas that are currently lacking any tests are:

a. Drupal module integration
b. Hooks testing

Would be great if you can help start building test suites for either or both of the above areas. That would be great and help ensure even more stability in future releases. Ping us on IRC if interested

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jtbayly

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 0
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
May 17, 2011, 06:52:23 am
Thanks, Lobo.

I have no idea how I got that test user to have the test role, but I did... And I never added the user to the group manually. I even double checked the membership status of the user, and it said "smart". But I guess we'll have to chalk it up to user error, because I cannot reproduce it now. I've just spent an hour trying to eliminate every conceivable variable, and user error is the only variable left. :)

As for testing, I was pretty sure CiviCRM had it, but now I understand what's going on. If I had any ability to write tests, I'd be more than happy to contribute a few, but unfortunately, my ability to code is essentially non-existant at this point.

If I could code, I'd also try to work on solving this problem. I guess I'll just add a feature request. :(

By the way, the naming (and description) of the MIH initiatives is *very* important for whether they get funded. I think that another MIH should be created, that makes prominent this feature being a result. The last one was too difficult for people to understand what the real-world benefits would be. My guess is that it would be more successful. Just my 2 cents though.

-Joseph

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
May 17, 2011, 10:04:35 am
Quote from: jtbayly on May 17, 2011, 06:52:23 am
By the way, the naming (and description) of the MIH initiatives is *very* important for whether they get funded. I think that another MIH should be created, that makes prominent this feature being a result. The last one was too difficult for people to understand what the real-world benefits would be. My guess is that it would be more successful. Just my 2 cents though.

Can you rename and write a better description for it that makes sense and would attract more funding. If we find a seed sponsor or two for that MIH, we'd be happy to resurrect it

You can contribute in lots of ways, even if you dont write code, check

http://en.flossmanuals.net/civicrm/ch071_civicommunity/

lobo

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
CiviGroup Role Sync lets you choose smart group but does't work w smart groups
September 11, 2014, 09:46:44 am
Old issue, but maybe better to reply here so that people finding this issue, or subscribed to it, see the latest developments.

CiviGroup Roles Sync now supports smart groups, but only in the Drupal 7 version - see CRM-11161 and CRM-13569.

I've tested in 4.4.6 / Drupal 7 and found that if I set up a sync rule for a smart group, the role is correctly added on login for a contact who fits the criteria of the smart group.

However I found that when the contact ceased to fit the smart group criteria, logging out & in again did not remove the role. It seems what happens is that when civicrm_group_roles_user_login adds the role, this fires civicrm_group_roles_user_update, which calls civicrm_group_roles_add_remove_groups($roles, $account, 'add') . The latter finds that the user has a role for which there's a sync rule, so does a civicrm_api('GroupContact', 'create') call to add them to the group if they're not already in it.

The result is that the contact becomes a static member of the smart group, so even if they cease to fit the smart group criteria, they are still in the group so they keep the role.

I think the fix would be to check in civicrm_group_roles_add_remove_groups() whether the group it's about to sync to is a smart group and if so, skip it.

If that diagnosis seems right, I'll create an issue.

Cheers,

Dave
« Last Edit: September 16, 2014, 10:57:57 am by davej »

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: CiviMember Role Sync lets you choose smart group, but does't work w smart groups
October 13, 2014, 08:09:14 am
I reopened CRM-11161 and fixed the issue mentioned above plus another issue that prevented roles from being removed. Details at https://issues.civicrm.org/jira/browse/CRM-11161?focusedCommentId=66049&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-66049

Dave

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • CiviMember Role Sync lets you choose smart group, but does't work w smart groups

This forum was archived on 2017-11-26.