Skip to content
Snippets Groups Projects
Commit a347cd93 authored by jaapjansma's avatar jaapjansma
Browse files

Fixed issues with Update Participant By ID action.

parent c49f5cb7
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ Version 1.66 (not yet released)
------------
* Fixed issue with get participant actions.
* Fixed issues with Update Participant By ID action.
Version 1.65
------------
......
......@@ -3,12 +3,14 @@
namespace Civi\ActionProvider\Action\Event;
use \Civi\ActionProvider\Action\AbstractAction;
use Civi\ActionProvider\ConfigContainer;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use \Civi\ActionProvider\Parameter\Specification;
use \Civi\ActionProvider\Parameter\OptionGroupSpecification;
use \Civi\ActionProvider\Utils\CustomField;
use Civi\ActionProvider\Utils\Fields;
use CRM_ActionProvider_ExtensionUtil as E;
class UpdateParticipantById extends AbstractAction {
......@@ -62,13 +64,7 @@ class UpdateParticipantById extends AbstractAction {
$type = 'Integer';
break;
}
if (stripos($field['name'], 'custom_') === 0) {
$fieldId = substr($field['name'], 7);
$name = CustomField::getCustomFieldName($fieldId);
$title = $field['groupTitle'].' :: '.$field['title'];
$fieldSpec = new Specification($name, $type, $title, FALSE);
$fieldSpec->setApiFieldName($field['name']);
} else {
if (stripos($field['name'], 'custom_') !== 0) {
$fieldSpec = new Specification(
$field['name'],
$type,
......@@ -80,6 +76,13 @@ class UpdateParticipantById extends AbstractAction {
$specs->addSpecification($fieldSpec);
}
$customGroups = ConfigContainer::getInstance()->getCustomGroupsForEntity('Participant');
foreach ($customGroups as $customGroup) {
if (!empty($customGroup['is_active'])) {
$specs->addSpecification(CustomField::getSpecForCustomGroup($customGroup['id'], $customGroup['name'], $customGroup['title']));
}
}
return $specs;
}
......@@ -110,12 +113,12 @@ class UpdateParticipantById extends AbstractAction {
$participant_id = $parameters->getParameter('participant_id');
// Create or Update the participant record through an API call.
try {
$participantParams = array();
$participantParams = CustomField::getCustomFieldsApiParameter($parameters, $this->getParameterSpecification());
if ($participant_id) {
$participantParams['id'] = $participant_id;
}
foreach($this->getParameterSpecification() as $spec) {
if ($parameters->doesParameterExists($spec->getName())) {
if ($spec instanceof Specification && $spec->getApiFieldName() && $parameters->doesParameterExists($spec->getName())) {
$participantParams[$spec->getApiFieldName()] = $parameters->getParameter($spec->getName());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment