[#18] implementing xcm profiles
This commit is contained in:
parent
8ae3f658c0
commit
8642ab5cfd
6 changed files with 77 additions and 6 deletions
|
@ -98,6 +98,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
*/
|
*/
|
||||||
protected static $_locationTypes = NULL;
|
protected static $_locationTypes = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*
|
||||||
|
* A static cache of retrieved location types found within
|
||||||
|
* static::getXCMProfiles().
|
||||||
|
*/
|
||||||
|
protected static $_xcm_profiles = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*
|
*
|
||||||
|
@ -198,6 +206,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
TRUE // is required
|
TRUE // is required
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->add(
|
||||||
|
'select',
|
||||||
|
'xcm_profile',
|
||||||
|
E::ts('Contact Matcher (XCM) Profile'),
|
||||||
|
static::getXCMProfiles(),
|
||||||
|
TRUE
|
||||||
|
);
|
||||||
|
|
||||||
$this->add(
|
$this->add(
|
||||||
'select',
|
'select',
|
||||||
'location_type_id',
|
'location_type_id',
|
||||||
|
@ -510,6 +526,26 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
return static::$_locationTypes;
|
return static::$_locationTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves XCM profiles (if supported). 'default' profile is always available
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getXCMProfiles() {
|
||||||
|
if (!isset(static::$_xcm_profiles)) {
|
||||||
|
static::$_xcm_profiles = array(
|
||||||
|
'' => E::ts("<default profile>"),
|
||||||
|
);
|
||||||
|
if (method_exists('CRM_Xcm_Configuration', 'getProfileList')) {
|
||||||
|
$profiles = CRM_Xcm_Configuration::getProfileList();
|
||||||
|
foreach ($profiles as $profile_key => $profile_name) {
|
||||||
|
static::$_xcm_profiles[$profile_key] = $profile_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return static::$_xcm_profiles;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves financial types present within the system as options for select
|
* Retrieves financial types present within the system as options for select
|
||||||
* form elements.
|
* form elements.
|
||||||
|
|
|
@ -199,6 +199,7 @@ class CRM_Twingle_Profile {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
array(
|
array(
|
||||||
'selector',
|
'selector',
|
||||||
|
'xcm_profile',
|
||||||
'location_type_id',
|
'location_type_id',
|
||||||
'location_type_id_organisation',
|
'location_type_id_organisation',
|
||||||
'financial_type_id',
|
'financial_type_id',
|
||||||
|
@ -258,6 +259,7 @@ class CRM_Twingle_Profile {
|
||||||
public static function createDefaultProfile($name = 'default') {
|
public static function createDefaultProfile($name = 'default') {
|
||||||
return new CRM_Twingle_Profile($name, array(
|
return new CRM_Twingle_Profile($name, array(
|
||||||
'selector' => '',
|
'selector' => '',
|
||||||
|
'xcm_profile' => '',
|
||||||
'location_type_id' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
'location_type_id' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
||||||
'location_type_id_organisation' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
'location_type_id_organisation' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
||||||
'financial_type_id' => 1, // "Donation"
|
'financial_type_id' => 1, // "Donation"
|
||||||
|
|
|
@ -139,6 +139,12 @@ class CRM_Twingle_Submission {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add xcm profile
|
||||||
|
$xcm_profile = $profile->getAttribute('xcm_profile');
|
||||||
|
if (!empty($xcm_profile)) {
|
||||||
|
$contact_data['xcm_profile'] = $xcm_profile;
|
||||||
|
}
|
||||||
|
|
||||||
// add campaign
|
// add campaign
|
||||||
$campaign_id = (int) $profile->getAttribute('campaign');
|
$campaign_id = (int) $profile->getAttribute('campaign');
|
||||||
if ($campaign_id) {
|
if ($campaign_id) {
|
||||||
|
|
|
@ -450,14 +450,15 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Address is not shared, use submitted address with configured location
|
// Address is not shared, use submitted address with
|
||||||
// type.
|
// configured location type.
|
||||||
if (!$address_shared && !empty($submitted_address)) {
|
if (!$address_shared && !empty($submitted_address)) {
|
||||||
// Do not use `Address.create` API action in order for XCM to decide
|
// Do not use `Address.create` API action, let XCM decide
|
||||||
// whether to create an address.
|
// whether to create an address.
|
||||||
civicrm_api3('Contact', 'getorcreate', array(
|
CRM_Twingle_Submission::getContact(
|
||||||
'id' => $contact_id,
|
'Individual',
|
||||||
) + $submitted_address);
|
array('id' => $contact_id) + $submitted_address,
|
||||||
|
$profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create employer relationship between organization and individual.
|
// Create employer relationship between organization and individual.
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
{ts domain="de.systopia.twingle"}You can also provide multiple project IDs separated by a comma.{/ts}
|
{ts domain="de.systopia.twingle"}You can also provide multiple project IDs separated by a comma.{/ts}
|
||||||
{/htxt}
|
{/htxt}
|
||||||
|
|
||||||
|
{htxt id='id-xcm_profile'}
|
||||||
|
{ts domain="de.systopia.twingle"}The Contact Matcher (XCM) manages the identification or creation of the related contact.{/ts}
|
||||||
|
{ts domain="de.systopia.twingle"}We recommend creating a new XCM profile only to be used with the Twingle API.{/ts}
|
||||||
|
{/htxt}
|
||||||
|
|
||||||
{htxt id='id-location_type_id_organisation'}
|
{htxt id='id-location_type_id_organisation'}
|
||||||
{ts domain="de.systopia.twingle"}Select which location type to use for addresses for organisations and shared organisation addresses for individual contacts.{/ts}
|
{ts domain="de.systopia.twingle"}Select which location type to use for addresses for organisations and shared organisation addresses for individual contacts.{/ts}
|
||||||
{/htxt}
|
{/htxt}
|
||||||
|
|
|
@ -48,6 +48,27 @@
|
||||||
<td class="content">{$form.selector.html}</td>
|
<td class="content">{$form.selector.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr class="crm-section">
|
||||||
|
<td class="label">{$form.xcm_profile.label}
|
||||||
|
<a
|
||||||
|
onclick='
|
||||||
|
CRM.help(
|
||||||
|
"{ts domain="de.systopia.twingle"}XCM Profile{/ts}",
|
||||||
|
{literal}{
|
||||||
|
"id": "id-xcm_profile",
|
||||||
|
"file": "CRM\/Twingle\/Form\/Profile"
|
||||||
|
}{/literal}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
'
|
||||||
|
href="#"
|
||||||
|
title="{ts domain="de.systopia.twingle"}Help{/ts}"
|
||||||
|
class="helpicon"
|
||||||
|
></a>
|
||||||
|
</td>
|
||||||
|
<td class="content">{$form.xcm_profile.html}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">
|
<td class="label">
|
||||||
{$form.location_type_id.label}
|
{$form.location_type_id.label}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue