Commit 3d589217 authored by Sebastian Castro's avatar Sebastian Castro

Fixs double contributions

parent 53fe05c1
......@@ -77,7 +77,7 @@ class ElementAdminController extends Controller
public function batchResolveReportsFunction($elementActionService, $selectedModel, $sendMail, $comment)
{
$elementActionService->resolveReports($selectedModel, $comment);
$elementActionService->resolveReports($selectedModel, $comment, true);
}
public function batchActionValidation(ProxyQueryInterface $selectedModelQuery)
......
......@@ -56,7 +56,7 @@ class DuplicatesController extends GoGoController
foreach ($duplicates as $key => $duplicate) {
$em->persist($element);
foreach($duplicates as $dup) { if($dup != $duplicate) $duplicate->addNonDuplicate($dup); }
$elementActionService->resolveReports($duplicate, 'Marqué comme non doublon');
$elementActionService->resolveReports($duplicate, 'Marqué comme non doublon', true);
}
$element->clearPotentialDuplicates();
......
......@@ -131,7 +131,7 @@ class ElementInteractionController extends Controller
$element = $em->getRepository('BiopenGeoDirectoryBundle:Element')->find($request->get('elementId'));
$elementActionService = $this->container->get('biopen.element_action_service');
$elementActionService->resolveReports($element, $request->get('comment'));
$elementActionService->resolveReports($element, $request->get('comment'), true);
$em->persist($element);
$em->flush();
......
......@@ -121,18 +121,18 @@ class ElementActionService
$element->updateTimestamp();
}
public function resolveReports($element, $message = '')
public function resolveReports($element, $message = '', $addContribution = false)
{
$elements = $element->getUnresolvedReports();
if (count($elements) > 0)
foreach ($elements as $key => $report)
$reports = $element->getUnresolvedReports();
if (count($reports) > 0)
foreach ($reports as $key => $report)
{
$report->setResolvedMessage($message);
$report->updateResolvedBy($this->securityContext);
$report->setIsResolved(true);
$this->mailService->sendAutomatedMail('report', $element, $message, $report);
}
else
else if ($addContribution)
$this->addContribution($element, $message, InteractType::ModerationResolved, $element->getStatus());
$element->setModerationState(ModerationState::NotNeeded);
......@@ -146,13 +146,13 @@ class ElementActionService
$this->em->flush();
}
private function addContribution($element, $message, $InteractType, $status, $directModerationWithHash = false)
private function addContribution($element, $message, $interactType, $status, $directModerationWithHash = false)
{
$contribution = new UserInteractionContribution();
$contribution->updateUserInformation($this->securityContext, null, $directModerationWithHash);
$contribution->setResolvedMessage($message);
$contribution->updateResolvedBy($this->securityContext, null, $directModerationWithHash);
$contribution->setType($InteractType);
$contribution->setType($interactType);
$contribution->setStatus($status);
$element->addContribution($contribution);
}
......
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