Skip to content

Commit

Permalink
no notification email if user is admin
Browse files Browse the repository at this point in the history
  • Loading branch information
mrothauer committed Jun 28, 2024
1 parent 626ac1d commit ef0ea22
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/Controller/WorkshopsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Event\EventInterface;
use Cake\Mailer\Mailer;
use Cake\Http\Exception\ForbiddenException;
use Cake\Http\Exception\NotFoundException;
use Cake\Utility\Hash;
Expand Down Expand Up @@ -152,7 +151,7 @@ private function _edit($workshop, $isEditMode)
$this->AppFlash->setFlashMessage($this->Workshop->name_de . ' erfolgreich gespeichert.');

// add orga user to workshop if workshop was created - id is kinda hard to retrieve...
if (!$isEditMode && $this->isOrga() &&!$this->isAdmin()) {
if (!$isEditMode && $this->isOrga() && !$this->isAdmin()) {
$usersWorkshop = $this->getTableLocator()->get('UsersWorkshops');
$savedWorkshop = $this->Workshop->find('all', conditions: [
'Workshops.url' => $patchedEntity->url,
Expand All @@ -167,16 +166,19 @@ private function _edit($workshop, $isEditMode)
if ($isEditMode) {
$userAction = 'geändert';
}
$email = new AppMailer();
$email->viewBuilder()->setTemplate('workshop_added_or_changed');
$email->setSubject('Initiative "'.$entity->name.'" erfolgreich ' . $userAction)
->setViewVars([
'workshop' => $entity,
'username' => $this->loggedUser->name,
'userAction' => $userAction,
]);
$email->setTo(Configure::read('AppConfig.notificationMailAddress'));
$email->addToQueue();

if (!$this->isAdmin()) {
$email = new AppMailer();
$email->viewBuilder()->setTemplate('workshop_added_or_changed');
$email->setSubject('Initiative "'.$entity->name.'" erfolgreich ' . $userAction)
->setViewVars([
'workshop' => $entity,
'username' => $this->loggedUser->name,
'userAction' => $userAction,
]);
$email->setTo(Configure::read('AppConfig.notificationMailAddress'));
$email->addToQueue();
}

$this->redirect($this->getPreparedReferer());

Expand Down

0 comments on commit ef0ea22

Please sign in to comment.