3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * Drupal specific stuff goes here
39 class CRM_Utils_System_Drupal
extends CRM_Utils_System_Base
{
40 function __construct() {
41 $this->is_drupal
= TRUE;
42 $this->supports_form_extensions
= TRUE;
46 * Function to create a user in Drupal.
48 * @param array $params associated array
49 * @param string $mail email id for cms user
51 * @return uid if user exists, false otherwise
56 function createUser(&$params, $mail) {
57 $form_state = array();
58 $form_state['input'] = array(
59 'name' => $params['cms_name'],
60 'mail' => $params[$mail],
61 'op' => 'Create new account',
64 $admin = user_access('administer users');
65 if (!variable_get('user_email_verification', TRUE) ||
$admin) {
66 $form_state['input']['pass'] = array('pass1'=>$params['cms_pass'],'pass2'=>$params['cms_pass']);
69 if(!empty($params['notify'])){
70 $form_state['input']['notify'] = $params['notify'];
73 $form_state['rebuild'] = FALSE;
74 $form_state['programmed'] = TRUE;
75 $form_state['complete form'] = FALSE;
76 $form_state['method'] = 'post';
77 $form_state['build_info']['args'] = array();
79 * if we want to submit this form more than once in a process (e.g. create more than one user)
80 * we must force it to validate each time for this form. Otherwise it will not validate
81 * subsequent submissions and the manner in which the password is passed in will be invalid
83 $form_state['must_validate'] = TRUE;
84 $config = CRM_Core_Config
::singleton();
86 // we also need to redirect b
87 $config->inCiviCRM
= TRUE;
89 $form = drupal_retrieve_form('user_register_form', $form_state);
90 $form_state['process_input'] = 1;
91 $form_state['submitted'] = 1;
92 $form['#array_parents'] = array();
93 $form['#tree'] = FALSE;
94 drupal_process_form('user_register_form', $form, $form_state);
96 $config->inCiviCRM
= FALSE;
98 if (form_get_errors()) {
102 return $form_state['user']->uid
;
107 * Change user name in host CMS
109 * @param integer $ufID User ID in CMS
110 * @param string $ufName User name
112 function updateCMSName($ufID, $ufName) {
114 if (function_exists('user_load')) {
115 $user = user_load($ufID);
116 if ($user->mail
!= $ufName) {
117 user_save($user, array('mail' => $ufName));
118 $user = user_load($ufID);
124 * Check if username and email exists in the drupal db
126 * @params $params array array of name and mail values
127 * @params $errors array array of errors
128 * @params $emailName string field label for the 'email'
132 static function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
133 $config = CRM_Core_Config
::singleton();
135 $dao = new CRM_Core_DAO();
136 $name = $dao->escape(CRM_Utils_Array
::value('name', $params));
137 $email = $dao->escape(CRM_Utils_Array
::value('mail', $params));
138 $errors = form_get_errors();
140 // unset drupal messages to avoid twice display of errors
141 unset($_SESSION['messages']);
144 if (CRM_Utils_Array
::value('name', $params)) {
145 if ($nameError = user_validate_name($params['name'])) {
146 $errors['cms_name'] = $nameError;
150 "SELECT uid FROM {users} WHERE name = :name",
151 array(':name' => $params['name'])
154 $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', array(1 => $params['name']));
159 if (CRM_Utils_Array
::value('mail', $params)) {
160 if ($emailError = user_validate_mail($params['mail'])) {
161 $errors[$emailName] = $emailError;
165 "SELECT uid FROM {users} WHERE mail = :mail",
166 array(':mail' => $params['mail'])
169 $resetUrl = $config->userFrameworkBaseURL
. 'user/password';
170 $errors[$emailName] = ts('The email address %1 is already registered. <a href="%2">Have you forgotten your password?</a>',
171 array(1 => $params['mail'], 2 => $resetUrl)
179 * Function to get the drupal destination string. When this is passed in the
180 * URL the user will be directed to it after filling in the drupal form
182 * @param object $form Form object representing the 'current' form - to which the user will be returned
183 * @return string $destination destination value for URL
186 function getLoginDestination(&$form) {
189 $id = $form->get('id');
194 $gid = $form->get('gid');
196 $args .= "&gid=$gid";
199 // Setup Personal Campaign Page link uses pageId
200 $pageId = $form->get('pageId');
202 $component = $form->get('component');
203 $args .= "&pageId=$pageId&component=$component&action=add";
210 // append destination so user is returned to form they came from after login
211 $destination = CRM_Utils_System
::currentPath() . '?reset=1' . $args;
217 * Get user login URL for hosting CMS (method declared in each CMS system class)
219 * @param string $destination - if present, add destination to querystring (works for Drupal only)
221 * @return string - loginURL for the current CMS
224 public function getLoginURL($destination = '') {
225 $config = CRM_Core_Config
::singleton();
226 $loginURL = $config->userFrameworkBaseURL
;
228 if (!empty($destination)) {
229 // append destination so user is returned to form they came from after login
230 $loginURL .= '?destination=' . urlencode($destination);
237 * sets the title of the page
239 * @param string $title
240 * @paqram string $pageTitle
245 function setTitle($title, $pageTitle = NULL) {
246 if (arg(0) == 'civicrm') {
251 drupal_set_title($pageTitle, PASS_THROUGH
);
256 * Append an additional breadcrumb tag to the existing breadcrumb
258 * @param string $title
264 function appendBreadCrumb($breadCrumbs) {
265 $breadCrumb = drupal_get_breadcrumb();
267 if (is_array($breadCrumbs)) {
268 foreach ($breadCrumbs as $crumbs) {
269 if (stripos($crumbs['url'], 'id%%')) {
270 $args = array('cid', 'mid');
271 foreach ($args as $a) {
272 $val = CRM_Utils_Request
::retrieve($a, 'Positive', CRM_Core_DAO
::$_nullObject,
276 $crumbs['url'] = str_ireplace("%%{$a}%%", $val, $crumbs['url']);
280 $breadCrumb[] = "<a href=\"{$crumbs['url']}\">{$crumbs['title']}</a>";
283 drupal_set_breadcrumb($breadCrumb);
287 * Reset an additional breadcrumb tag to the existing breadcrumb
292 function resetBreadCrumb() {
294 drupal_set_breadcrumb($bc);
298 * Append a string to the head of the html file
300 * @param string $header the new string to be appended
305 function addHTMLHead($header) {
307 if (!empty($header)) {
308 $key = 'civi_' . ++
$count;
311 '#markup' => $header,
313 drupal_add_html_head($data, $key);
320 * @param $url: string, absolute path to file
321 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
323 * Note: This function is not to be called directly
324 * @see CRM_Core_Region::render()
326 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
329 public function addScriptUrl($url, $region) {
330 $params = array('group' => JS_LIBRARY
, 'weight' => 10);
334 $params['scope'] = substr($region, 5);
339 // If the path is within the drupal directory we can use the more efficient 'file' setting
340 $params['type'] = self
::formatResourceUrl($url) ?
'file' : 'external';
341 drupal_add_js($url, $params);
346 * Add an inline script
348 * @param $code: string, javascript code
349 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
351 * Note: This function is not to be called directly
352 * @see CRM_Core_Region::render()
354 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
357 public function addScript($code, $region) {
358 $params = array('type' => 'inline', 'group' => JS_LIBRARY
, 'weight' => 10);
362 $params['scope'] = substr($region, 5);
367 drupal_add_js($code, $params);
374 * @param $url: string, absolute path to file
375 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
377 * Note: This function is not to be called directly
378 * @see CRM_Core_Region::render()
380 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
383 public function addStyleUrl($url, $region) {
384 if ($region != 'html-header') {
388 // If the path is within the drupal directory we can use the more efficient 'file' setting
389 $params['type'] = self
::formatResourceUrl($url) ?
'file' : 'external';
390 drupal_add_css($url, $params);
395 * Add an inline style
397 * @param $code: string, css code
398 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
400 * Note: This function is not to be called directly
401 * @see CRM_Core_Region::render()
403 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
406 public function addStyle($code, $region) {
407 if ($region != 'html-header') {
410 $params = array('type' => 'inline');
411 drupal_add_css($code, $params);
416 * Check if a resource url is within the drupal directory and format appropriately
418 * @param url (reference)
420 * @return bool: TRUE for internal paths, FALSE for external
422 static function formatResourceUrl(&$url) {
424 $base = CRM_Core_Config
::singleton()->resourceBase
;
426 // Handle absolute urls
427 if (strpos($url, $base_url) === 0) {
429 $url = trim(str_replace($base_url, '', $url), '/');
431 // Handle relative urls
432 elseif (strpos($url, $base) === 0) {
434 $url = substr(drupal_get_path('module', 'civicrm'), 0, -6) . trim(substr($url, strlen($base)), '/');
436 // Strip query string
437 $q = strpos($url, '?');
438 if ($q && $internal) {
439 $url = substr($url, 0, $q);
445 * rewrite various system urls to https
452 function mapConfigToSSL() {
454 $base_url = str_replace('http://', 'https://', $base_url);
458 * figure out the post url for the form
460 * @param mix $action the default action if one is pre-specified
462 * @return string the url to post the form
465 function postURL($action) {
466 if (!empty($action)) {
470 return $this->url($_GET['q']);
474 * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
476 * @param $path string The path being linked to, such as "civicrm/add"
477 * @param $query string A query string to append to the link.
478 * @param $absolute boolean Whether to force the output to be an absolute link (beginning with http:).
479 * Useful for links that will be displayed outside the site, such as in an
481 * @param $fragment string A fragment identifier (named anchor) to append to the link.
482 * @param $htmlize boolean whether to convert to html eqivalant
483 * @param $frontend boolean a gross joomla hack
485 * @return string an HTML string containing a link to the given path.
489 function url($path = NULL, $query = NULL, $absolute = FALSE,
490 $fragment = NULL, $htmlize = TRUE,
491 $frontend = FALSE, $forceBackend = FALSE
493 $config = CRM_Core_Config
::singleton();
494 $script = 'index.php';
496 $path = CRM_Utils_String
::stripPathChars($path);
498 if (isset($fragment)) {
499 $fragment = '#' . $fragment;
502 if (!isset($config->useFrameworkRelativeBase
)) {
503 $base = parse_url($config->userFrameworkBaseURL
);
504 $config->useFrameworkRelativeBase
= $base['path'];
506 $base = $absolute ?
$config->userFrameworkBaseURL
: $config->useFrameworkRelativeBase
;
508 $separator = $htmlize ?
'&' : '&';
510 if (!$config->cleanURL
) {
513 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
516 return $base . $script . '?q=' . $path . $fragment;
521 return $base . $script . '?' . $query . $fragment;
524 return $base . $fragment;
531 return $base . $path . '?' . $query . $fragment;
534 return $base . $path . $fragment;
539 return $base . $script . '?' . $query . $fragment;
542 return $base . $fragment;
549 * Authenticate the user against the drupal db
551 * @param string $name the user name
552 * @param string $password the password for the above user name
553 * @param $loadCMSBootstrap boolean load cms bootstrap?
555 * @return mixed false if no auth
557 * contactID, ufID, unique string ) if success
560 static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
561 require_once 'DB.php';
563 $config = CRM_Core_Config
::singleton();
565 $dbDrupal = DB
::connect($config->userFrameworkDSN
);
566 if (DB
::isError($dbDrupal)) {
567 CRM_Core_Error
::fatal("Cannot connect to drupal db via $config->userFrameworkDSN, " . $dbDrupal->getMessage());
572 $account = $userUid = $userMail = NULL;
573 if ($loadCMSBootstrap) {
574 $bootStrapParams = array();
575 if ($name && $password) {
576 $bootStrapParams = array(
581 CRM_Utils_System
::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
585 $userUid = $user->uid
;
586 $userMail = $user->mail
;
591 // SOAP cannot load drupal bootstrap and hence we do it the old way
592 // Contact CiviSMTP folks if we run into issues with this :)
593 $cmsPath = $config->userSystem
->cmsRootPath($realPath);
595 require_once ("$cmsPath/includes/bootstrap.inc");
596 require_once ("$cmsPath/includes/password.inc");
598 $strtolower = function_exists('mb_strtolower') ?
'mb_strtolower' : 'strtolower';
599 $name = $dbDrupal->escapeSimple($strtolower($name));
602 FROM {$config->userFrameworkUsersTableName} u
603 WHERE LOWER(u.name) = '$name'
607 $query = $dbDrupal->query($sql);
608 $row = $query->fetchRow(DB_FETCHMODE_ASSOC
);
611 $fakeDrupalAccount = drupal_anonymous_user();
612 $fakeDrupalAccount->name
= $name;
613 $fakeDrupalAccount->pass
= $row['pass'];
614 $passwordCheck = user_check_password($password, $fakeDrupalAccount);
615 if ($passwordCheck) {
616 $userUid = $row['uid'];
617 $userMail = $row['mail'];
622 if ($userUid && $userMail) {
623 CRM_Core_BAO_UFMatch
::synchronizeUFMatch($account, $userUid, $userMail, 'Drupal');
624 $contactID = CRM_Core_BAO_UFMatch
::getContactId($userUid);
628 return array($contactID, $userUid, mt_rand());
634 * Load user into session
636 function loadUser($username) {
639 $user = user_load_by_name($username);
641 if (empty($user->uid
)) {
646 $contact_id = CRM_Core_BAO_UFMatch
::getContactId($uid);
648 // lets store contact id and user id in session
649 $session = CRM_Core_Session
::singleton();
650 $session->set('ufID', $uid);
651 $session->set('userID', $contact_id);
656 * Set a message in the UF to display to a user
658 * @param string $message the message to set
662 function setMessage($message) {
663 drupal_set_message($message);
666 function permissionDenied() {
667 drupal_access_denied();
671 module_load_include('inc', 'user', 'user.pages');
672 return user_logout();
675 function updateCategories() {
676 // copied this from profile.module. Seems a bit inefficient, but i dont know a better way
683 * Get the default location for CiviCRM blocks
687 function getDefaultBlockLocation() {
688 return 'sidebar_first';
692 * Get the locale set in the hosting CMS
694 * @return string with the locale or null for none
696 function getUFLocale() {
697 // return CiviCRM’s xx_YY locale that either matches Drupal’s Chinese locale
698 // (for CRM-6281), Drupal’s xx_YY or is retrieved based on Drupal’s xx
699 // sometimes for CLI based on order called, this might not be set and/or empty
702 if (empty($language)) {
706 if ($language->language
== 'zh-hans') {
710 if ($language->language
== 'zh-hant') {
714 if (preg_match('/^.._..$/', $language->language
)) {
715 return $language->language
;
718 return CRM_Core_I18n_PseudoConstant
::longForShort(substr($language->language
, 0, 2));
721 function getVersion() {
722 return defined('VERSION') ? VERSION
: 'Unknown';
726 * load drupal bootstrap
728 * @param $params array with uid or name and password
729 * @param $loadUser boolean load cms user?
730 * @param $throwError throw error on failure?
733 function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
734 //take the cms root path.
735 $cmsPath = $this->cmsRootPath($realPath);
737 if (!file_exists("$cmsPath/includes/bootstrap.inc")) {
739 echo '<br />Sorry, could not locate bootstrap.inc\n';
744 // load drupal bootstrap
746 define('DRUPAL_ROOT', $cmsPath);
748 // For drupal multi-site CRM-11313
749 if ($realPath && strpos($realPath, 'sites/all/modules/') === FALSE) {
750 preg_match('@sites/([^/]*)/modules@s', $realPath, $matches);
751 if (!empty($matches[1])) {
752 $_SERVER['HTTP_HOST'] = $matches[1];
755 require_once 'includes/bootstrap.inc';
756 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL
);
758 // explicitly setting error reporting, since we cannot handle drupal related notices
760 if (!function_exists('module_exists') ||
!module_exists('civicrm')) {
762 echo '<br />Sorry, could not load drupal bootstrap.';
768 // seems like we've bootstrapped drupal
769 $config = CRM_Core_Config
::singleton();
771 // lets also fix the clean url setting
773 $config->cleanURL
= (int) variable_get('clean_url', '0');
775 // we need to call the config hook again, since we now know
776 // all the modules that are listening on it, does not apply
777 // to J! and WP as yet
779 CRM_Utils_Hook
::config($config);
785 $uid = CRM_Utils_Array
::value('uid', $params);
787 //load user, we need to check drupal permissions.
788 $name = CRM_Utils_Array
::value('name', $params, FALSE) ?
$params['name'] : trim(CRM_Utils_Array
::value('name', $_REQUEST));
789 $pass = CRM_Utils_Array
::value('pass', $params, FALSE) ?
$params['pass'] : trim(CRM_Utils_Array
::value('pass', $_REQUEST));
792 $uid = user_authenticate($name, $pass);
795 echo '<br />Sorry, unrecognized username or password.';
804 $account = user_load($uid);
805 if ($account && $account->uid
) {
813 echo '<br />Sorry, can not load CMS user account.';
817 // CRM-6948: When using loadBootStrap, it's implicit that CiviCRM has already loaded its settings
818 // which means that define(CIVICRM_CLEANURL) was correctly set.
820 $config = CRM_Core_Config
::singleton();
821 $config->cleanURL
= (int)variable_get('clean_url', '0');
823 // CRM-8655: Drupal wasn't available during bootstrap, so hook_civicrm_config never executes
824 CRM_Utils_Hook
::config($config);
829 function cmsRootPath($scriptFilename = NULL) {
831 $cmsRoot = $valid = NULL;
833 if (!is_null($scriptFilename)) {
834 $path = $scriptFilename;
837 $path = $_SERVER['SCRIPT_FILENAME'];
840 if (function_exists('drush_get_context')) {
841 // drush anyway takes care of multisite install etc
842 return drush_get_context('DRUSH_DRUPAL_ROOT');
845 $pathVars = explode('/',
846 str_replace('//', '/',
847 str_replace('\\', '/', $path)
851 //lets store first var,
852 //need to get back for windows.
853 $firstVar = array_shift($pathVars);
855 //lets remove sript name to reduce one iteration.
856 array_pop($pathVars);
858 //CRM-7429 --do check for upper most 'includes' dir,
859 //which would effectually work for multisite installation.
861 $cmsRoot = $firstVar . '/' . implode('/', $pathVars);
862 $cmsIncludePath = "$cmsRoot/includes";
863 //stop as we found bootstrap.
864 if (@opendir
($cmsIncludePath) &&
865 file_exists("$cmsIncludePath/bootstrap.inc")
870 //remove one directory level.
871 array_pop($pathVars);
872 } while (count($pathVars));
874 return ($valid) ?
$cmsRoot : NULL;
878 * check is user logged in.
880 * @return boolean true/false.
882 public function isUserLoggedIn() {
884 if (function_exists('user_is_logged_in')) {
885 $isloggedIn = user_is_logged_in();
892 * Get currently logged in user uf id.
894 * @return int $userID logged in user uf id.
896 public function getLoggedInUfID() {
898 if (function_exists('user_is_logged_in') &&
899 user_is_logged_in() &&
900 function_exists('user_uid_optional_to_arg')
902 $ufID = user_uid_optional_to_arg(array());
909 * Format the url as per language Negotiation.
913 * @return string $url, formatted url.
916 function languageNegotiationURL(
918 $addLanguagePart = TRUE,
919 $removeLanguagePart = FALSE
925 //CRM-7803 -from d7 onward.
926 $config = CRM_Core_Config
::singleton();
927 if (function_exists('variable_get') &&
928 module_exists('locale') &&
929 function_exists('language_negotiation_get')
933 //does user configuration allow language
934 //support from the URL (Path prefix or domain)
935 if (language_negotiation_get('language') == 'locale-url') {
936 $urlType = variable_get('locale_language_negotiation_url_part');
939 if ($urlType == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX
) {
940 if (isset($language->prefix
) && $language->prefix
) {
941 if ($addLanguagePart) {
942 $url .= $language->prefix
. '/';
944 if ($removeLanguagePart) {
945 $url = str_replace("/{$language->prefix}/", '/', $url);
950 if ($urlType == LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN
) {
951 if (isset($language->domain
) && $language->domain
) {
952 if ($addLanguagePart) {
953 $url = CRM_Utils_File
::addTrailingSlash($language->domain
, '/');
955 if ($removeLanguagePart && defined('CIVICRM_UF_BASEURL')) {
956 $url = str_replace('\\', '/', $url);
957 $parseUrl = parse_url($url);
959 //kinda hackish but not sure how to do it right
960 //hope http_build_url() will help at some point.
961 if (is_array($parseUrl) && !empty($parseUrl)) {
962 $urlParts = explode('/', $url);
963 $hostKey = array_search($parseUrl['host'], $urlParts);
964 $ufUrlParts = parse_url(CIVICRM_UF_BASEURL
);
965 $urlParts[$hostKey] = $ufUrlParts['host'];
966 $url = implode('/', $urlParts);
978 * Find any users/roles/security-principals with the given permission
979 * and replace it with one or more permissions.
981 * @param $oldPerm string
982 * @param $newPerms array, strings
986 function replacePermission($oldPerm, $newPerms) {
987 $roles = user_roles(FALSE, $oldPerm);
988 if (!empty($roles)) {
989 foreach (array_keys($roles) as $rid) {
990 user_role_revoke_permissions($rid, array($oldPerm));
991 user_role_grant_permissions($rid, $newPerms);
997 * Get a list of all installed modules, including enabled and disabled ones
999 * @return array CRM_Core_Module
1001 function getModules() {
1003 $q = db_query('SELECT name, status FROM {system} WHERE type = \'module\' AND schema_version <> -1');
1004 foreach ($q as $row) {
1005 $result[] = new CRM_Core_Module('drupal.' . $row->name
, ($row->status
== 1) ?
TRUE : FALSE);
1011 * Wrapper for og_membership creation
1013 function og_membership_create($ogID, $drupalID){
1014 if (function_exists('og_entity_query_alter')) {
1015 // sort-of-randomly chose a function that only exists in the 7.x-2.x branch
1016 // TODO: Find a more solid way to make this test
1017 // Also, since we don't know how to get the entity type of the group, we'll assume it's 'node'
1018 og_group('node', $ogID, array('entity' => user_load($drupalID)));
1021 // Works for the OG 7.x-1.x branch
1022 og_group($ogID, array('entity' => user_load($drupalID)));
1027 * Wrapper for og_membership deletion
1029 function og_membership_delete($ogID, $drupalID) {
1030 if (function_exists('og_entity_query_alter')) {
1031 // sort-of-randomly chose a function that only exists in the 7.x-2.x branch
1032 // TODO: Find a more solid way to make this test
1033 // Also, since we don't know how to get the entity type of the group, we'll assume it's 'node'
1034 og_ungroup('node', $ogID, 'user', user_load($drupalID));
1036 // Works for the OG 7.x-1.x branch
1037 og_ungroup($ogID, 'user', user_load($drupalID));
1042 * Reset any system caches that may be required for proper CiviCRM
1046 drupal_flush_all_caches();