Commit a73561be authored by jaapjansma's avatar jaapjansma
Browse files

added support identity tracker mapping settings

parent b89e566f
......@@ -34,7 +34,7 @@ class CRM_Civiconfig_Config {
*/
public function getSupportedEntityTypes() {
// TODO: make this list configurable.
return array(
$supportedEntities = array(
'CivicrmSetting',
'ContactType',
'MembershipType',
......@@ -52,5 +52,11 @@ class CRM_Civiconfig_Config {
// CustomGroup as last one because it might need one of the previous ones (option group, relationship types)
// DO NOT INCLUDE CustomField, because custom fields are updated together with custom groups.
);
if (CRM_Civiconfig_Utils::isExtensionInstalled('de.systopia.identitytracker')) {
$supportedEntities[] = 'IdentityTrackerMapping';
}
return $supportedEntities;
}
}
\ No newline at end of file
}
<?php
/**
* Class for identity tracker mapping configuration
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @date 3 Feb 2016
* @license AGPL-3.0
*/
class CRM_Civiconfig_Entity_IdentityTrackerMapping extends CRM_Civiconfig_Entity {
/**
* CRM_Civiconfig_Group constructor.
*/
public function __construct() {
parent::__construct('IdentityTrackerMapping');
}
/**
* Method to update the identity tracker settings.
* Only available when identity tracker extension is installed.
*
* @param array $params Parameters
* @return int id of created/updated entity
* @throws Exception when error from API Entity Create
*/
public function create(array $params) {
$configuration = CRM_Identitytracker_Configuration::instance();
$mapping = $configuration->getCustomFieldMapping();
$mappingToMigrate = array();
$field_id = civicrm_api3('CustomField', 'getvalue', array(
'return' => 'id',
'name' => $params['custom_field'],
'custom_group_id' => $params['custom_group'],
));
$mapping[$field_id] = $params['id_type'];
$mappingToMigrate[$field_id] = $params['id_type'];
$configuration->setCustomFieldMapping($mapping);
foreach ($mappingToMigrate as $custom_field_id => $identity_type) {
CRM_Identitytracker_Migration::migrateCustom($identity_type, $custom_field_id);
}
return;
}
}
......@@ -67,4 +67,14 @@ class CRM_Civiconfig_Utils {
public static function getDefaultResourcesPath() {
return realpath(__DIR__ . '/../../') . '/resources/';
}
}
\ No newline at end of file
public static function isExtensionInstalled($extension) {
if (civicrm_api3('Extension', 'get', ['key' => $extension, 'status' => 'installed'])['count']) {
return true;
} elseif (civicrm_api3('Extension', 'get', ['key' => $extension, 'status' => 'installed'])['count']) {
return true;
}
return false;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment