From b0b2638a57457fa4cda345caef1dc660ea982716 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Tue, 5 Mar 2013 21:42:15 -0800 Subject: [PATCH] fix CRM-12027 --- CRM/Import/DataSource/CSV.php | 4 +++- CRM/Import/Form/DataSource.php | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CRM/Import/DataSource/CSV.php b/CRM/Import/DataSource/CSV.php index cf1c4885a1..a5ed742843 100644 --- a/CRM/Import/DataSource/CSV.php +++ b/CRM/Import/DataSource/CSV.php @@ -33,7 +33,9 @@ * */ class CRM_Import_DataSource_CSV extends CRM_Import_DataSource { - CONST NUM_ROWS_TO_INSERT = 100; + CONST + NUM_ROWS_TO_INSERT = 100; + function getInfo() { return array('title' => ts('Comma-Separated Values (CSV)')); } diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index b385a5b0a5..0f998d6d05 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -45,6 +45,8 @@ class CRM_Import_Form_DataSource extends CRM_Core_Form { private $_dataSourceClassFile; + private $_dataSourceClass; + /** * Function to set variables up before form is built * @@ -125,7 +127,8 @@ class CRM_Import_Form_DataSource extends CRM_Core_Form { if ($this->_dataSourceIsValid) { $this->_dataSourceClassFile = str_replace('_', '/', $this->_dataSource) . ".php"; require_once $this->_dataSourceClassFile; - eval("{$this->_dataSource}::buildQuickForm( \$this );"); + $this->_dataSourceClass = new $this->_dataSource; + $this->_dataSourceClass->buildQuickForm( $this ); } // Get list of data sources and display them as options @@ -256,7 +259,8 @@ class CRM_Import_Form_DataSource extends CRM_Core_Form { ) { $dataSourceClass = "CRM_Import_DataSource_" . $matches[1]; require_once $dataSourceDir . DIRECTORY_SEPARATOR . $dataSourceFile; - eval("\$object = new $dataSourceClass(); \$info = \$object->getInfo();"); + $object = new $dataSourceClass; + $info = $object->getInfo(); $dataSources[$dataSourceClass] = $info['title']; } } @@ -308,8 +312,7 @@ class CRM_Import_Form_DataSource extends CRM_Core_Form { $this->_params['import_table_name'] = 'civicrm_import_job_' . md5(uniqid(rand(), TRUE)); } - require_once $this->_dataSourceClassFile; - eval("$this->_dataSource::postProcess( \$this->_params, \$db, \$this );"); + $this->_dataSourceClass->postProcess( $this->_params, $db, $this ); // We should have the data in the DB now, parse it $importTableName = $this->get('importTableName'); -- 2.25.1