Merge pull request #10383 from MegaphoneJon/unsupervised-reserved-threshold
[civicrm-core.git] / CRM / Import / DataSource.php
index 3e8258b91c7546b634ad8b243e92215b82f4e311..9091e3f647a102ed124fe2b0df6a1d274f7e2488 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2017
  * $Id$
  *
  */
@@ -43,30 +43,46 @@ abstract class CRM_Import_DataSource {
    * Provides information about the data source.
    *
    * @return array
-   *   collection of info about this data source
+   *   Description of this data source, including:
+   *   - title: string, translated, required
+   *   - permissions: array, optional
+   *
    */
   abstract public function getInfo();
 
   /**
    * Set variables up before form is built.
+   *
+   * @param CRM_Core_Form $form
    */
   abstract public function preProcess(&$form);
 
   /**
-   * This is function is called by the form object to get the DataSource's
-   * form snippet. It should add all fields necesarry to get the data
-   * uploaded to the temporary table in the DB.
+   * This is function is called by the form object to get the DataSource's form snippet.
    *
-   * @param CRM_Core_Form $form
+   * It should add all fields necessary to get the data uploaded to the temporary table in the DB.
    *
-   * @return void
-   *   (operates directly on form argument)
+   * @param CRM_Core_Form $form
    */
   abstract public function buildQuickForm(&$form);
 
   /**
    * Process the form submission.
+   *
+   * @param array $params
+   * @param string $db
+   * @param CRM_Core_Form $form
    */
   abstract public function postProcess(&$params, &$db, &$form);
 
+  /**
+   * Determine if the current user has access to this data source.
+   *
+   * @return bool
+   */
+  public function checkPermission() {
+    $info = $this->getInfo();
+    return empty($info['permissions']) || CRM_Core_Permission::check($info['permissions']);
+  }
+
 }