Skip to content

Commit

Permalink
Merge pull request #23740 from eileenmcnaughton/import_unused
Browse files Browse the repository at this point in the history
Remove unused functions
  • Loading branch information
seamuslee001 authored Jun 9, 2022
2 parents 8720f08 + 9726737 commit dffc11f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 90 deletions.
1 change: 0 additions & 1 deletion .toxic.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"CRM_Contact_Import_Form_MapField::buildQuickForm()": "toxicAlert",
"CRM_Contact_Import_Parser_Contact::formatCommonData()": "toxicAlert",
"CRM_Contact_Import_Parser_Contact::formatContactParameters()": "toxicAlert",
"CRM_Contact_Import_Parser_Contact::run()": "toxicAlert",
"CRM_Contact_Import_Parser_Contact::import()": "toxicAlert",
"CRM_Contribute_BAO_Contribution::recordFinancialAccounts()": "toxicAlert",
"CRM_Contribute_BAO_Contribution::transitionComponents()": "toxicAlert",
Expand Down
89 changes: 0 additions & 89 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,49 +104,6 @@ protected function isParseStreetAddress() : bool {
return (bool) (CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options')['street_address_parsing'] ?? FALSE);
}

/**
* Handle the values in preview mode.
*
* Function will be deprecated in favour of validateValues.
*
* @param array $values
* The array of values belonging to this line.
*
* @return bool
* the result of this processing
* CRM_Import_Parser::ERROR or CRM_Import_Parser::VALID
*/
public function preview(&$values) {
return $this->summary($values);
}

/**
* Handle the values in summary mode.
*
* Function will be deprecated in favour of validateValues.
*
* @param array $values
* The array of values belonging to this line.
*
* @return int
* the result of this processing
* CRM_Import_Parser::ERROR or CRM_Import_Parser::VALID
*/
public function summary(&$values): int {
$rowNumber = (int) ($values[array_key_last($values)]);
try {
$this->validateValues($values);
}
catch (CRM_Core_Exception $e) {
$this->setImportStatus($rowNumber, 'ERROR', $e->getMessage());
array_unshift($values, $e->getMessage());
return CRM_Import_Parser::ERROR;
}
$this->setImportStatus($rowNumber, 'NEW', '');

return CRM_Import_Parser::VALID;
}

/**
* Handle the values in import mode.
*
Expand Down Expand Up @@ -1149,52 +1106,6 @@ public function addField(
public function set($store, $mode = self::MODE_SUMMARY) {
}

/**
* Export data to a CSV file.
*
* @param string $fileName
* @param array $header
* @param array $data
*/
public static function exportCSV($fileName, $header, $data) {

if (file_exists($fileName) && !is_writable($fileName)) {
CRM_Core_Error::movedSiteError($fileName);
}
//hack to remove '_status', '_statusMsg' and '_id' from error file
$errorValues = [];
$dbRecordStatus = ['IMPORTED', 'ERROR', 'DUPLICATE', 'INVALID', 'NEW'];
foreach ($data as $rowCount => $rowValues) {
$count = 0;
foreach ($rowValues as $key => $val) {
if (in_array($val, $dbRecordStatus) && $count == (count($rowValues) - 3)) {
break;
}
$errorValues[$rowCount][$key] = $val;
$count++;
}
}
$data = $errorValues;

$output = [];
$fd = fopen($fileName, 'w');

foreach ($header as $key => $value) {
$header[$key] = "\"$value\"";
}
$config = CRM_Core_Config::singleton();
$output[] = implode($config->fieldSeparator, $header);

foreach ($data as $datum) {
foreach ($datum as $key => $value) {
$datum[$key] = "\"$value\"";
}
$output[] = implode($config->fieldSeparator, $datum);
}
fwrite($fd, implode("\n", $output));
fclose($fd);
}

/**
* Format contact parameters.
*
Expand Down

0 comments on commit dffc11f

Please sign in to comment.