3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Bridge_OG_Utils
{
18 const aclEnabled
= 1, syncFromCiviCRM
= 1;
23 public static function aclEnabled() {
24 return self
::aclEnabled
;
28 * Switch to stop synchronization from CiviCRM.
29 * This was always false before, and is always true
30 * now. Most likely, this needs to be a setting.
32 public static function syncFromCiviCRM() {
33 // make sure that acls are not enabled
34 //RMT -- the following makes no f**king sense...
35 //return ! self::aclEnabled & self::syncFromCiviCRM;
44 public static function ogSyncName($ogID) {
45 return "OG Sync Group :{$ogID}:";
53 public static function ogSyncACLName($ogID) {
54 return "OG Sync Group ACL :{$ogID}:";
61 * @return int|null|string
64 public static function ogID($groupID, $abort = TRUE) {
65 $source = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group',
70 if (strpos($source, 'OG Sync Group') !== FALSE) {
71 preg_match('/:(\d+):$/', $source, $matches);
72 if (is_numeric($matches[1])) {
77 CRM_Core_Error
::fatal();
88 public static function contactID($ufID) {
89 $contactID = CRM_Core_BAO_UFMatch
::getContactId($ufID);
93 // else synchronize contact for this user
95 $account = user_load($ufID);
97 CRM_Core_BAO_UFMatch
::synchronizeUFMatch($account, $ufID, $account->mail
, 'Drupal');
98 $contactID = CRM_Core_BAO_UFMatch
::getContactId($ufID);
100 CRM_Core_Error
::fatal();
110 * @return null|string
113 public static function groupID($source, $title = NULL, $abort = FALSE) {
118 $params = [1 => [$source, 'String']];
121 $query .= " OR title = %2";
122 $params[2] = [$title, 'String'];
125 $groupID = CRM_Core_DAO
::singleValueQuery($query, $params);
129 CRM_Core_Error
::fatal();