From 8b01c2f24a772107a36ed99edd13ef12848d13c3 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 30 Apr 2014 14:47:48 -0700 Subject: [PATCH] CRM-14581 upgrade Multisite form --- CRM/Admin/Form/Preferences.php | 3 ++ CRM/Admin/Form/Preferences/Multisite.php | 14 +++++--- api/v3/Group.php | 46 +++++------------------- 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index 6705d01c64..ce1541edb9 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -188,6 +188,9 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { array('  ', '  ', '
') ); break; + + case 'entity_reference': + $this->addEntityRef($fieldName, NULL, array('entity' => 'group', 'api' => array('params' => array()))); } } diff --git a/CRM/Admin/Form/Preferences/Multisite.php b/CRM/Admin/Form/Preferences/Multisite.php index eb849e3a8e..27d45a0bcf 100644 --- a/CRM/Admin/Form/Preferences/Multisite.php +++ b/CRM/Admin/Form/Preferences/Multisite.php @@ -48,26 +48,30 @@ class CRM_Admin_Form_Preferences_Multisite extends CRM_Admin_Form_Preferences { 'html_type' => 'checkbox', 'title' => ts('Enable Multi Site Configuration'), 'weight' => 1, - 'description' => ts('Multi Site provides support for sharing a single CiviCRM database among multiple sites.') . ' ' . $msDoc, + 'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled') . ' ' . $msDoc, ), - 'uniq_email_per_site' => array( + /** Remove this checkbox until some one knows what this setting does + 'uniq_email_per_site' => array( 'html_type' => 'checkbox', 'title' => ts('Ensure multi sites have a unique email per site'), 'weight' => 2, 'description' => NULL, ), + */ 'domain_group_id' => array( - 'html_type' => 'text', - 'title' => ts('Parent group for this domain'), + 'html_type' => 'entity_reference', + 'title' => ts('Domain Group'), 'weight' => 3, - 'description' => ts('Enter the group ID (civicrm_group.id).'), + 'description' => ts('Contacts created on this site are added to this group'), ), + /** Remove this checkbox until some one knows what this setting does 'event_price_set_domain_id' => array( 'html_type' => 'text', 'title' => ts('Domain for event price sets'), 'weight' => 4, 'description' => NULL, ), + */ ), ); diff --git a/api/v3/Group.php b/api/v3/Group.php index 6cc7647ebc..67f39f0d18 100644 --- a/api/v3/Group.php +++ b/api/v3/Group.php @@ -53,17 +53,7 @@ * @access public */ function civicrm_api3_group_create($params) { - - $group = CRM_Contact_BAO_Group::create($params); - - if (is_null($group)) { - return civicrm_api3_create_error('Group not created'); - } - else { - $values = array(); - _civicrm_api3_object_to_array_unique_fields($group, $values[$group->id]); - return civicrm_api3_create_success($values, $params, 'group', 'create', $group); - } + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Group'); } /** @@ -90,34 +80,16 @@ function _civicrm_api3_group_create_spec(&$params) { * @access public */ function civicrm_api3_group_get($params) { - - $options = _civicrm_api3_get_options_from_params($params, TRUE, 'group', 'get'); - $sort = CRM_Utils_Array::value('sort', $options, NULL); - $offset = CRM_Utils_Array::value('offset', $options); - $rowCount = CRM_Utils_Array::value('limit', $options); - $returnProperties = CRM_Utils_Array::value('return', $options, NULL); - $inputParams = CRM_Utils_Array::value('input_params', $options, array()); - if(is_array($returnProperties) && !empty($returnProperties)){ - // group function takes $returnProperties in non standard format & doesn't add id - unset($returnProperties['group_id']); - $returnProperties['id'] = 1; - $returnProperties = array_keys($returnProperties); - } - if (!empty($inputParams['group_id'])) { - $inputParams['id'] = $inputParams['group_id']; - } - $groupObjects = CRM_Contact_BAO_Group::getGroups($inputParams, $returnProperties, $sort, $offset, $rowCount); - if (empty($groupObjects)) { - return civicrm_api3_create_success(FALSE); - } - $groups = array(); - foreach ($groupObjects as $group) { - _civicrm_api3_object_to_array($group, $groups[$group->id]); - _civicrm_api3_custom_data_get($groups[$group->id], 'Group', $group->id); + $options = _civicrm_api3_get_options_from_params($params, TRUE, 'group', 'get'); + if(empty($options['return']) || !in_array('member_count', $options['return'])) { + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group'); } - - return civicrm_api3_create_success($groups, $params, 'group', 'create'); + $groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group'); + foreach ($groups as $id => $group) { + $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id); + } + return civicrm_api3_create_success($groups, $params, 'group', 'get'); } /** -- 2.25.1