From 5a552b8702717ec0be877b50f2a97f416951ed2c 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 5e34ef12f5..57f8e08aaa 100644 --- a/CRM/Contact/Import/Form/Preview.php +++ b/CRM/Contact/Import/Form/Preview.php @@ -144,6 +144,14 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview { public function buildQuickForm() { $this->addElement('text', 'newGroupName', ts('Name for new group'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title')); $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'); @@ -263,6 +271,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'), @@ -353,6 +362,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'); @@ -484,6 +494,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 c5643532ea..52ab6d1414 100644 --- a/CRM/Contact/Import/ImportJob.php +++ b/CRM/Contact/Import/ImportJob.php @@ -47,6 +47,7 @@ class CRM_Contact_Import_ImportJob { protected $_dedupe; protected $_newGroupName; protected $_newGroupDesc; + protected $_newGroupType; protected $_groups; protected $_allGroups; protected $_newTagName; @@ -314,7 +315,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); @@ -348,7 +350,7 @@ class CRM_Contact_Import_ImportJob { */ private function _addImportedContactsToNewGroup( $contactIds, - $newGroupName, $newGroupDesc + $newGroupName, $newGroupDesc, $newGroupType ) { $newGroupId = NULL; @@ -359,6 +361,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