CRM-10202 CiviGroup Roles Sync does not sync roles to groups

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.1.3
    • Labels:
      None

      Description

      In my testing on a Civi 4.1.2 / Drupal 7 site, CiviGroup Roles Sync fails to sync roles to groups in each of the following scenarios:

      1. Create user at /admin/people/create
      2. Add role to user at /user/N/edit
      3. Remove role from user at /user/N/edit

      I investigated and found that this was due to multiple bugs in civicrm_group_roles.module, mostly due to code having been only partially adapted for API v3 & D7 db calls & D7 forms, so left in a non-working state.

      The attached patch gets it working in the above scenarios in my testing. I took the approach of only changing what was needed to get it working; there are parts that could probably be cleaned up but I was reluctant to change without understanding the rationale for the way they were done, e.g.

      a. The test for module_exists('content_profile') in civicrm_group_roles_form_alter: I left this but added a rather speculative '|| isset( $form['account'] )' - I found that /user/N/edit (with or without a Civi profile in the edit form and without module content_profile) had form id 'user-profile-form', so I somewhat arbitrarily broadened the test to succeed for form id 'user-profile-form' provided $form['account'] is set.

      b. Could / should civicrm_group_roles_add_remove_groups use CRM_Core_BAO_UFMatch::getContactId() instead of API?

      I added an update function to change the module weight, as I found that otherwise, with the default 0 vs civicrm's 100, CRM_Core_BAO_UFMatch::getContactId() returned nothing in civicrm_group_roles_add_groups_oncreate() (called from civicrm_group_roles_user_insert() ).

        Attachments

          Activity

          [CRM-10202] CiviGroup Roles Sync does not sync roles to groups
          Donald A. Lobo added a comment -


          applied the patch. we are basically patching and distributing those modules so cant really answer your questions. maybe discuss in forums?

          Graham Mitchell added a comment -

          I'm having troubles getting this working with CiviCRM 4.1.2 and D6. Dave, any idea whether would this patch work for D6?

          Dave Jenkins added a comment -

          Hi Graham,

          Much of the patch isn't relevant to Drupal 6 - see http://forum.civicrm.org/index.php/topic,18083.msg104337.html#msg104337

          Dave J

          Mark Tompsett added a comment -

          I am using 4.2.6 with Drupal 7, so I assume this patch has been applied to that version?
          I am having trouble getting CiviGroup Roles Sync to work as expected, hence my question.

          Mark

          Dave Schafer added a comment -

          We are also seeing this same error with Drupal 7 and 4.0 and 4.2.4. The group roles sync does not work.

          We're going to compare the 4.1.3 module to the 4.2.4 to see if the original fix was somehow lost.

            People

            • Assignee:
              Donald A. Lobo
              Reporter:
              Dave Jenkins

              Dates

              • Created:
                Updated:
                Resolved: