Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2020-06-22 19:55:42 +0300
committerdartcafe <github@dartcafe.de>2020-06-22 19:55:42 +0300
commit863d50ecfa2963664cb16892d31af65ad3289b5e (patch)
treea7e602e4bba24c103d4fd071b29e6e4c1cb314d0 /lib/Service
parent0d632d59b202f55da389db28b870b8c64416c00f (diff)
code maintenance
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/CommentService.php1
-rw-r--r--lib/Service/OptionService.php4
-rw-r--r--lib/Service/PollService.php100
-rw-r--r--lib/Service/ShareService.php17
4 files changed, 17 insertions, 105 deletions
diff --git a/lib/Service/CommentService.php b/lib/Service/CommentService.php
index 8ae7ef1e..a1cd7131 100644
--- a/lib/Service/CommentService.php
+++ b/lib/Service/CommentService.php
@@ -59,6 +59,7 @@ class CommentService {
Acl $acl
) {
$this->commentMapper = $commentMapper;
+ $this->comment = $comment;
$this->logger = $logger;
$this->anonymizer = $anonymizer;
$this->acl = $acl;
diff --git a/lib/Service/OptionService.php b/lib/Service/OptionService.php
index 139c8267..93052c3d 100644
--- a/lib/Service/OptionService.php
+++ b/lib/Service/OptionService.php
@@ -34,7 +34,6 @@ use OCA\Polls\Model\Acl;
class OptionService {
private $optionMapper;
- private $options;
private $option;
private $logService;
private $acl;
@@ -195,7 +194,8 @@ class OptionService {
/**
* Set order by order of the given array
* @NoAdminRequired
- * @param array $options
+ * @param integer $fromPollId
+ * @param integer $toPollId
* @return array Array of Option objects
*/
public function clone($fromPollId, $toPollId) {
diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php
index e747450d..d57f1124 100644
--- a/lib/Service/PollService.php
+++ b/lib/Service/PollService.php
@@ -45,7 +45,6 @@
class PollService {
private $logger;
- private $userid;
private $pollMapper;
private $poll;
private $logService;
@@ -57,8 +56,6 @@
/**
* PollController constructor.
- * @param string $appName
- * @param $userId
* @param PollMapper $pollMapper
* @param LogService $logService
* @param CommentService $commentService
@@ -69,8 +66,6 @@
*/
public function __construct(
- string $appName,
- $userId,
ILogger $logger,
PollMapper $pollMapper,
Poll $poll,
@@ -81,7 +76,6 @@
VoteService $voteService,
Acl $acl
) {
- $this->userId = $userId;
$this->logger = $logger;
$this->pollMapper = $pollMapper;
$this->poll = $poll;
@@ -97,7 +91,7 @@
/**
* list
* @NoAdminRequired
- * @return DataResponse
+ * @return array
*/
public function list() {
@@ -105,6 +99,8 @@
throw new NotAuthorizedException;
}
+ $pollList = [];
+
$polls = $this->pollMapper->findAll();
// TODO: Not the elegant way. Improvement neccessary
foreach ($polls as $poll) {
@@ -217,7 +213,7 @@
* @NoAdminRequired
* @NoCSRFRequired
* @param Array $poll
- * @return DataResponse
+ * @return Poll
*/
public function add($type, $title) {
@@ -258,94 +254,12 @@
return $this->poll;
}
- // /**
- // * write
- // * @NoAdminRequired
- // * @NoCSRFRequired
- // * @depricated
- // * @param Array $poll
- // * @return DataResponse
- // */
- //
- // public function write($poll, $pollId = null) {
- //
- // if (!$pollId) {
- // $pollId = $poll['id'];
- // }
- //
- // // Validate valuess
- // if (isset($poll['showResults']) && !in_array($poll['showResults'], $this->getValidShowResults())) {
- // throw new InvalidShowResultsException('Invalid value for prop showResults');
- // }
- //
- // if (isset($poll['access']) && !in_array($poll['access'], $this->getValidShowResults())) {
- // throw new InvalidAccessException('Invalid value for prop access');
- // }
- //
- // if (isset($poll['title']) && !$poll['title']) {
- // throw new EmptyTitleException('Title must not be empty');
- // }
- //
- // try {
- // // find pollId
- // $this->poll = $this->pollMapper->find($pollId);
- // $this->logService->setLog($this->poll->getId(), 'updatePoll');
- //
- //
- // } catch (DoesNotExistException $e) {
- // // if not found create a new poll
- //
- // // Validate valuess
- // if (!in_array($poll['type'], $this->getValidPollType())) {
- // throw new InvalidPollTypeException('Invalid poll type');
- // }
- //
- // if (!$poll['title']) {
- // throw new EmptyTitleException('Title must not be empty');
- // }
- //
- //
- // $this->poll = new Poll();
- // $this->poll->setType($poll['type']);
- // $this->poll->setOwner($this->userId);
- // $this->poll->setTitle($poll['title']);
- // $this->poll->setCreated(time());
- // $this->poll = $this->pollMapper->insert($this->poll);
- //
- // $this->logService->setLog($this->poll->getId(), 'addPoll');
- // }
- //
- // if (!$this->acl->setPollId($this->poll->getId())->getAllowEdit()) {
- // throw new NotAuthorizedException;
- // }
- //
- // $this->poll->setTitle(isset($poll['title']) ? $poll['title'] : $this->poll->getTitle());
- // $this->poll->setDescription(isset($poll['description']) ? $poll['description'] : $this->poll->getDescription());
- // $this->poll->setAccess(isset($poll['access']) ? $poll['access'] : $this->poll->getAccess());
- // $this->poll->setExpire(isset($poll['expire']) ? $poll['expire'] : $this->poll->getExpire());
- // $this->poll->setAnonymous(isset($poll['anonymous']) ? $poll['anonymous'] : $this->poll->getAnonymous());
- // $this->poll->setAllowMaybe(isset($poll['allowMaybe']) ? $poll['allowMaybe'] : $this->poll->getAllowMaybe());
- // $this->poll->setVoteLimit(isset($poll['voteLimit']) ? $poll['voteLimit'] : $this->poll->getVoteLimit());
- // $this->poll->setShowResults(isset($poll['showResults']) ? $poll['showResults'] : $this->poll->getShowResults());
- // $this->poll->setDeleted(isset($poll['deleted']) ? $poll['deleted'] : $this->poll->getDeleted());
- // $this->poll->setAdminAccess(isset($poll['adminAccess']) ? $poll['adminAccess'] : $this->poll->getAdminAccess());
- //
- // $this->poll->setFullAnonymous(0);
- // $this->poll->setVoteLimit(0);
- // $this->poll->setSettings('');
- // $this->poll->setOptions('');
- //
- // $this->pollMapper->update($this->poll);
- //
- // return $this->poll;
- // }
-
/**
* update
* @NoAdminRequired
* @NoCSRFRequired
* @param Array $poll
- * @return DataResponse
+ * @return Poll
*/
public function update($pollId, $poll) {
@@ -391,7 +305,7 @@
* @NoAdminRequired
* @NoCSRFRequired
* @param integer $pollId
- * @return DataResponse
+ * @return Poll
*/
public function clone($pollId) {
@@ -408,7 +322,7 @@
$this->poll->setId(0);
$this->poll = $this->pollMapper->insert($this->poll);
- $this->logService->setLog($clonePoll->getId(), 'addPoll');
+ $this->logService->setLog($this->poll->getId(), 'addPoll');
$this->optionService->clone($pollId, $this->poll->getId());
diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php
index 04a40269..a7cf144b 100644
--- a/lib/Service/ShareService.php
+++ b/lib/Service/ShareService.php
@@ -71,7 +71,7 @@ class ShareService {
* Read all shares of a poll based on the poll id and return list as array
* @NoAdminRequired
* @param integer $pollId
- * @return DataResponse
+ * @return array
*/
public function list($pollId) {
if (!$this->acl->setPollId($pollId)->getAllowEdit()) {
@@ -87,11 +87,10 @@ class ShareService {
* Get pollId by token
* @NoAdminRequired
* @param string $token
- * @return Array
+ * @return Share
*/
public function get($token) {
- $this->share = $this->shareMapper->findByToken($token);
- return $this->share;
+ return $this->shareMapper->findByToken($token);
}
/**
@@ -100,7 +99,7 @@ class ShareService {
* @depricated
* @param int $pollId
* @param string $share
- * @return Array
+ * @return array
*/
// TODO: Replace with $this->add and separate sending invitations
public function write($pollId, $type, $userId, $userEmail = '') {
@@ -135,7 +134,7 @@ class ShareService {
* @NoAdminRequired
* @param int $pollId
* @param string $share
- * @return Array
+ * @return array
*/
public function add($pollId, $type, $userId, $userEmail = '') {
@@ -192,15 +191,13 @@ class ShareService {
$this->share->setPollId($publicShare->getPollId());
$this->share->setUserId($userName);
$this->share->setUserEmail('');
- $this->share = $this->shareMapper->insert($this->share);
- return $this->share;
+ return $this->shareMapper->insert($this->share);
} elseif ($publicShare->getType() === 'email') {
$publicShare->setType('external');
$publicShare->setUserId($userName);
- $this->shareMapper->update($publicShare);
- return new DataResponse($publicShare, Http::STATUS_OK);
+ return $this->shareMapper->update($publicShare);
} else {
throw new NotAuthorizedException;