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) »
  • Problems and a Proposal for OG Sync from CiviCRM
Pages: [1]

Author Topic: Problems and a Proposal for OG Sync from CiviCRM  (Read 4519 times)

andrewhunt

  • I post occasionally
  • **
  • Posts: 80
  • Karma: 13
    • AGH Strategies
  • CiviCRM version: all of 'em
  • CMS version: Drupal, Joomla, and WordPress
Problems and a Proposal for OG Sync from CiviCRM
June 16, 2010, 12:42:40 pm
I've found spotty documentation on this, so I wanted to do several things with this topic:
1. report what I've found through wrestling with "reverse" OG sync and see if anyone can help elaborate,
2. suggest a way to improve the situation, and
3. see if anyone would miss removing a bit of already-disabled functionality

Currently

As things stand, if the CiviCRM OG Sync module is enabled, CiviCRM groups are created when OG groups are created, and each user's associated contact is added to the corresponding CiviCRM group when he or she subscribes to a OG group.  Deletion works the same.

However, out of the box, adding a contact to a CiviCRM group that's associated with an OG group does not subscribe that user to the OG group.  Likewise, removing the contact from the CiviCRM group does not affect the user's subscription to the OG group.

The files for OG sync are in two places:
drupal root..../sites/all/civicrm/drupal/modules/civicrm_og_sync/
drupal root..../sites/all/civicrm/CRM/Bridge/OG/

CRM/Bridge/OG/Utils.php begins with declaring two constants: aclEnabled = 1 and syncFromCiviCRM = 1.  However, the function syncFromCiviCRM( )--on which all the CiviCRM-to-OG stuff is conditional--only returns true if aclEnabled = 0 and syncFromCiviCRM = 1.  There's even a comment there saying "make sure that acls are not enabled".  I'm not sure why ACLs for CiviCRM OG groups and syncing from CiviCRM should be mutually exclusive, however.

Still, setting aclEnabled = 0 subscribes and unsubscribes users from OG groups as contacts are added and removed from the corresponding CiviCRM groups.  However, there is an unintended consequence, as I'll explain.

The Problem

There is a function groupAdd() in CRM/Bridge/OG/CiviCRM.php that adds new OG groups (called by hook_civicrm_post when CiviCRM groups are created).  Now, I don't think most people would want an OG group created for each CiviCRM group, but that's beside the point.  The real problem is that it creates a node of the type "og", whether or not there is an actual node of that type.  Moreover, it somehow gets called when syncing contacts that got added to CiviCRM groups.  It searches for the node ID and overwrites the node record to have the type "og".  If your organic groups are called something different, this causes all sorts of problems.

A Suggested Solution

First, nobody will be thinking to look in CRM/Bridge/OG/Utils.php to enable or disable OG ACLs and sync from CiviCRM groups.  These ought to be variables set in the Drupal variables table, editable from an admin page.

Second, I doubt that it's preferable in (m)any cases to have OG groups automatically created from CiviCRM groups.  This is the "feature" that's causing most of the trouble, and eliminating it should make the CiviCRM-to-OG sync useful for what I feel would be most use cases.

What Do You Think?

Does this make sense?  Does anyone use the automatic OG creation from CiviCRM groups?  I don't want to urge the removal of a feature people use.  On the other hand, I'd be happy to work on a patch get this working out-of-the-box for most people.

Also, I don't know why syncing from CiviCRM and ACLs from OGs should be mutually exclusive.  If you have an idea why, please explain.
You can find me at AGH Strategies.
Need help now?  Civi911 is your go-to for CiviCRM support.

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: Problems and a Proposal for OG Sync from CiviCRM
June 16, 2010, 02:37:43 pm
Hi Andrew - we are just scoping a project that may need reverse OG synch (ie adding to a CiviCRM group adds to related OG) so your post couldn't be timelier. Have you seen this post by Matt

http://forum.civicrm.org/index.php?topic=8206.0

He has some code there for reverse synching - though it may have the same problem you cite about every civigroup creating an OG - which I agree is rarely the desired outcome.
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

andrewhunt

  • I post occasionally
  • **
  • Posts: 80
  • Karma: 13
    • AGH Strategies
  • CiviCRM version: all of 'em
  • CMS version: Drupal, Joomla, and WordPress
Re: Problems and a Proposal for OG Sync from CiviCRM
June 16, 2010, 02:44:52 pm
Hi Peter,

