From cc3fa1178d09b3e4354c28e69b449ab2e4e89cec Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 18 Jul 2016 09:27:05 +0000 Subject: [PATCH] CRM-19098 Add in Group Settings to add new group on import --- CRM/Contact/Import/Form/Preview.php | 11 +++++++++++ CRM/Contact/Import/ImportJob.php | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Import/Form/Preview.php b/CRM/Contact/Import/Form/Preview.php index a3c5faa899..f608ecc6bc 100644 --- a/CRM/Contact/Import/Form/Preview.php +++ b/CRM/Contact/Import/Form/Preview.php @@ -151,6 +151,14 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview { public function buildQuickForm() { $this->addElement('text', 'newGroupName', ts('Name for new group')); $this->addElement('text', 'newGroupDesc', ts('Description of new group')); + $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE); + if (!empty($groupTypes)) { + $this->addCheckBox('newGroupType', + ts('Group Type'), + $groupTypes, + NULL, NULL, NULL, NULL, '   ' + ); + } $groups = $this->get('groups'); @@ -273,6 +281,7 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview { 'dedupe' => $this->get('dedupe'), 'newGroupName' => $this->controller->exportValue($this->_name, 'newGroupName'), 'newGroupDesc' => $this->controller->exportValue($this->_name, 'newGroupDesc'), + 'newGroupType' => $this->controller->exportValue($this->_name, 'newGroupType'), 'groups' => $this->controller->exportValue($this->_name, 'groups'), 'allGroups' => $this->get('groups'), 'newTagName' => $this->controller->exportValue($this->_name, 'newTagName'), @@ -366,6 +375,7 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview { $onDuplicate = $this->get('onDuplicate'); $newGroupName = $this->controller->exportValue($this->_name, 'newGroupName'); $newGroupDesc = $this->controller->exportValue($this->_name, 'newGroupDesc'); + $newGroupType = $this->controller->exportValue($this->_name, 'newGroupType'); $groups = $this->controller->exportValue($this->_name, 'groups'); $allGroups = $this->get('groups'); $newTagName = $this->controller->exportValue($this->_name, 'newTagName'); @@ -497,6 +507,7 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview { 'name' => $newGroupName, 'title' => $newGroupName, 'description' => $newGroupDesc, + 'group_type' => $newGroupType, 'is_active' => TRUE, ); $group = CRM_Contact_BAO_Group::create($gParams); diff --git a/CRM/Contact/Import/ImportJob.php b/CRM/Contact/Import/ImportJob.php index c3911afeb4..02a0d43420 100644 --- a/CRM/Contact/Import/ImportJob.php +++ b/CRM/Contact/Import/ImportJob.php @@ -49,6 +49,7 @@ class CRM_Contact_Import_ImportJob { protected $_dedupe; protected $_newGroupName; protected $_newGroupDesc; + protected $_newGroupType; protected $_groups; protected $_allGroups; protected $_newTagName; @@ -316,7 +317,8 @@ class CRM_Contact_Import_ImportJob { if ($this->_newGroupName || count($this->_groups)) { $groupAdditions = $this->_addImportedContactsToNewGroup($contactIds, $this->_newGroupName, - $this->_newGroupDesc + $this->_newGroupDesc, + $this->_newGroupType ); if ($form) { $form->set('groupAdditions', $groupAdditions); @@ -350,7 +352,7 @@ class CRM_Contact_Import_ImportJob { */ private function _addImportedContactsToNewGroup( $contactIds, - $newGroupName, $newGroupDesc + $newGroupName, $newGroupDesc, $newGroupType ) { $newGroupId = NULL; @@ -361,6 +363,7 @@ class CRM_Contact_Import_ImportJob { $gParams = array( 'title' => $newGroupName, 'description' => $newGroupDesc, + 'group_type' => $newGroupType, 'is_active' => TRUE, ); $group = CRM_Contact_BAO_Group::create($gParams); -- 2.25.1