本文整理汇总了PHP中CRM_Core_BAO_Mapping类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Mapping类的具体用法?PHP CRM_Core_BAO_Mapping怎么用?PHP CRM_Core_BAO_Mapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_Mapping类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Common form elements.
*/
public function buildQuickForm()
{
$config = CRM_Core_Config::singleton();
$uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE);
$uploadSize = round($uploadFileSize / (1024 * 1024), 2);
$this->assign('uploadSize', $uploadSize);
$this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
$this->setMaxFileSize($uploadFileSize);
$this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
$this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
$this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
$this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE);
$this->setDefaults(array('fieldSeparator' => $config->fieldSeparator));
//get the saved mapping details
$mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, 'name'));
$this->assign('savedMapping', $mappingArray);
$this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
if ($loadedMapping = $this->get('loadedMapping')) {
$this->assign('loadedMapping', $loadedMapping);
$this->setDefaults(array('savedMapping' => $loadedMapping));
}
//build date formats
CRM_Core_Form_Date::buildAllowedDateFormats($this);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:29,代码来源:DataSource.php
示例2: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
//Setting Upload File Size
$config = CRM_Core_Config::singleton();
$uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE);
$uploadSize = round($uploadFileSize / (1024 * 1024), 2);
$this->assign('uploadSize', $uploadSize);
$this->setMaxFileSize($uploadFileSize);
$this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
$this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
$this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
$this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
$duplicateOptions = array();
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP);
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE);
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL);
$this->addGroup($duplicateOptions, 'onDuplicate', ts('On duplicate entries'));
//get the saved mapping details
$mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name'));
$this->assign('savedMapping', $mappingArray);
$this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
if ($loadeMapping = $this->get('loadedMapping')) {
$this->assign('loadedMapping', $loadeMapping);
$this->setDefaults(array('savedMapping' => $loadeMapping));
}
$this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP));
//build date formats
CRM_Core_Form_Date::buildAllowedDateFormats($this);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
开发者ID:kidaa30,项目名称:yes,代码行数:36,代码来源:DataSource.php
示例3: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
//Setting Upload File Size
$config = CRM_Core_Config::singleton();
if ($config->maxImportFileSize >= 8388608) {
$uploadFileSize = 8388608;
} else {
$uploadFileSize = $config->maxImportFileSize;
}
$uploadSize = round($uploadFileSize / (1024 * 1024), 2);
$this->assign('uploadSize', $uploadSize);
$this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=60', true);
$this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
$this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
$this->setMaxFileSize($uploadFileSize);
$this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
$duplicateOptions = array();
$duplicateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Insert new contributions'), CRM_Contribute_Import_Parser::DUPLICATE_SKIP);
$duplicateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Update existing contributions'), CRM_Contribute_Import_Parser::DUPLICATE_UPDATE);
$this->addGroup($duplicateOptions, 'onDuplicate', ts('Import mode'));
//get the saved mapping details
require_once "CRM/Core/BAO/Mapping.php";
require_once "CRM/Core/OptionGroup.php";
$mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name'));
$this->assign('savedMapping', $mappingArray);
$this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
$this->addElement('submit', 'loadMapping', ts('Load Mapping'), null, array('onclick' => 'checkSelect()'));
if ($loadeMapping = $this->get('loadedMapping')) {
$this->assign('loadedMapping', $loadeMapping);
$this->setDefaults(array('savedMapping' => $loadeMapping));
}
$this->setDefaults(array('onDuplicate' => CRM_Contribute_Import_Parser::DUPLICATE_SKIP));
//contact types option
require_once 'CRM/Contact/BAO/ContactType.php';
$contactOptions = array();
if (CRM_Contact_BAO_ContactType::isActive('Individual')) {
$contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Individual'), CRM_Contribute_Import_Parser::CONTACT_INDIVIDUAL);
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Household'), CRM_Contribute_Import_Parser::CONTACT_HOUSEHOLD);
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Organization'), CRM_Contribute_Import_Parser::CONTACT_ORGANIZATION);
}
$this->addGroup($contactOptions, 'contactType', ts('Contact Type'));
$this->setDefaults(array('contactType' => CRM_Contribute_Import_Parser::CONTACT_INDIVIDUAL));
//build date formats
require_once 'CRM/Core/Form/Date.php';
CRM_Core_Form_Date::buildAllowedDateFormats($this);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:58,代码来源:UploadFile.php
示例4: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
//Setting Upload File Size
$config = CRM_Core_Config::singleton();
if ($config->maxImportFileSize >= 8388608) {
$uploadFileSize = 8388608;
} else {
$uploadFileSize = $config->maxImportFileSize;
}
$uploadSize = round($uploadFileSize / (1024 * 1024), 2);
$this->assign('uploadSize', $uploadSize);
$this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
$this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
$this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
$this->setMaxFileSize($uploadFileSize);
$this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
$duplicateOptions = array();
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP);
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE);
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK);
// for contributions NOCHECK == SKIP
// $duplicateOptions[] = $this->createElement('radio',
// null, null, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK);
$this->addGroup($duplicateOptions, 'onDuplicate', ts('On Duplicate Entries'));
//get the saved mapping details
$mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name'));
$this->assign('savedMapping', $mappingArray);
$this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
if ($loadeMapping = $this->get('loadedMapping')) {
$this->assign('loadedMapping', $loadeMapping);
$this->setDefaults(array('savedMapping' => $loadeMapping));
}
$this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP));
//contact types option
$contactOptions = array();
if (CRM_Contact_BAO_ContactType::isActive('Individual')) {
$contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL);
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD);
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION);
}
$this->addGroup($contactOptions, 'contactType', ts('Contact Type'));
$this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL));
//build date formats
CRM_Core_Form_Date::buildAllowedDateFormats($this);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:57,代码来源:DataSource.php
示例5: postProcess
/**
* Process the uploaded file.
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$exportParams = $this->controller->exportValues('Select');
$currentPath = CRM_Utils_System::currentPath();
$urlParams = NULL;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams = "&qfKey={$qfKey}";
}
//get the button name
$buttonName = $this->controller->getButtonName('done');
$buttonName1 = $this->controller->getButtonName('next');
if ($buttonName == '_qf_Map_done') {
$this->set('exportColumnCount', NULL);
$this->controller->resetPage($this->_name);
return CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, 'force=1' . $urlParams));
}
if ($this->controller->exportValue($this->_name, 'addMore')) {
$this->set('exportColumnCount', $this->_exportColumnCount);
return;
}
$mapperKeys = $params['mapper'][1];
$checkEmpty = 0;
foreach ($mapperKeys as $value) {
if ($value[0]) {
$checkEmpty++;
}
}
if (!$checkEmpty) {
$this->set('mappingId', NULL);
CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, '_qf_Map_display=true' . $urlParams));
}
if ($buttonName1 == '_qf_Map_next') {
if (!empty($params['updateMapping'])) {
//save mapping fields
CRM_Core_BAO_Mapping::saveMappingFields($params, $params['mappingId']);
}
if (!empty($params['saveMapping'])) {
$mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => $this->get('mappingTypeId'));
$saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
//save mapping fields
CRM_Core_BAO_Mapping::saveMappingFields($params, $saveMapping->id);
}
}
//get the csv file
CRM_Export_BAO_Export_Relationship::exportComponents($this->get('selectAll'), $this->get('componentIds'), $this->get('queryParams'), $this->get(CRM_Utils_Sort::SORT_ORDER), $mapperKeys, $this->get('returnProperties'), $this->get('exportMode'), $this->get('componentClause'), $this->get('componentTable'), $this->get('mergeSameAddress'), $this->get('mergeSameHousehold'), $exportParams);
}
开发者ID:Chirojeugd-Vlaanderen,项目名称:civicrm-relationship-entity,代码行数:53,代码来源:Map.php
示例6: buildMapping
/**
* Function to build mapping form element
*
*/
function buildMapping()
{
switch ($this->_exportMode) {
case CRM_Export_Form_Select::CONTACT_EXPORT:
$exportType = 'Export Contact';
break;
case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
$exportType = 'Export Contribution';
break;
case CRM_Export_Form_Select::MEMBER_EXPORT:
$exportType = 'Export Membership';
break;
case CRM_Export_Form_Select::EVENT_EXPORT:
$exportType = 'Export Participant';
break;
case CRM_Export_Form_Select::PLEDGE_EXPORT:
$exportType = 'Export Pledge';
break;
case CRM_Export_Form_Select::CASE_EXPORT:
$exportType = 'Export Case';
break;
case CRM_Export_Form_Select::GRANT_EXPORT:
$exportType = 'Export Grant';
break;
case CRM_Export_Form_Select::ACTIVITY_EXPORT:
$exportType = 'Export Activity';
break;
}
$mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $exportType, 'name');
$this->set('mappingTypeId', $mappingTypeId);
$mappings = CRM_Core_BAO_Mapping::getMappings($mappingTypeId);
// Remove the mappings to which a user has no permission to use.
foreach ($mappings as $mapping_id => $mapping) {
if (!CRM_Mappingacl_Acl::hasAccessToMapping($mapping_id)) {
unset($mappings[$mapping_id]);
}
}
if (!empty($mappings)) {
$this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings);
}
}
开发者ID:SPnl,项目名称:nl.sp.mappingacl,代码行数:45,代码来源:Select.php
示例7:
public function &returnProperties()
{
return CRM_Core_BAO_Mapping::returnProperties($this->_formValues);
}
开发者ID:hguru,项目名称:224Civi,代码行数:4,代码来源:Builder.php
示例8: buildClause
/**
* given a saved search compute the clause and the tables
* and store it for future use
*/
function buildClause()
{
$fv = unserialize($this->form_values);
if ($this->mapping_id) {
require_once 'CRM/Core/BAO/Mapping.php';
$params = CRM_Core_BAO_Mapping::formattedFields($fv);
} else {
require_once 'CRM/Contact/BAO/Query.php';
$params = CRM_Contact_BAO_Query::convertFormValues($fv);
}
if (!empty($params)) {
$tables = $whereTables = array();
$this->where_clause = CRM_Contact_BAO_Query::getWhereClause($params, null, $tables, $whereTables);
if (!empty($tables)) {
$this->select_tables = serialize($tables);
}
if (!empty($whereTables)) {
$this->where_tables = serialize($whereTables);
}
}
return;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:26,代码来源:SavedSearch.php
示例9: preProcessCommon
static function preProcessCommon(&$form, $useTable = false)
{
$form->_contactIds = array();
$form->_contactTypes = array();
// get the submitted values of the search form
// we'll need to get fv from either search or adv search in the future
$fragment = 'search';
if ($form->_action == CRM_Core_Action::ADVANCED) {
$values = $form->controller->exportValues('Advanced');
$fragment .= '/advanced';
} else {
if ($form->_action == CRM_Core_Action::PROFILE) {
$values = $form->controller->exportValues('Builder');
$fragment .= '/builder';
} else {
if ($form->_action == CRM_Core_Action::COPY) {
$values = $form->controller->exportValues('Custom');
$fragment .= '/custom';
} else {
$values = $form->controller->exportValues('Basic');
}
}
}
//set the user context for redirection of task actions
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
require_once 'CRM/Utils/Rule.php';
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= "&qfKey={$qfKey}";
}
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
$session = CRM_Core_Session::singleton();
$session->replaceUserContext($url);
require_once 'CRM/Contact/Task.php';
$form->_task = CRM_Utils_Array::value('task', $values);
$crmContactTaskTasks = CRM_Contact_Task::taskTitles();
$form->assign('taskName', CRM_Utils_Array::value($form->_task, $crmContactTaskTasks));
if ($useTable) {
$form->_componentTable = CRM_Core_DAO::createTempTableName('civicrm_task_action', false);
$sql = " DROP TABLE IF EXISTS {$form->_componentTable}";
CRM_Core_DAO::executeQuery($sql);
$sql = "CREATE TABLE {$form->_componentTable} ( contact_id int primary key) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
CRM_Core_DAO::executeQuery($sql);
}
// all contacts or action = save a search
if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_all' || $form->_task == CRM_Contact_Task::SAVE_SEARCH) {
// need to perform action on all contacts
// fire the query again and get the contact id's + display name
$sortID = null;
if ($form->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($form->get(CRM_Utils_Sort::SORT_ID), $form->get(CRM_Utils_Sort::SORT_DIRECTION));
}
$selectorName = $form->controller->selectorName();
require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php';
$fv = $form->get('formValues');
$customClass = $form->get('customSearchClass');
require_once "CRM/Core/BAO/Mapping.php";
$returnProperties = CRM_Core_BAO_Mapping::returnProperties($values);
eval('$selector = new ' . $selectorName . '( $customClass, $fv, null, $returnProperties ); ');
$params = $form->get('queryParams');
// fix for CRM-5165
$sortByCharacter = $form->get('sortByCharacter');
if ($sortByCharacter && $sortByCharacter != 1) {
$params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0);
}
$dao =& $selector->contactIDQuery($params, $form->_action, $sortID);
$form->_contactIds = array();
if ($useTable) {
$count = 0;
$insertString = array();
while ($dao->fetch()) {
$count++;
$insertString[] = " ( {$dao->contact_id} ) ";
if ($count % 200 == 0) {
$string = implode(',', $insertString);
$sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}";
CRM_Core_DAO::executeQuery($sql);
$insertString = array();
}
}
if (!empty($insertString)) {
$string = implode(',', $insertString);
$sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES {$string}";
CRM_Core_DAO::executeQuery($sql);
}
$dao->free();
} else {
// filter duplicates here
// CRM-7058
// might be better to do this in the query, but that logic is a bit complex
// and it decides when to use distinct based on input criteria, which needs
// to be fixed and optimized.
$alreadySeen = array();
while ($dao->fetch()) {
if (!array_key_exists($dao->contact_id, $alreadySeen)) {
$form->_contactIds[] = $dao->contact_id;
$alreadySeen[$dao->contact_id] = 1;
}
}
unset($alreadySeen);
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Task.php
示例10: buildQuickForm
/**
* Function to actually build the form - this appears to be entirely code that should be in a shared base class in core
*
* @return None
* @access public
*/
public function buildQuickForm()
{
// Setting Upload File Size.
$config = CRM_Core_Config::singleton();
// This conditional block is important as the "maxImportFileSize" has been changed to "maxFileSize"
// in the newer versions. In order to remove version support, remove this block and
// replace by $uploadFileSize = $config->maxFileSize.
if (!empty($config->maxImportFileSize)) {
$uploadFileSize = $config->maxImportFileSize;
} else {
$uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE);
}
if ($uploadFileSize >= 8388608) {
$uploadFileSize = 8388608;
}
$uploadSize = round($uploadFileSize / (1024 * 1024), 2);
$this->assign('uploadSize', $uploadSize);
$this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
$this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
$this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
$this->setMaxFileSize($uploadFileSize);
$this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
if ($this->isDuplicateOptions) {
$duplicateOptions = array();
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP);
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE);
$duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK);
$this->addGroup($duplicateOptions, 'onDuplicate', ts('On Duplicate Entries'));
}
//get the saved mapping details
$mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', $this->_mappingType, 'name'));
$this->assign('savedMapping', $mappingArray);
$this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
if ($loadedMapping = $this->get('loadedMapping')) {
$this->assign('loadedMapping', $loadedMapping);
$this->setDefaults(array('savedMapping' => $loadedMapping));
}
$this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP));
if ($this->_enableContactOptions) {
$this->addContactOptions();
}
$this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL));
$this->addElement('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2));
//build date formats
CRM_Core_Form_Date::buildAllowedDateFormats($this);
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
开发者ID:wayneYaw,项目名称:nz.co.fuzion.csvimport,代码行数:54,代码来源:DataSourceBaseClass.php
示例11: postProcess
/**
* Process the mapped fields and map it into the uploaded file
* preview the file and extract some summary statistics
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues('MapField');
//reload the mapfield if load mapping is pressed
if (!empty($params['savedMapping'])) {
$this->set('savedMapping', $params['savedMapping']);
$this->controller->resetPage($this->_name);
return;
}
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
$seperator = $this->controller->exportValue('DataSource', 'fieldSeparator');
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
$mapperKeys = array();
$mapper = array();
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
$mapperKeysMain = array();
$mapperLocType = array();
$mapperPhoneType = array();
for ($i = 0; $i < $this->_columnCount; $i++) {
$mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
$mapperKeysMain[$i] = $mapperKeys[$i][0];
if (!empty($mapperKeys[$i][1]) && is_numeric($mapperKeys[$i][1])) {
$mapperLocType[$i] = $mapperKeys[$i][1];
} else {
$mapperLocType[$i] = NULL;
}
if (!empty($mapperKeys[$i][2]) && !is_numeric($mapperKeys[$i][2])) {
$mapperPhoneType[$i] = $mapperKeys[$i][2];
} else {
$mapperPhoneType[$i] = NULL;
}
}
$this->set('mapper', $mapper);
// store mapping Id to display it in the preview page
if (!empty($params['mappingId'])) {
$this->set('loadMappingId', $params['mappingId']);
}
//Updating Mapping Records
if (!empty($params['updateMapping'])) {
$mappingFields = new CRM_Core_DAO_MappingField();
$mappingFields->mapping_id = $params['mappingId'];
$mappingFields->find();
$mappingFieldsId = array();
while ($mappingFields->fetch()) {
if ($mappingFields->id) {
$mappingFieldsId[$mappingFields->column_number] = $mappingFields->id;
}
}
for ($i = 0; $i < $this->_columnCount; $i++) {
$updateMappingFields = new CRM_Core_DAO_MappingField();
$updateMappingFields->id = $mappingFieldsId[$i];
$updateMappingFields->mapping_id = $params['mappingId'];
$updateMappingFields->column_number = $i;
$mapperKeyParts = explode('_', $mapperKeys[$i][0], 3);
$id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL;
$first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL;
$second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL;
$updateMappingFields->name = $mapper[$i];
$updateMappingFields->save();
}
}
//Saving Mapping Details and Records
if (!empty($params['saveMapping'])) {
$mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Membership', 'name'));
$saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
for ($i = 0; $i < $this->_columnCount; $i++) {
$saveMappingFields = new CRM_Core_DAO_MappingField();
$saveMappingFields->mapping_id = $saveMapping->id;
$saveMappingFields->column_number = $i;
$mapperKeyParts = explode('_', $mapperKeys[$i][0], 3);
$id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL;
$first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL;
$second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL;
$saveMappingFields->name = $mapper[$i];
$saveMappingFields->save();
}
$this->set('savedMapping', $saveMappingFields->mapping_id);
}
$parser = new CRM_Member_Import_Parser_Membership($mapperKeysMain, $mapperLocType, $mapperPhoneType);
$parser->run($fileName, $seperator, $mapper, $skipColumnHeader, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType'));
// add all the necessary variables to the form
$parser->set($this);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:89,代码来源:MapField.php
示例12: buildMapping
/**
* Function to build mapping form element
*
*/
function buildMapping()
{
switch ($this->_exportMode) {
case CRM_Export_Form_Select::CONTACT_EXPORT:
$exportType = 'Export Contact';
break;
case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
$exportType = 'Export Contribution';
break;
case CRM_Export_Form_Select::MEMBER_EXPORT:
$exportType = 'Export Membership';
break;
case CRM_Export_Form_Select::EVENT_EXPORT:
$exportType = 'Export Participant';
break;
case CRM_Export_Form_Select::PLEDGE_EXPORT:
$exportType = 'Export Pledge';
break;
case CRM_Export_Form_Select::CASE_EXPORT:
$exportType = 'Export Case';
break;
case CRM_Export_Form_Select::GRANT_EXPORT:
$exportType = 'Export Grant';
break;
case CRM_Export_Form_Select::ACTIVITY_EXPORT:
$exportType = 'Export Activity';
break;
}
require_once "CRM/Core/BAO/Mapping.php";
$mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $exportType, 'name');
$this->set('mappingTypeId', $mappingTypeId);
$mappings = CRM_Core_BAO_Mapping::getMappings($mappingTypeId);
if (!empty($mappings)) {
$this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings);
}
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:40,代码来源:Select.php
示例13: postProcess
//.........这里部分代码省略.........
if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'url') {
$updateMappingFields->website_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
} else {
if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') {
$updateMappingFields->phone_type_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL;
} elseif (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') {
$updateMappingFields->im_provider_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL;
}
$updateMappingFields->location_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
}
} else {
$updateMappingFields->name = $mapper[$i];
$updateMappingFields->relationship_type_id = 'NULL';
$updateMappingFields->relationship_type_direction = 'NULL';
// to store phoneType id and provider id separately
// before updating mappingFields for phone and IM, CRM-3140
if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'url') {
$updateMappingFields->website_type_id = isset($mapperKeys[$i][1]) ? $mapperKeys[$i][1] : NULL;
} else {
if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'phone') {
$updateMappingFields->phone_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
} elseif (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'im') {
$updateMappingFields->im_provider_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
}
$location = array_keys($locationTypes, $locations[$i]);
$updateMappingFields->location_type_id = isset($location) && isset($location[0]) ? $location[0] : NULL;
}
}
$updateMappingFields->save();
}
}
//Saving Mapping Details and Records
if (!empty($params['saveMapping'])) {
$mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contact', 'name'));
$saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$contactType = $this->get('contactType');
switch ($contactType) {
case CRM_Import_Parser::CONTACT_INDIVIDUAL:
$cType = 'Individual';
break;
case CRM_Import_Parser::CONTACT_HOUSEHOLD:
$cType = 'Household';
break;
case CRM_Import_Parser::CONTACT_ORGANIZATION:
$cType = 'Organization';
}
for ($i = 0; $i < $this->_columnCount; $i++) {
$saveMappingFields = new CRM_Core_DAO_MappingField();
$saveMappingFields->mapping_id = $saveMapping->id;
$saveMappingFields->contact_type = $cType;
$saveMappingFields->column_number = $i;
$mapperKeyParts = explode('_', $mapperKeys[$i][0], 3);
$id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL;
$first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL;
$second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL;
if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
$saveMappingFields->name = ucwords(str_replace("_", " ", $mapperKeys[$i][1]));
$saveMappingFields->relationship_type_id = $id;
$saveMappingFields->relationship_direction = "{$first}_{$second}";
// to get phoneType id and provider id separately
// before saving mappingFields of phone and IM for related contact, CRM-3140
if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'url') {
$saveMappingFields->website_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
} else {
if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') {
$saveMappingFields->phone_type_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL;
} elseif (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') {
$saveMappingFields->im_provider_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL;
}
$saveMappingFields->location_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
}
} else {
$saveMappingFields->name = $mapper[$i];
$location_id = array_keys($locationTypes, $locations[$i]);
// to get phoneType id and provider id separately
// before saving mappingFields of phone and IM, CRM-3140
if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'url') {
$saveMappingFields->website_type_id = isset($mapperKeys[$i][1]) ? $mapperKeys[$i][1] : NULL;
} else {
if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'phone') {
$saveMappingFields->phone_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
} elseif (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'im') {
$saveMappingFields->im_provider_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL;
}
$saveMappingFields->location_type_id = isset($location_id[0]) ? $location_id[0] : NULL;
}
$saveMappingFields->relationship_type_id = NULL;
}
$saveMappingFields->save();
}
$this->set('savedMapping', $saveMappingFields->mapping_id);
}
$parser = new CRM_Contact_Import_Parser_Contact($mapperKeysMain, $mapperLocType, $mapperPhoneType, $mapperImProvider, $related, $relatedContactType, $relatedContactDetails, $relatedContactLocType, $relatedContactPhoneType, $relatedContactImProvider, $mapperWebsiteType, $relatedContactWebsiteType);
$primaryKeyName = $this->get('primaryKeyName');
$statusFieldName = $this->get('statusFieldName');
$parser->run($this->_importTableName, $mapper, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType'), $primaryKeyName, $statusFieldName, $this->_onDuplicate, NULL, NULL, FALSE, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->get('contactSubType'), $this->get('dedupe'));
// add all the necessary variables to the form
$parser->set($this);
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:MapField.php
示例14: load
/**
* load the smart group cache for a saved search
*/
static function load(&$group)
{
$groupID = $group->id;
$savedSearchID = $group->saved_search_id;
$sql = null;
$idName = 'id';
$customClass = null;
if ($savedSearchID) {
require_once 'CRM/Contact/BAO/SavedSearch.php';
$ssParams =& CRM_Contact_BAO_SavedSearch::getSearchParams($savedSearchID);
$returnProperties = array();
if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $savedSearchID, 'mapping_id')) {
require_once "CRM/Core/BAO/Mapping.php";
$fv =& CRM_Contact_BAO_SavedSearch::getFormValues($savedSearchID);
$returnProperties = CRM_Core_BAO_Mapping::returnProperties($fv);
}
if (isset($ssParams['customSearchID'])) {
// if custom search
require_once 'CRM/Contact/BAO/SearchCustom.php';
// we split it up and store custom class
// so temp tables are not destroyed if they are used
// hence customClass is defined above at top of function
$customClass = CRM_Contact_BAO_SearchCustom::customClass($ssParams['customSearchID'], $savedSearchID);
$searchSQL = $customClass->contactIDs();
$idName = 'contact_id';
} else {
require_once 'CRM/Contact/BAO/Query.php';
$query = new CRM_Contact_BAO_Query($ssParams, $returnProperties, null, false, false, 1, true, true, false);
$query->_useGroupBy = false;
$searchSQL =& $query->searchQuery(0, 0, null, false, false, false, true, true, null);
}
$groupID = CRM_Utils_Type::escape($groupID, 'Integer');
$sql = $searchSQL . " AND contact_a.id NOT IN ( \n SELECT contact_id FROM civicrm_group_contact \n WHERE civicrm_group_contact.status = 'Removed' \n AND civicrm_group_contact.group_id = {$groupID} ) ";
}
if ($sql) {
$sql .= " UNION ";
}
// lets also store the records that are explicitly added to the group
// this allows us to skip the group contact LEFT JOIN
$sql .= "\nSELECT contact_id as {$idName}\nFROM civicrm_group_contact\nWHERE civicrm_group_contact.status = 'Added'\n AND civicrm_group_contact.group_id = {$groupID} ";
$dao = CRM_Core_DAO::executeQuery($sql);
$values = array();
while ($dao->fetch()) {
$values[] = "({$groupID},{$dao->{$idName}})";
}
$groupIDs = array($groupID);
self::remove($groupIDs);
self::store($groupIDs, $values);
if ($group->children) {
require_once 'CRM/Contact/BAO/Group.php';
$childrenIDs = explode(',', $group->children);
foreach ($childrenIDs as $childID) {
$contactIDs =& CRM_Contact_BAO_Group::getMember($childID, false);
$values = array();
foreach ($contactIDs as $contactID => $dontCare) {
$values[] = "({$groupID},{$contactID})";
}
self::store($groupIDs, $values);
}
}
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:64,代码来源:GroupContactCache.php
示例15: buildMappingForm
/**
* Build the mapping form.
*
* @param CRM_Core_Form $form
* @param string $mappingType
* (Export/Import/Search Builder).
* @param int $mappingId
* @param int $columnNo
* @param int $blockCount
* (no of blocks shown).
* @param NULL $exportMode
*
* @return void
*/
public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL)
{
if ($mappingType == 'Export') {
$name = "Map";
$columnCount = array('1' => $columnNo);
} elseif ($mappingType == 'Search Builder') {
$name = "Builder";
$columnCount = $columnNo;
}
//get the saved mapping details
if ($mappingType == 'Export') {
$form->applyFilter('saveMappingName', 'trim');
//to save the current mappings
if (!isset($mappingId)) {
$saveDetailsName = ts('Save this field mapping');
$form->add('text', 'saveM
|
请发表评论