Great to know.  Actually, most of the code for reverse sync is already shipped; it's just prevented from running because of that weird bit at the top of CRM/Bridge/OG/Utils.php where it enables ACL for OG and disables reverse sync if ACL for OG is enabled.

Andrew
You can find me at AGH Strategies.
Need help now?  Civi911 is your go-to for CiviCRM support.

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: Problems and a Proposal for OG Sync from CiviCRM
June 16, 2010, 03:07:05 pm

here's the current behavior:

if ACL is enabled:

A user in OG 1 gets mapped to CiviGroup 1
A admin in OG 1 (admins in OG are also users) get mapped to CiviGroup 1 and CiviGroup 2 and an ACL is created which gives edit permission to contacts in Civigroup 2 on CiviGroup 1

thus one OG maps to two CiviGroup if ACL is enabled

Doing a reverse sync of this is a bit of an issue, specifically since Civi does not have an explicit Admin role and hence reverse sync is disabled if ACL is enabled.

If ACL is disabled:

Any user in OG 1 maps to CiviGroup 1

thus we can do a reverse sync

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

Andrew Perry

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 1
  • Building empowering tools that comply with rules
    • Community Builders Australia
  • CiviCRM version: 3.x, 4.x
  • CMS version: Joomla 1.0.x, 1.5.x -> Drupal 6.x, 7.x, WordPress
  • MySQL version: 5.1, 5.5, 5.6
  • PHP version: 5.2, 5.3, 5.4
Re: Problems and a Proposal for OG Sync from CiviCRM
May 12, 2011, 04:12:27 am
I'm just looking at this for Drupal 7, and was wondering about the issue raised by andrewhunt
Quote
There is a function groupAdd() in CRM/Bridge/OG/CiviCRM.php that adds new OG groups (called by hook_civicrm_post when CiviCRM groups are created).  Now, I don't think most people would want an OG group created for each CiviCRM group, but that's beside the point.  The real problem is that it creates a node of the type "og", whether or not there is an actual node of that type.  Moreover, it somehow gets called when syncing contacts that got added to CiviCRM groups.  It searches for the node ID and overwrites the node record to have the type "og".  If your organic groups are called something different, this causes all sorts of problems.

Is this [still] an issue?

We are looking to reverse sync and create OGs for existing CiviCRM groups.  Anyone have experience with this?  Do you have to create the OGs manually and if so, are there any suggestion for how to let the CiviCRM OG Sync module know which OG relates to each CiviCRM group?

Thanks for any pointers.

Andrew
Community Builders Australia Pty Ltd
www.communitybuilders.com.au

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Problems and a Proposal for OG Sync from CiviCRM
June 06, 2012, 04:01:36 pm
Just as a side note - there is a problem with ogsync in d6 - there is a patch waiting for testing on d6 & d7 here

http://issues.civicrm.org/jira/browse/CRM-10231

if anyone is playing with the code (the patch affects both CMS - but I haven't tested it as setting up the test is the slow part)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Problems and a Proposal for OG Sync from CiviCRM
June 07, 2012, 05:09:46 pm
FYI - We are trying to refactor the OG synch module for D7
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

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Re: Problems and a Proposal for OG Sync from CiviCRM
July 21, 2012, 06:02:26 am
Quote from: petednz on June 07, 2012, 05:09:46 pm
FYI - We are trying to refactor the OG synch module for D7

Pete,

Do you have any further info about what you will be doing in the refactoring? Will it include reverse sync?
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

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: Problems and a Proposal for OG Sync from CiviCRM
July 21, 2012, 02:19:11 pm
Hi Laryn - i will check with the team on Monday but from what I recall of the conversation, a couple of hours of walking through the code resulted in us basically confirming that reverse synch could work (and does) based on the existing code. But let me come back with a more technical answer.
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

asuttonsd

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.18
  • MySQL version: 5.5
  • PHP version: 5
Re: Problems and a Proposal for OG Sync from CiviCRM
February 26, 2013, 01:52:24 pm
I am curious if any progress has been made regarding the 'reverse sync' of CiviCRM Groups to OG Groups?

Thank you.

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: Problems and a Proposal for OG Sync from CiviCRM
February 26, 2013, 01:55:13 pm
i think my comment above still holds - reverse synching is already available as the code stands
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Problems and a Proposal for OG Sync from CiviCRM

This forum was archived on 2017-11-26.