3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2018
33 class CRM_Bridge_OG_Utils
{
34 const aclEnabled
= 1, syncFromCiviCRM
= 1;
39 public static function aclEnabled() {
40 return self
::aclEnabled
;
44 * Switch to stop synchronization from CiviCRM.
45 * This was always false before, and is always true
46 * now. Most likely, this needs to be a setting.
48 public static function syncFromCiviCRM() {
49 // make sure that acls are not enabled
50 //RMT -- the following makes no f**king sense...
51 //return ! self::aclEnabled & self::syncFromCiviCRM;
60 public static function ogSyncName($ogID) {
61 return "OG Sync Group :{$ogID}:";
69 public static function ogSyncACLName($ogID) {
70 return "OG Sync Group ACL :{$ogID}:";
77 * @return int|null|string
80 public static function ogID($groupID, $abort = TRUE) {
81 $source = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Group',
86 if (strpos($source, 'OG Sync Group') !== FALSE) {
87 preg_match('/:(\d+):$/', $source, $matches);
88 if (is_numeric($matches[1])) {
93 CRM_Core_Error
::fatal();
104 public static function contactID($ufID) {
105 $contactID = CRM_Core_BAO_UFMatch
::getContactId($ufID);
109 // else synchronize contact for this user
111 $account = user_load($ufID);
113 CRM_Core_BAO_UFMatch
::synchronizeUFMatch($account, $ufID, $account->mail
, 'Drupal');
114 $contactID = CRM_Core_BAO_UFMatch
::getContactId($ufID);
116 CRM_Core_Error
::fatal();
126 * @return null|string
129 public static function groupID($source, $title = NULL, $abort = FALSE) {
134 $params = array(1 => array($source, 'String'));
137 $query .= " OR title = %2";
138 $params[2] = array($title, 'String');
141 $groupID = CRM_Core_DAO
::singleValueQuery($query, $params);
145 CRM_Core_Error
::fatal();