Merge pull request #23746 from totten/master-queue-flag
[civicrm-core.git] / CRM / Member / Import / Form / DataSource.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 /**
19 * This class gets the name of the file to upload
20 */
21 class CRM_Member_Import_Form_DataSource extends CRM_Import_Form_DataSource {
22
23 const PATH = 'civicrm/member/import';
24
25 const IMPORT_ENTITY = 'Membership';
26
27 /**
28 * Get the name of the type to be stored in civicrm_user_job.type_id.
29 *
30 * @return string
31 */
32 public function getUserJobType(): string {
33 return 'membership_import';
34 }
35
36 /**
37 * Build the form object.
38 *
39 * @return void
40 */
41 public function buildQuickForm() {
42 parent::buildQuickForm();
43
44 $this->addRadio('onDuplicate', ts('Import mode'), [
45 CRM_Import_Parser::DUPLICATE_SKIP => ts('Insert new Membership'),
46 CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update existing Membership'),
47 ]);
48 $this->setDefaults([
49 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP,
50 ]);
51
52 $this->addContactTypeSelector();
53 }
54
55 /**
56 * @return \CRM_Member_Import_Parser_Membership
57 */
58 protected function getParser(): CRM_Member_Import_Parser_Membership {
59 if (!$this->parser) {
60 $this->parser = new CRM_Member_Import_Parser_Membership();
61 $this->parser->setUserJobID($this->getUserJobID());
62 $this->parser->init();
63 }
64 return $this->parser;
65 }
66
67 }