static function og(&$params, $op)
 {
     $contactID = CRM_Bridge_OG_Utils::contactID($params['uf_id']);
     if (!$contactID) {
         CRM_Core_Error::fatal();
     }
     // get the group id of this OG
     $groupID = CRM_Bridge_OG_Utils::groupID(CRM_Bridge_OG_Utils::ogSyncName($params['og_id']), NULL, TRUE);
     $groupParams = array('contact_id' => $contactID, 'group_id' => $groupID, 'version' => 3);
     if ($op == 'add') {
         $groupParams['status'] = $params['is_active'] ? 'Added' : 'Pending';
         civicrm_api('GroupContact', 'Create', $groupParams);
     } else {
         $groupParams['status'] = 'Removed';
         civicrm_api('GroupContact', 'Delete', $groupParams);
     }
     if (CRM_Bridge_OG_Utils::aclEnabled() && $params['is_admin'] !== NULL) {
         // get the group ID of the acl group
         $groupID = CRM_Bridge_OG_Utils::groupID(CRM_Bridge_OG_Utils::ogSyncACLName($params['og_id']), NULL, TRUE);
         $groupParams = array('contact_id' => $contactID, 'group_id' => $groupID, 'status' => $params['is_admin'] ? 'Added' : 'Removed', 'version' => 3);
         if ($params['is_admin']) {
             civicrm_api('GroupContact', 'Create', $groupParams);
         } else {
             civicrm_api('GroupContact', 'Delete', $groupParams);
         }
     }
 }
示例#2
0
文件: Drupal.php 项目: ksecor/civicrm
 static function og(&$params, $op)
 {
     require_once 'CRM/Bridge/OG/Utils.php';
     $contactID = CRM_Bridge_OG_Utils::contactID($params['uf_id']);
     if (!$contactID) {
         CRM_Core_Error::fatal();
     }
     // get the group id of this OG
     $groupID = CRM_Bridge_OG_Utils::groupID(CRM_Bridge_OG_Utils::ogSyncName($params['og_id']), null, true);
     $groupParams = array('contact_id' => $contactID, 'group_id' => $groupID);
     require_once 'api/v2/GroupContact.php';
     if ($op == 'add') {
         $groupParams['status'] = $params['is_active'] ? 'Added' : 'Pending';
         civicrm_group_contact_add($groupParams);
     } else {
         $groupParams['status'] = 'Removed';
         civicrm_group_contact_remove($groupParams);
     }
     if (CRM_Bridge_OG_Utils::aclEnabled() && $params['is_admin'] !== null) {
         // get the group ID of the acl group
         $groupID = CRM_Bridge_OG_Utils::groupID(CRM_Bridge_OG_Utils::ogSyncACLName($params['og_id']), null, true);
         $groupParams = array('contact_id' => $contactID, 'group_id' => $groupID, 'status' => $params['is_admin'] ? 'Added' : 'Removed');
         if ($params['is_admin']) {
             civicrm_group_contact_add($groupParams);
         } else {
             civicrm_group_contact_remove($groupParams);
         }
     }
 }