diff options
author | dartcafe <github@dartcafe.de> | 2020-07-11 18:32:57 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2020-07-11 18:32:57 +0300 |
commit | cf4fe7174164f6a168bcd60ecf26896e0ea65848 (patch) | |
tree | 41f9e0daa3a5be1b24038c42f1ab58eebacb4b14 /lib/Service | |
parent | 255a36387351e40f2377a649156c3b0bf90f3ab5 (diff) |
code fixes and bugs
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/CommentService.php | 2 | ||||
-rw-r--r-- | lib/Service/OptionService.php | 26 | ||||
-rw-r--r-- | lib/Service/PollService.php | 2 | ||||
-rw-r--r-- | lib/Service/SubscriptionService.php | 4 | ||||
-rw-r--r-- | lib/Service/VoteService.php | 5 |
5 files changed, 19 insertions, 20 deletions
diff --git a/lib/Service/CommentService.php b/lib/Service/CommentService.php index f2c6ef56..6c5f89b6 100644 --- a/lib/Service/CommentService.php +++ b/lib/Service/CommentService.php @@ -119,7 +119,7 @@ class CommentService { } } catch (Exception $e) { - \OC::$server->getLogger()->alert('Error writing comment for pollId ' . $pollId . ': '. $e); + \OC::$server->getLogger()->alert('Error writing comment for pollId ' . $pollId . ': ' . $e); throw new NotAuthorizedException($e); } diff --git a/lib/Service/OptionService.php b/lib/Service/OptionService.php index 2bab49a8..84fb9822 100644 --- a/lib/Service/OptionService.php +++ b/lib/Service/OptionService.php @@ -35,7 +35,7 @@ use OCA\Polls\Db\Poll; use OCA\Polls\Service\LogService; use OCA\Polls\Model\Acl; -class OptionService { +class OptionService { /** @var OptionMapper */ private $optionMapper; @@ -112,7 +112,7 @@ class OptionService { * @return Option * @throws NotAuthorizedException */ - public function add($pollId, $timestamp = 0 , $pollOptionText = '') { + public function add($pollId, $timestamp = 0, $pollOptionText = '') { $this->poll = $this->pollMapper->find($pollId); if (!$this->acl->setPollId($pollId)->getAllowEdit()) { @@ -136,7 +136,7 @@ class OptionService { * @return Option * @throws NotAuthorizedException */ - public function update($optionId, $timestamp = 0 , $pollOptionText = '', $order = 0) { + public function update($optionId, $timestamp = 0, $pollOptionText = '', $order = 0) { $this->option = $this->optionMapper->find($optionId); $this->poll = $this->pollMapper->find($this->option->getPollId()); @@ -183,10 +183,10 @@ class OptionService { throw new NotAuthorizedException; } - if ($this->option->setConfirmation()) { - $this->option->setConfirmation(0); + if ($this->option->getConfirmed()) { + $this->option->setConfirmed(0); } else { - $this->option->setConfirmation(time()); + $this->option->setConfirmed(time()); } return $this->optionMapper->update($this->option); @@ -237,7 +237,7 @@ class OptionService { } if ($this->poll->getType() === 'datePoll') { - throw new BadRequestException("Not allowed in date polls", 1); + throw new BadRequestException("Not allowed in date polls"); } $i = 0; @@ -272,13 +272,13 @@ class OptionService { } if ($this->poll->getType() === 'datePoll') { - throw new BadRequestException("Not allowed in date polls", 1); + throw new BadRequestException("Not allowed in date polls"); } if ($newOrder < 1) { $newOrder = 1; - } elseif ($newOrder > getHighestOrder($pollId)) { - $newOrder = getHighestOrder($pollId); + } elseif ($newOrder > $this->getHighestOrder($pollId)) { + $newOrder = $this->getHighestOrder($pollId); } $oldOrder = $this->option->getOrder(); @@ -324,20 +324,20 @@ class OptionService { * @param int $order * @throws BadRequestException */ - private function setOption($timestamp = 0 , $pollOptionText = '', $order = 0) { + private function setOption($timestamp = 0, $pollOptionText = '', $order = 0) { if ($this->poll->getType() === 'datePoll') { if ($timestamp) { $this->option->setTimestamp($timestamp); $this->option->setOrder($timestamp); $this->option->setPollOptionText(date('c', $timestamp)); } else { - throw new BadRequestException("Date poll must have a timestamp", 1); + throw new BadRequestException("Date poll must have a timestamp"); } } elseif ($this->poll->getType() === 'textPoll') { if ($pollOptionText) { $this->option->setPollOptionText($pollOptionText); } else { - throw new BadRequestException("Text poll must have a pollOptionText", 1); + throw new BadRequestException("Text poll must have a pollOptionText"); } if (!$order && !$this->option->getOrder()) { diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php index 946a66d2..e730b575 100644 --- a/lib/Service/PollService.php +++ b/lib/Service/PollService.php @@ -208,7 +208,7 @@ } if (isset($poll['access']) && !in_array($poll['access'], $this->getValidAccess())) { - throw new InvalidAccessException('Invalid value for prop access '. $poll['access']); + throw new InvalidAccessException('Invalid value for prop access ' . $poll['access']); } if (isset($poll['title']) && !$poll['title']) { diff --git a/lib/Service/SubscriptionService.php b/lib/Service/SubscriptionService.php index 8809f792..0f7d82a7 100644 --- a/lib/Service/SubscriptionService.php +++ b/lib/Service/SubscriptionService.php @@ -32,7 +32,7 @@ use OCA\Polls\Db\Subscription; use OCA\Polls\Db\SubscriptionMapper; use OCA\Polls\Model\Acl; -class SubscriptionService { +class SubscriptionService { /** @var Acl */ private $acl; @@ -92,7 +92,7 @@ class SubscriptionService { return ['status' => 'Subscribed to poll ' . $pollId]; } - } catch (DoesNotExistException $e){ + } catch (DoesNotExistException $e) { if ($subscribed) { $subscription = new Subscription(); diff --git a/lib/Service/VoteService.php b/lib/Service/VoteService.php index 5073b732..7534b258 100644 --- a/lib/Service/VoteService.php +++ b/lib/Service/VoteService.php @@ -34,7 +34,7 @@ use OCA\Polls\Service\AnonymizeService; use OCA\Polls\Service\LogService; use OCA\Polls\Model\Acl; -class VoteService { +class VoteService { /** @var VoteMapper */ private $voteMapper; @@ -114,13 +114,12 @@ class VoteService { public function set($optionId, $setTo, $token = '') { $option = $this->optionMapper->find($optionId); - $pollId = $option->getPollId(); if (!$this->acl->setPollIdOrToken($option->getPollId(), $token)->getAllowVote()) { throw new NotAuthorizedException; } - if (!$option->getPollId() === $this->acl->getPollId()) { + if ($option->getPollId() !== $this->acl->getPollId()) { throw new NotAuthorizedException; } |