From b61735d1ce675a5179161061898bea957c285a7e Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 23 Aug 2016 15:55:29 -0700 Subject: [PATCH] CRM-15925 - CRM_Import_DataSource_SQL - Declare required permission --- CRM/Import/DataSource.php | 15 ++++++++++++++- CRM/Import/DataSource/SQL.php | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CRM/Import/DataSource.php b/CRM/Import/DataSource.php index b58e6ad848..fb5aa33755 100644 --- a/CRM/Import/DataSource.php +++ b/CRM/Import/DataSource.php @@ -43,7 +43,10 @@ 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(); @@ -69,4 +72,14 @@ abstract class CRM_Import_DataSource { */ 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']); + } + } diff --git a/CRM/Import/DataSource/SQL.php b/CRM/Import/DataSource/SQL.php index 1c084cf5e5..73471e8fa8 100644 --- a/CRM/Import/DataSource/SQL.php +++ b/CRM/Import/DataSource/SQL.php @@ -41,7 +41,10 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { * collection of info about this data source */ public function getInfo() { - return array('title' => ts('SQL Query')); + return array( + 'title' => ts('SQL Query'), + 'permissions' => array('import SQL datasource'), + ); } /** -- 2.25.1