Commit 3d6d99c4 authored by jaapjansma's avatar jaapjansma
Browse files

Added extends column for custom group of type ParticipantRole and Event.

parent ddd52cf0
......@@ -74,6 +74,26 @@ class CRM_Civiconfig_Entity_CustomGroup extends CRM_Civiconfig_Entity {
}
}
}
break;
case "Event":
if (!empty($params['extends_entity_column_value'])) {
if (is_array($params['extends_entity_column_value'])) {
foreach ($params['extends_entity_column_value'] as $extendsValue) {
$activityType = new CRM_Civiconfig_Entity_EventType();
$found = $activityType->getExisting(['name' => $extendsValue]);
if (isset($found['value'])) {
$params['extends_entity_column_value'][] = $found['value'];
}
unset ($activityType);
}
} else {
$activityType = new CRM_Civiconfig_Entity_EventType();
$found = $activityType->getExisting(['name' => $params['extends_entity_column_value']]);
if (isset($found['value'])) {
$params['extends_entity_column_value'] = $found['value'];
}
}
}
break;
case "Membership":
if (!empty($params['extends_entity_column_value'])) {
......@@ -134,6 +154,26 @@ class CRM_Civiconfig_Entity_CustomGroup extends CRM_Civiconfig_Entity {
}
}
}
break;
case "ParticipantRole":
if (!empty($params['extends_entity_column_value'])) {
if (is_array($params['extends_entity_column_value'])) {
foreach ($params['extends_entity_column_value'] as $extendsValue) {
$eventType = new CRM_Civiconfig_Entity_ParticipantRole();
$found = $eventType->getExisting(['name' => $extendsValue]);
if (isset($found['value'])) {
$params['extends_entity_column_value'][] = $found['value'];
}
unset ($eventType);
}
} else {
$eventType = new CRM_Civiconfig_Entity_ParticipantRole();
$found = $eventType->getExisting(['name' => $params['extends_entity_column_value']]);
if (isset($found['value'])) {
$params['extends_entity_column_value'] = $found['value'];
}
}
}
break;
}
}
......
<?php
/**
* Class for ParticipantRole configuration
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @date 3 Feb 2016
* @license AGPL-3.0
*/
class CRM_Civiconfig_Entity_ParticipantRole extends CRM_Civiconfig_Entity_OptionValue {
/**
* Manipulate $params before entity creation.
*
* @param array $params params that will be used for entity creation
* @param array $existing existing entity (if available)
*/
protected function prepareParams(array &$params, array $existing = []) {
$params['option_group_id'] = $this->getOptionGroupId();
parent::prepareParams($params, $existing);
}
/**
* Function to find an existing entity based on the entity's parameters.
*
* This default implementation searches on the name, but you can override it.
*
* @param array $params
* @return array|bool
* @access public
* @static
*/
public function getExisting(array $params) {
$params['option_group_id'] = $this->getOptionGroupId();
return parent::getExisting($params); // TODO: Change the autogenerated stub
}
/**
* Method to get option group id for event type
*
* @return array
* @throws CiviCRM_API3_Exception
*/
public function getOptionGroupId() {
return civicrm_api3('OptionGroup', 'Getvalue', array('name' => 'participant_role', 'return' => 'id'));
}
}
\ No newline at end of file
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