Merge pull request #17614 from demeritcowboy/xmlproc-acttypes-more
[civicrm-core.git] / CRM / Import / 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 * $Id$
17 *
18 */
19
20 /**
21 * This class defines the DataSource interface but must be subclassed to be
22 * useful.
23 */
24 abstract class CRM_Import_DataSource {
25
26 /**
27 * Provides information about the data source.
28 *
29 * @return array
30 * Description of this data source, including:
31 * - title: string, translated, required
32 * - permissions: array, optional
33 *
34 */
35 abstract public function getInfo();
36
37 /**
38 * Set variables up before form is built.
39 *
40 * @param CRM_Core_Form $form
41 */
42 abstract public function preProcess(&$form);
43
44 /**
45 * This is function is called by the form object to get the DataSource's form snippet.
46 *
47 * It should add all fields necessary to get the data uploaded to the temporary table in the DB.
48 *
49 * @param CRM_Core_Form $form
50 */
51 abstract public function buildQuickForm(&$form);
52
53 /**
54 * Process the form submission.
55 *
56 * @param array $params
57 * @param string $db
58 * @param CRM_Core_Form $form
59 */
60 abstract public function postProcess(&$params, &$db, &$form);
61
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
72 }