Skip to content

Commit

Permalink
Fix ShowListener for multiple socs. Fixes #191
Browse files Browse the repository at this point in the history
  • Loading branch information
GKFX committed Dec 7, 2018
1 parent 5e1bebb commit 68c8cc8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Acts/CamdramBundle/EventListener/ShowListener.php
Expand Up @@ -75,12 +75,20 @@ private function sendChangeEmails(Show $show, PreUpdateEventArgs $event)
{
$authorisationEmailSent = false;

if ($event->hasChangedField('society') && ! $show->getSocieties()->isEmpty()) {
if ($show->getAuthorised()) {
$this->moderationManager->notifySocietyChanged($show);
} else {
$this->moderationManager->autoApproveOrEmailModerators($show);
$authorisationEmailSent = true;
if ($event->hasChangedField('societies_display_list') && ! $show->getSocieties()->isEmpty()) {
// Can't access changes to the societies Association here, so
// it's neccessary to parse the JSON.
$socs_data = array_map('json_decode', $event->getEntityChangeSet()['societies_display_list']);
if (is_array($socs_data[0]) && is_array($socs_data[1])) {
$socs_data = [array_filter($socs_data[0], 'is_int'), array_filter($socs_data[1], 'is_int')];
if (array_diff($socs_data[0], $socs_data[1]) || array_diff($socs_data[1], $socs_data[0])) {
if ($show->getAuthorised()) {
$this->moderationManager->notifySocietyChanged($show);
} else {
$this->moderationManager->autoApproveOrEmailModerators($show);
$authorisationEmailSent = true;
}
}
}
}

Expand Down

0 comments on commit 68c8cc8

Please sign in to comment.