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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • OG sync module deletes all ACLs when you delete one Organic Group
Pages: [1]

Author Topic: OG sync module deletes all ACLs when you delete one Organic Group  (Read 690 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
OG sync module deletes all ACLs when you delete one Organic Group
August 08, 2011, 08:58:49 am
I have been troubled by strange behaviour in OG_sync for a while & just got nearly to the bottom of some wierd behaviour I have been seeing.

There is code in class CRM_Bridge_OG_Drupal that should delete the relevant value in the option group table but it seems that the DAO->delete method is not working as the coder (and I) expected.

The key piece of code is
Code: [Select]
        $dao = new CRM_Core_DAO_OptionValue( );
        $dao->option_group_id = $optionGroupID;
        $dao->description     = $params['source'];
        $dao->delete( );

The effect of this is to delete all option values where option_group_id = $optionGroupID AND description IS NOT NULL.

I tested the snippet below directly in the devel module execute PHP box & could see this is what is happening.

First some SQL to add test values
Code: [Select]
INSERT INTO `civicrm_option_value` ( `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `domain_id`, `visibility_id`) VALUES
( 8, '916 - Palo Alto GMF, June 7-July 12, Tues 7 pm: Administrator', '5', NULL, NULL, NULL, 0, 6, NULL, 0, 0, 1, NULL, NULL, NULL),
( 8, '915 - Palo Alto GMF, May 10 - June 14, Tues 9 am: Administrator', '4', NULL, NULL, NULL, 0, 5, 'OG Sync Group ACL :1967:', 0, 0, 1, NULL, NULL, NULL);
SELECT * from civicrm_option_value WHERE option_group_id = 8;

Code: [Select]
civicrm_initialize( ) ;     
print_r(civicrm_api('OptionValue', 'Get', array('version' => 3,'option_group_id' => 8)));
 require_once 'CRM/Core/DAO/OptionValue.php';

        $optionGroupID = 8;
    $params['source'] = 'OG Sync Group ACL';

        $dao = new CRM_Core_DAO_OptionValue( );
        $dao->option_group_id = $optionGroupID;
        $dao->description     = $params['source'];

            $dao->delete( );
print_r(civicrm_api('OptionValue', 'Get', array('version' => 3,'option_group_id' => 8)));


And the code in the Civi Module

 CRM_Bridge_OG_Drupal code
Code: [Select]
    static function updateCiviACLRole( &$params, $op ) {
        require_once 'CRM/Core/DAO/OptionValue.php';

        $optionGroupID = CRM_Core_DAO::getFieldValue( 'CRM_Core_DAO_OptionGroup',
                                                      'acl_role',
                                                      'id',
                                                      'name' );
   
        $dao = new CRM_Core_DAO_OptionValue( );
        $dao->option_group_id = $optionGroupID;
        $dao->description     = $params['source'];
       
        if ( $op == 'delete' ) {
            $dao->delete( );
            return;
        }
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

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: OG sync module deletes all ACLs when you delete one Organic Group
August 08, 2011, 10:56:46 am

can u enable the mysql query log and see the delete query being generated?

seems wierd that its not deleting all option values that match the group_id AND description

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: OG sync module deletes all ACLs when you delete one Organic Group
August 08, 2011, 11:03:43 am
DELETE FROM civicrm_option_value  WHERE (  civicrm_option_value.option_group_id = 8 )  AND (  civicrm_option_value.description = 0 );
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: OG sync module deletes all ACLs when you delete one Organic Group
August 08, 2011, 12:13:08 pm
http://issues.civicrm.org/jira/browse/CRM-8622
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • OG sync module deletes all ACLs when you delete one Organic Group

This forum was archived on 2017-11-26.