Commit f94e28c4 authored by ErikHommel's avatar ErikHommel
Browse files

fix issue 7766 - sign petition only once

parent 86c034a7
......@@ -68,9 +68,37 @@ class PetitionActivity extends AbstractAction {
* @throws ExecutionException
*/
public function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$this->addPetitionActivity($parameters, $output);
// temporarily: add to Nieuwsbrief group if more information ticked
$this->addNieuwsbrief($parameters);
if (!$this->signedPetitionEarlier($parameters)) {
$this->addPetitionActivity($parameters, $output);
// temporarily: add to Nieuwsbrief group if more information ticked
$this->addNieuwsbrief($parameters);
}
else {
throw new ExecutionException(E::ts('Petition was already signed by this contact'));
}
}
/**
* Methdo to check if the contact already signed this petition
*
* @param $parameters
* @return bool
*/
private function signedPetitionEarlier($parameters) {
$contactId = $parameters->getParameter('contact_id');
$campaignId = $parameters->getParameter('campaign_id');
$activityTypeId = $this->configuration->getParameter('activity_type_id');
if ($contactId && $campaignId && $activityTypeId) {
$count = civicrm_api3('Activity', 'getcount', [
'activity_type_id' => $activityTypeId,
'campaign_id' => $campaignId,
'target_contact_id' => $contactId,
]);
if ($count > 0) {
return TRUE;
}
}
return FALSE;
}
/**
......
......@@ -14,9 +14,9 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-01-20</releaseDate>
<version>1.12</version>
<develStage>beta</develStage>
<releaseDate>2021-03-01</releaseDate>
<version>1.13</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
</compatibility>
......@@ -28,7 +28,7 @@
<classloader>
<psr4 prefix="Civi\" path="Civi" />
</classloader>
<comments>Extension is being developed</comments>
<comments>Extension is being used in live</comments>
<civix>
<namespace>CRM/Aivlspecificactions</namespace>
</civix>
......
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