397e3e935bed33bc771752a488c8f12e3a87f99b
[civicrm-core.git] / CRM / Contact / Import / Form / Summary.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 use Civi\Api4\UserJob;
19
20 /**
21 * This class summarizes the import results.
22 */
23 class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary {
24
25 /**
26 * Set variables up before form is built.
27 *
28 * @throws \API_Exception
29 * @throws \CRM_Core_Exception
30 */
31 public function preProcess() {
32 $userJobID = CRM_Utils_Request::retrieve('user_job_id', 'String', $this, TRUE);
33 $userJob = UserJob::get(TRUE)->addWhere('id', '=', $userJobID)->addSelect('metadata', 'type_id:label')->execute()->first();
34 $this->setTitle($userJob['type_id:label']);
35 $onDuplicate = $userJob['metadata']['submitted_values']['onDuplicate'];
36 $this->assign('dupeError', FALSE);
37
38 if ($onDuplicate === CRM_Import_Parser::DUPLICATE_UPDATE) {
39 $this->assign('dupeActionString', ts('These records have been updated with the imported data.'));
40 }
41 elseif ($onDuplicate === CRM_Import_Parser::DUPLICATE_FILL) {
42 $this->assign('dupeActionString', ts('These records have been filled in with the imported data.'));
43 }
44 else {
45 /* Skip by default */
46 $this->assign('dupeActionString', ts('These records have not been imported.'));
47 $this->assign('dupeError', TRUE);
48 }
49
50 $this->assign('groupAdditions', $this->getUserJob()['metadata']['summary_info']['groups'] ?? []);
51 $this->assign('tagAdditions', $this->getUserJob()['metadata']['summary_info']['tags'] ?? []);
52 $this->assignOutputURLs();
53 $session = CRM_Core_Session::singleton();
54 $session->pushUserContext(CRM_Utils_System::url('civicrm/import/contact', 'reset=1'));
55 }
56
57 }