From c133262cebad36866345e448e7e87f032fe9776d Mon Sep 17 00:00:00 2001 From: Vinzenz Date: Wed, 16 Mar 2016 03:41:36 +0100 Subject: [PATCH] check for notification before other changes --- controller/pagecontroller.php | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 95fdf8aa9..3b32c6137 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -336,31 +336,31 @@ public function insertPoll($pollType, $pollTitle, $pollDesc, $userId, $chosenDat * @PublicPage */ public function insertVote($pollId, $userId, $types, $dates, $notif, $changed) { - if($changed === 'true') { - if($this->userId !== null) { - if($notif === 'true') { - try { - //check if user already set notification for this poll - $this->notificationMapper->findByUserAndPoll($pollId, $userId); - } catch(\OCP\AppFramework\Db\DoesNotExistException $e) { - //insert if not exist - $not = new Notification(); - $not->setUserId($userId); - $not->setPollId($pollId); - $this->notificationMapper->insert($not); - } - } else { - try { - //delete if entry is in db - $not = $this->notificationMapper->findByUserAndPoll($pollId, $userId); - $this->notificationMapper->delete($not); - } catch(\OCP\AppFramework\Db\DoesNotExistException $e) { - //doesn't exist in db, nothing to do - } + if($this->userId !== null) { + if($notif === 'true') { + try { + //check if user already set notification for this poll + $this->notificationMapper->findByUserAndPoll($pollId, $userId); + } catch(\OCP\AppFramework\Db\DoesNotExistException $e) { + //insert if not exist + $not = new Notification(); + $not->setUserId($userId); + $not->setPollId($pollId); + $this->notificationMapper->insert($not); } } else { - $userId = $userId . ' (extern)'; + try { + //delete if entry is in db + $not = $this->notificationMapper->findByUserAndPoll($pollId, $userId); + $this->notificationMapper->delete($not); + } catch(\OCP\AppFramework\Db\DoesNotExistException $e) { + //doesn't exist in db, nothing to do + } } + } else { + $userId = $userId . ' (extern)'; + } + if($changed === 'true') { $poll = $this->eventMapper->find($pollId); $dates = json_decode($dates); $types = json_decode($types);