Merge pull request #17541 from seamuslee001/dev_core_560_third_to_last
[civicrm-core.git] / CRM / Import / DataSource.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 * $Id$
17 *
18 */
19
6a488035
TO
20/**
21 * This class defines the DataSource interface but must be subclassed to be
22 * useful.
23 */
24abstract class CRM_Import_DataSource {
25
26 /**
fe482240 27 * Provides information about the data source.
6a488035 28 *
a6c01b45 29 * @return array
11749569
TO
30 * Description of this data source, including:
31 * - title: string, translated, required
32 * - permissions: array, optional
33 *
6a488035
TO
34 */
35 abstract public function getInfo();
36
37 /**
fe482240 38 * Set variables up before form is built.
54957108 39 *
40 * @param CRM_Core_Form $form
6a488035
TO
41 */
42 abstract public function preProcess(&$form);
43
44 /**
54957108 45 * This is function is called by the form object to get the DataSource's form snippet.
6a488035 46 *
54957108 47 * It should add all fields necessary to get the data uploaded to the temporary table in the DB.
6c8f6e67 48 *
54957108 49 * @param CRM_Core_Form $form
6a488035
TO
50 */
51 abstract public function buildQuickForm(&$form);
52
53 /**
fe482240 54 * Process the form submission.
54957108 55 *
56 * @param array $params
57 * @param string $db
58 * @param CRM_Core_Form $form
6a488035
TO
59 */
60 abstract public function postProcess(&$params, &$db, &$form);
96025800 61
11749569
TO
62 /**
63 * Determine if the current user has access to this data source.
64 *
65 * @return bool
66 */
67 public function checkPermission() {
68 $info = $this->getInfo();
69 return empty($info['permissions']) || CRM_Core_Permission::check($info['permissions']);
70 }
71
6a488035 72}