From 4d73a914ee951ce90c0c2efde489841f8116062b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 17 Aug 2022 08:23:31 +1200 Subject: [PATCH] Remove now-unused addField from Participant import --- CRM/Event/Import/Field.php | 139 ------------------------ CRM/Event/Import/Parser/Participant.php | 32 ------ 2 files changed, 171 deletions(-) delete mode 100644 CRM/Event/Import/Field.php diff --git a/CRM/Event/Import/Field.php b/CRM/Event/Import/Field.php deleted file mode 100644 index a3062a2ec0..0000000000 --- a/CRM/Event/Import/Field.php +++ /dev/null @@ -1,139 +0,0 @@ -_name = $name; - $this->_title = $title; - $this->_type = $type; - $this->_headerPattern = $headerPattern; - $this->_dataPattern = $dataPattern; - - $this->_value = NULL; - } - - public function resetValue() { - $this->_value = NULL; - } - - /** - * Convert the value to the type of this field and set the field value with the appropriate type. - * - * @param string $value - */ - public function setValue($value) { - $this->_value = $value; - } - - /** - * @return bool - */ - public function validate() { - if (CRM_Utils_System::isNull($this->_value)) { - return TRUE; - } - - switch ($this->_name) { - case 'contact_id': - // note: we validate existence of the contact in API, upon - // insert (it would be too costly to do a db call here) - return CRM_Utils_Rule::integer($this->_value); - - case 'register_date': - return CRM_Utils_Rule::date($this->_value); - - /* @codingStandardsIgnoreStart - case 'event_id': - static $events = null; - if (!$events) { - $events = CRM_Event_PseudoConstant::event(); - } - if (in_array($this->_value, $events)) { - return true; - } - else { - return false; - } - break; - @codingStandardsIgnoreEnd */ - - default: - break; - } - - // check whether that's a valid custom field id - // and if so, check the contents' validity - if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) { - static $customFields = NULL; - if (!$customFields) { - $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); - } - if (!array_key_exists($customFieldID, $customFields)) { - return FALSE; - } - return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value); - } - return TRUE; - } - -} diff --git a/CRM/Event/Import/Parser/Participant.php b/CRM/Event/Import/Parser/Participant.php index de8b919289..b3d335b453 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -94,12 +94,6 @@ class CRM_Event_Import_Parser_Participant extends CRM_Import_Parser { public function init() { unset($this->userJob); $this->setFieldMetadata(); - foreach ($this->importableFieldsMetadata as $name => $field) { - $field['type'] = CRM_Utils_Array::value('type', $field, CRM_Utils_Type::T_INT); - $field['dataPattern'] = CRM_Utils_Array::value('dataPattern', $field, '//'); - $field['headerPattern'] = CRM_Utils_Array::value('headerPattern', $field, '//'); - $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); - } } /** @@ -536,32 +530,6 @@ class CRM_Event_Import_Parser_Participant extends CRM_Import_Parser { return TRUE; } - /** - * @param string $name - * @param $title - * @param int $type - * @param string $headerPattern - * @param string $dataPattern - */ - public function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') { - if (empty($name)) { - $this->_fields['doNotImport'] = new CRM_Event_Import_Field($name, $title, $type, $headerPattern, $dataPattern); - } - else { - - //$tempField = CRM_Contact_BAO_Contact::importableFields('Individual', null ); - $tempField = CRM_Contact_BAO_Contact::importableFields('All', NULL); - if (!array_key_exists($name, $tempField)) { - $this->_fields[$name] = new CRM_Event_Import_Field($name, $title, $type, $headerPattern, $dataPattern); - } - else { - $this->_fields[$name] = new CRM_Contact_Import_Field($name, $title, $type, $headerPattern, $dataPattern, - CRM_Utils_Array::value('hasLocationType', $tempField[$name]) - ); - } - } - } - /** * Set up field metadata. * -- 2.25.1