Exemplo n.º 1
0
 static function groupContact($groupID, $contactIDs, $op)
 {
     $config = CRM_Core_Config::singleton();
     $ogID = CRM_Bridge_OG_Utils::ogID($groupID, FALSE);
     if (!$ogID) {
         return;
     }
     foreach ($contactIDs as $contactID) {
         $drupalID = CRM_Core_BAO_UFMatch::getUFId($contactID);
         if ($drupalID) {
             if ($op == 'add') {
                 $group_membership = $config->userSystem->og_membership_create($ogID, $drupalID);
             } else {
                 $group_membership = $config->userSystem->og_membership_delete($ogID, $drupalID);
             }
         }
     }
 }
Exemplo n.º 2
0
 static function groupContact($groupID, $contactIDs, $op)
 {
     require_once 'CRM/Bridge/OG/Utils.php';
     $ogID = CRM_Bridge_OG_Utils::ogID($groupID, false);
     if (!$ogID) {
         return;
     }
     require_once 'api/v2/UFGroup.php';
     foreach ($contactIDs as $contactID) {
         $drupalID = civicrm_uf_id_get($contactID);
         if ($drupalID) {
             if ($op == 'add') {
                 og_save_subscription($ogID, $drupalID, array('is_active' => 1));
             } else {
                 og_delete_subscription($ogID, $drupalID);
             }
         }
     }
 }
 static function groupContact($groupID, $contactIDs, $op)
 {
     $ogID = CRM_Bridge_OG_Utils::ogID($groupID, FALSE);
     if (!$ogID) {
         return;
     }
     foreach ($contactIDs as $contactID) {
         $drupalID = CRM_Core_BAO_UFMatch::getUFId($contactID);
         if ($drupalID) {
             if ($op == 'add') {
                 $group_membership = og_membership_create($ogID, 'user', $drupalID, array('is_active' => 1));
                 $group_membership->save();
             } else {
                 $membership = og_get_group_membership($ogID, 'user', $drupalID);
                 if ($membership) {
                     og_membership_delete($membership->id);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 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);
         }
     }
 }
Exemplo n.º 5
0
 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);
         }
     }
 }