diff options
author | Vinzenz <vinzenz.rosenkranz@gmail.com> | 2016-03-16 05:41:36 +0300 |
---|---|---|
committer | Vinzenz <vinzenz.rosenkranz@gmail.com> | 2016-03-16 05:41:36 +0300 |
commit | c133262cebad36866345e448e7e87f032fe9776d (patch) | |
tree | c8b605eab4547bd066bc377ee3027ce29df3b7cc /controller | |
parent | 893bd675a6b0abe5948845bfa9819c87921719cf (diff) |
check for notification before other changes
Diffstat (limited to 'controller')
-rw-r--r-- | controller/pagecontroller.php | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 95fdf8aa..3b32c613 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -336,31 +336,31 @@ class PageController extends Controller { * @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); |