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>2021-06-22 00:52:14 +0300
committerdartcafe <github@dartcafe.de>2021-06-22 00:52:14 +0300
commit2062843b4db44043e013484156512d76bcde05de (patch)
tree9dd990ede136a25673da43dd2ec013451fef7e73 /lib/Migration
parent7751a511d857bc2f3f5e21d7cf651001b059a9d6 (diff)
apply changes from #1762 for #1749 manually
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib/Migration')
-rw-r--r--lib/Migration/FixVotes.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/Migration/FixVotes.php b/lib/Migration/FixVotes.php
new file mode 100644
index 00000000..20f0ba3c
--- /dev/null
+++ b/lib/Migration/FixVotes.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ * @author René Gieling <github@dartcafe.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCA\Polls\Migration;
+
+use OCA\Polls\Db\LogMapper;
+use OCA\Polls\Db\OptionMapper;
+use OCA\Polls\Db\VoteMapper;
+use OCP\Migration\IRepairStep;
+use OCP\Migration\IOutput;
+
+class FixVotes implements IRepairStep {
+ /** @var LogMapper */
+ private $logMapper;
+
+ /** @var OptionMapper */
+ private $optionMapper;
+
+ /** @var VoteMapper */
+ private $voteMapper;
+
+ public function __construct(
+ LogMapper $logMapper,
+ OptionMapper $optionMapper,
+ VoteMapper $voteMapper
+ ) {
+ $this->logMapper = $logMapper;
+ $this->optionMapper = $optionMapper;
+ $this->voteMapper = $voteMapper;
+ }
+
+ /*
+ * @inheritdoc
+ */
+ public function getName() {
+ return 'Polls repairstep - Fix votes with duration options';
+ }
+
+ /**
+ * @inheritdoc
+ *
+ * @return void
+ */
+ public function run(IOutput $output) {
+ $foundOptions = $this->optionMapper->findOptionsWithDuration();
+ foreach ($foundOptions as $option) {
+ $this->voteMapper->fixVoteOptionText(
+ $option->getPollId(),
+ $option->getId(),
+ $option->getPollOptionTextStart(),
+ $option->getPollOptionText(),
+ );
+ }
+ }
+}