Commit 4c36cd82 authored by ErikHommel's avatar ErikHommel
Browse files

issue 7740 - add location and metadata event + fix the first_name excel error

parent 8d7f6afe
......@@ -33,6 +33,8 @@ class PetitionActivity extends AbstractAction {
$specs->addSpecification(new Specification('petition_flag', 'Integer', E::ts('Petition Flag'), FALSE, 0));
$specs->addSpecification(new Specification('more_information', 'Integer', E::ts('More Information'), FALSE, 0));
$specs->addSpecification(new Specification('signature_date', 'Date', E::ts('Signature Date'), FALSE, NULL));
$specs->addSpecification(new Specification('location', 'String', E::ts('Location'), FALSE, NULL));
$specs->addSpecification(new Specification('metadata_event', 'String', E::ts('Petition metadata->event'), FALSE, NULL));
return $specs;
}
......@@ -161,6 +163,18 @@ class PetitionActivity extends AbstractAction {
catch (\Exception $ex) {
}
}
$location = $parameterBag->getParameter('location');
if ($location) {
$activityParams['location'] = $location;
}
$metadataEvent = $parameterBag->getParameter('metadata_event');
if ($metadataEvent) {
$customFieldId = $this->getEventCustomFieldId();
if ($customFieldId) {
$customFieldId = "custom_" . $customFieldId;
$activityParams[$customFieldId] = $metadataEvent;
}
}
try {
$created = civicrm_api3('Activity', 'create', $activityParams);
$output->setParameter('activity_id', $created['id']);
......@@ -171,6 +185,32 @@ class PetitionActivity extends AbstractAction {
}
}
/**
* Method to get custom field id for custom field Event in Petities Metadata
*
* @return array|false
*/
private function getEventCustomFieldId() {
$customGroupName = "Petities_metadata";
$customFieldName = "Event";
try {
$customFieldId = civicrm_api3('CustomField', 'getvalue', [
'return' => "id",
'custom_group_id' => $customGroupName,
'name' => $customFieldName,
]);
if ($customFieldId) {
return (int) $customFieldId;
}
}
catch (\CiviCRM_API3_Exception $ex) {
\Civi::log()->error(E::ts("Not able to find a custom field with name ") . $customFieldName
. E::ts(" in custom group with name ") . $customGroupName . E::ts(" in ") . __METHOD__
. E::ts(", error from API3 CustomField getvalue: ") . $ex->getMessage());
}
return FALSE;
}
/**
* Method to get the campaign title
*
......
......@@ -14,8 +14,8 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-05-03</releaseDate>
<version>1.14</version>
<releaseDate>2021-05-20</releaseDate>
<version>1.15</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
......
Supports Markdown
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