diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/OptionController.php | 11 | ||||
-rw-r--r-- | lib/Db/Option.php | 8 |
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/Controller/OptionController.php b/lib/Controller/OptionController.php index 798a3edf..c76cebbe 100644 --- a/lib/Controller/OptionController.php +++ b/lib/Controller/OptionController.php @@ -40,7 +40,6 @@ use OCA\Polls\Db\Option; use OCA\Polls\Db\OptionMapper; use OCA\Polls\Service\LogService; use OCA\Polls\Model\Acl; -use OCP\ILogger; class OptionController extends Controller { @@ -51,7 +50,6 @@ class OptionController extends Controller { private $pollMapper; private $logService; private $acl; - private $logger; /** * OptionController constructor. @@ -73,8 +71,7 @@ class OptionController extends Controller { IGroupManager $groupManager, PollMapper $pollMapper, LogService $logService, - Acl $acl, - ILogger $logger + Acl $acl ) { parent::__construct($appName, $request); $this->userId = $UserId; @@ -83,8 +80,7 @@ class OptionController extends Controller { $this->pollMapper = $pollMapper; $this->logService = $logService; $this->acl = $acl; - $this->logger = $logger; -} + } /** @@ -138,11 +134,10 @@ class OptionController extends Controller { public function add($option) { try { - // $this->acl->setPollId($option['pollId']); + if (!$this->acl->setPollId($option['pollId'])->getAllowEdit()) { return new DataResponse(null, Http::STATUS_UNAUTHORIZED); } - $this->logger->alert(json_encode($this->acl)); $NewOption = new Option(); diff --git a/lib/Db/Option.php b/lib/Db/Option.php index 48e47be9..f8c442ac 100644 --- a/lib/Db/Option.php +++ b/lib/Db/Option.php @@ -69,7 +69,7 @@ class Option extends Entity implements JsonSerializable { 'pollId' => intval($this->pollId), 'pollOptionText' => htmlspecialchars_decode($this->pollOptionText), 'timestamp' => intval($timestamp), - 'order' => setOrder($this->timestamp, $this->order) + 'order' => $this->setOrder(intval($this->timestamp), intval($this->order)) ]; } @@ -80,10 +80,10 @@ class Option extends Entity implements JsonSerializable { */ // TODO: remove by time private function setOrder($timestamp, $order) { - if ($timestamp > 0) { - return intval($timestamp); + if ($timestamp === 0) { + return $order; } else { - return intval($order); + return $timestamp; } } } |