From 3ea6a867411cf19032b73240ab362bbabe07fc47 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 10 Aug 2022 14:10:40 +1200 Subject: [PATCH] Fold only parent class into only child class --- CRM/Contact/Import/Form/Summary.php | 57 +++++++++++++++++- CRM/Import/Form/Summary.php | 92 ----------------------------- 2 files changed, 55 insertions(+), 94 deletions(-) delete mode 100644 CRM/Import/Form/Summary.php diff --git a/CRM/Contact/Import/Form/Summary.php b/CRM/Contact/Import/Form/Summary.php index d8efd8ab36..bae571b673 100644 --- a/CRM/Contact/Import/Form/Summary.php +++ b/CRM/Contact/Import/Form/Summary.php @@ -20,7 +20,7 @@ use Civi\Api4\UserJob; /** * This class summarizes the import results. */ -class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary { +class CRM_Contact_Import_Form_Summary extends CRM_Import_Forms { /** * Set variables up before form is built. @@ -28,7 +28,7 @@ class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary { * @throws \API_Exception * @throws \CRM_Core_Exception */ - public function preProcess() { + public function preProcess(): void { $userJobID = CRM_Utils_Request::retrieve('user_job_id', 'String', $this, TRUE); $userJob = UserJob::get(TRUE)->addWhere('id', '=', $userJobID)->addSelect('metadata', 'job_type:label')->execute()->first(); $this->setTitle($userJob['job_type:label']); @@ -54,4 +54,57 @@ class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary { $session->pushUserContext(CRM_Utils_System::url('civicrm/import/contact', 'reset=1')); } + /** + * Assign the relevant smarty variables. + * + * @throws \API_Exception + * @throws \CRM_Core_Exception + * @throws \Civi\API\Exception\UnauthorizedException + */ + protected function assignOutputURLs(): void { + $this->assign('outputUnavailable', FALSE); + try { + $this->assign('totalRowCount', $this->getRowCount()); + $this->assign('validRowCount', $this->getRowCount(CRM_Import_Parser::VALID) + $this->getRowCount(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING)); + $this->assign('invalidRowCount', $this->getRowCount(CRM_Import_Parser::ERROR)); + $this->assign('duplicateRowCount', $this->getRowCount(CRM_Import_Parser::DUPLICATE)); + $this->assign('unMatchCount', $this->getRowCount(CRM_Import_Parser::NO_MATCH)); + $this->assign('validSoftCreditRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT)); + $this->assign('invalidSoftCreditRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT_ERROR)); + $this->assign('validPledgePaymentRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT)); + $this->assign('invalidPledgePaymentRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR)); + $this->assign('unparsedAddressCount', $this->getRowCount(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING)); + $this->assign('downloadDuplicateRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::DUPLICATE)); + $this->assign('downloadErrorRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::ERROR)); + $this->assign('downloadMismatchRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::NO_MATCH)); + $this->assign('downloadAddressRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING)); + $this->assign('downloadPledgePaymentErrorRecordsUrl', $this->getDownloadURL(CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR)); + $this->assign('downloadSoftCreditErrorRecordsUrl', $this->getDownloadURL(CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT_ERROR)); + $this->assign('trackingSummary', $this->getTrackingSummary()); + + $userJobID = CRM_Utils_Request::retrieve('user_job_id', 'String', $this, TRUE); + $userJob = UserJob::get(TRUE) + ->addWhere('id', '=', $userJobID) + ->execute() + ->first(); + $onDuplicate = (int) $userJob['metadata']['submitted_values']['onDuplicate']; + $this->assign('dupeError', FALSE); + if ($onDuplicate === CRM_Import_Parser::DUPLICATE_UPDATE) { + $dupeActionString = ts('These records have been updated with the imported data.'); + } + elseif ($onDuplicate === CRM_Import_Parser::DUPLICATE_FILL) { + $dupeActionString = ts('These records have been filled in with the imported data.'); + } + else { + // Skip by default. + $dupeActionString = ts('These records have not been imported.'); + $this->assign('dupeError', TRUE); + } + $this->assign('dupeActionString', $dupeActionString); + } + catch (CRM_Import_Exception_ImportTableUnavailable $e) { + $this->assign('outputUnavailable', TRUE); + } + } + } diff --git a/CRM/Import/Form/Summary.php b/CRM/Import/Form/Summary.php deleted file mode 100644 index 8cf4e73401..0000000000 --- a/CRM/Import/Form/Summary.php +++ /dev/null @@ -1,92 +0,0 @@ -assignOutputURLs(); - } - - /** - * Return a descriptive name for the page, used in wizard header. - * - * @return string - */ - public function getTitle() { - return ts('Summary'); - } - - protected function assignOutputURLs(): void { - $this->assign('outputUnavailable', FALSE); - try { - $this->assign('totalRowCount', $this->getRowCount()); - $this->assign('validRowCount', $this->getRowCount(CRM_Import_Parser::VALID) + $this->getRowCount(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING)); - $this->assign('invalidRowCount', $this->getRowCount(CRM_Import_Parser::ERROR)); - $this->assign('duplicateRowCount', $this->getRowCount(CRM_Import_Parser::DUPLICATE)); - $this->assign('unMatchCount', $this->getRowCount(CRM_Import_Parser::NO_MATCH)); - $this->assign('validSoftCreditRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT)); - $this->assign('invalidSoftCreditRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT_ERROR)); - $this->assign('validPledgePaymentRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT)); - $this->assign('invalidPledgePaymentRowCount', $this->getRowCount(CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR)); - $this->assign('unparsedAddressCount', $this->getRowCount(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING)); - $this->assign('downloadDuplicateRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::DUPLICATE)); - $this->assign('downloadErrorRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::ERROR)); - $this->assign('downloadMismatchRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::NO_MATCH)); - $this->assign('downloadAddressRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING)); - $this->assign('downloadPledgePaymentErrorRecordsUrl', $this->getDownloadURL(CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR)); - $this->assign('downloadSoftCreditErrorRecordsUrl', $this->getDownloadURL(CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT_ERROR)); - $this->assign('trackingSummary', $this->getTrackingSummary()); - - $userJobID = CRM_Utils_Request::retrieve('user_job_id', 'String', $this, TRUE); - $userJob = UserJob::get(TRUE) - ->addWhere('id', '=', $userJobID) - ->execute() - ->first(); - $onDuplicate = (int) $userJob['metadata']['submitted_values']['onDuplicate']; - $this->assign('dupeError', FALSE); - if ($onDuplicate === CRM_Import_Parser::DUPLICATE_UPDATE) { - $dupeActionString = ts('These records have been updated with the imported data.'); - } - elseif ($onDuplicate === CRM_Import_Parser::DUPLICATE_FILL) { - $dupeActionString = ts('These records have been filled in with the imported data.'); - } - else { - // Skip by default. - $dupeActionString = ts('These records have not been imported.'); - $this->assign('dupeError', TRUE); - } - $this->assign('dupeActionString', $dupeActionString); - } - catch (CRM_Import_Exception_ImportTableUnavailable $e) { - $this->assign('outputUnavailable', TRUE); - } - } - -} -- 2.25.1