@@ -33,65 +33,65 @@ |
||
33 | 33 | |
34 | 34 | class ParticipationTextMapperTest extends UnitTestCase { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $con; |
|
38 | - /** @var ParticipationTextMapper */ |
|
39 | - private $participationTextMapper; |
|
40 | - /** @var EventMapper */ |
|
41 | - private $eventMapper; |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $con; |
|
38 | + /** @var ParticipationTextMapper */ |
|
39 | + private $participationTextMapper; |
|
40 | + /** @var EventMapper */ |
|
41 | + private $eventMapper; |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - */ |
|
46 | - public function setUp() { |
|
47 | - parent::setUp(); |
|
48 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | - $this->participationTextMapper = new ParticipationTextMapper($this->con); |
|
50 | - $this->eventMapper = new EventMapper($this->con); |
|
51 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + */ |
|
46 | + public function setUp() { |
|
47 | + parent::setUp(); |
|
48 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | + $this->participationTextMapper = new ParticipationTextMapper($this->con); |
|
50 | + $this->eventMapper = new EventMapper($this->con); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Create some fake data and persist them to the database. |
|
55 | - * |
|
56 | - * @return ParticipationText |
|
57 | - */ |
|
58 | - public function testCreate() { |
|
59 | - /** @var Event $event */ |
|
60 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
53 | + /** |
|
54 | + * Create some fake data and persist them to the database. |
|
55 | + * |
|
56 | + * @return ParticipationText |
|
57 | + */ |
|
58 | + public function testCreate() { |
|
59 | + /** @var Event $event */ |
|
60 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
62 | 62 | |
63 | - /** @var ParticipationText $participationText */ |
|
64 | - $participationText = $this->fm->instance('OCA\Polls\Db\ParticipationText'); |
|
65 | - $participationText->setPollId($event->getId()); |
|
66 | - $this->assertInstanceOf(ParticipationText::class, $this->participationTextMapper->insert($participationText)); |
|
63 | + /** @var ParticipationText $participationText */ |
|
64 | + $participationText = $this->fm->instance('OCA\Polls\Db\ParticipationText'); |
|
65 | + $participationText->setPollId($event->getId()); |
|
66 | + $this->assertInstanceOf(ParticipationText::class, $this->participationTextMapper->insert($participationText)); |
|
67 | 67 | |
68 | - return $participationText; |
|
69 | - } |
|
68 | + return $participationText; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Update the previously created entry and persist the changes. |
|
73 | - * |
|
74 | - * @depends testCreate |
|
75 | - * @param ParticipationText $participationText |
|
76 | - * @return ParticipationText |
|
77 | - */ |
|
78 | - public function testUpdate(ParticipationText $participationText) { |
|
79 | - $newText = Faker::paragraph(); |
|
80 | - $participationText->setText($newText()); |
|
81 | - $this->participationTextMapper->update($participationText); |
|
71 | + /** |
|
72 | + * Update the previously created entry and persist the changes. |
|
73 | + * |
|
74 | + * @depends testCreate |
|
75 | + * @param ParticipationText $participationText |
|
76 | + * @return ParticipationText |
|
77 | + */ |
|
78 | + public function testUpdate(ParticipationText $participationText) { |
|
79 | + $newText = Faker::paragraph(); |
|
80 | + $participationText->setText($newText()); |
|
81 | + $this->participationTextMapper->update($participationText); |
|
82 | 82 | |
83 | - return $participationText; |
|
84 | - } |
|
83 | + return $participationText; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Delete the previously created entries from the database. |
|
88 | - * |
|
89 | - * @depends testUpdate |
|
90 | - * @param ParticipationText $participationText |
|
91 | - */ |
|
92 | - public function testDelete(ParticipationText $participationText) { |
|
93 | - $event = $this->eventMapper->find($participationText->getPollId()); |
|
94 | - $this->participationTextMapper->delete($participationText); |
|
95 | - $this->eventMapper->delete($event); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Delete the previously created entries from the database. |
|
88 | + * |
|
89 | + * @depends testUpdate |
|
90 | + * @param ParticipationText $participationText |
|
91 | + */ |
|
92 | + public function testDelete(ParticipationText $participationText) { |
|
93 | + $event = $this->eventMapper->find($participationText->getPollId()); |
|
94 | + $this->participationTextMapper->delete($participationText); |
|
95 | + $this->eventMapper->delete($event); |
|
96 | + } |
|
97 | 97 | } |
@@ -33,65 +33,65 @@ |
||
33 | 33 | |
34 | 34 | class ParticipationMapperTest extends UnitTestCase { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $con; |
|
38 | - /** @var ParticipationMapper */ |
|
39 | - private $participationMapper; |
|
40 | - /** @var EventMapper */ |
|
41 | - private $eventMapper; |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $con; |
|
38 | + /** @var ParticipationMapper */ |
|
39 | + private $participationMapper; |
|
40 | + /** @var EventMapper */ |
|
41 | + private $eventMapper; |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - */ |
|
46 | - public function setUp() { |
|
47 | - parent::setUp(); |
|
48 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | - $this->participationMapper = new ParticipationMapper($this->con); |
|
50 | - $this->eventMapper = new EventMapper($this->con); |
|
51 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + */ |
|
46 | + public function setUp() { |
|
47 | + parent::setUp(); |
|
48 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
49 | + $this->participationMapper = new ParticipationMapper($this->con); |
|
50 | + $this->eventMapper = new EventMapper($this->con); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Create some fake data and persist them to the database. |
|
55 | - * |
|
56 | - * @return Participation |
|
57 | - */ |
|
58 | - public function testCreate() { |
|
59 | - /** @var Event $event */ |
|
60 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
53 | + /** |
|
54 | + * Create some fake data and persist them to the database. |
|
55 | + * |
|
56 | + * @return Participation |
|
57 | + */ |
|
58 | + public function testCreate() { |
|
59 | + /** @var Event $event */ |
|
60 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
61 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
62 | 62 | |
63 | - /** @var Participation $participation */ |
|
64 | - $participation = $this->fm->instance('OCA\Polls\Db\Participation'); |
|
65 | - $participation->setPollId($event->getId()); |
|
66 | - $this->assertInstanceOf(Participation::class, $this->participationMapper->insert($participation)); |
|
63 | + /** @var Participation $participation */ |
|
64 | + $participation = $this->fm->instance('OCA\Polls\Db\Participation'); |
|
65 | + $participation->setPollId($event->getId()); |
|
66 | + $this->assertInstanceOf(Participation::class, $this->participationMapper->insert($participation)); |
|
67 | 67 | |
68 | - return $participation; |
|
69 | - } |
|
68 | + return $participation; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Update the previously created entry and persist the changes. |
|
73 | - * |
|
74 | - * @depends testCreate |
|
75 | - * @param Participation $participation |
|
76 | - * @return Participation |
|
77 | - */ |
|
78 | - public function testUpdate(Participation $participation) { |
|
79 | - $newDt = Faker::date('Y-m-d H:i:s'); |
|
80 | - $participation->setDt($newDt()); |
|
81 | - $this->participationMapper->update($participation); |
|
71 | + /** |
|
72 | + * Update the previously created entry and persist the changes. |
|
73 | + * |
|
74 | + * @depends testCreate |
|
75 | + * @param Participation $participation |
|
76 | + * @return Participation |
|
77 | + */ |
|
78 | + public function testUpdate(Participation $participation) { |
|
79 | + $newDt = Faker::date('Y-m-d H:i:s'); |
|
80 | + $participation->setDt($newDt()); |
|
81 | + $this->participationMapper->update($participation); |
|
82 | 82 | |
83 | - return $participation; |
|
84 | - } |
|
83 | + return $participation; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Delete the previously created entries from the database. |
|
88 | - * |
|
89 | - * @depends testUpdate |
|
90 | - * @param Participation $participation |
|
91 | - */ |
|
92 | - public function testDelete(Participation $participation) { |
|
93 | - $event = $this->eventMapper->find($participation->getPollId()); |
|
94 | - $this->participationMapper->delete($participation); |
|
95 | - $this->eventMapper->delete($event); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Delete the previously created entries from the database. |
|
88 | + * |
|
89 | + * @depends testUpdate |
|
90 | + * @param Participation $participation |
|
91 | + */ |
|
92 | + public function testDelete(Participation $participation) { |
|
93 | + $event = $this->eventMapper->find($participation->getPollId()); |
|
94 | + $this->participationMapper->delete($participation); |
|
95 | + $this->eventMapper->delete($event); |
|
96 | + } |
|
97 | 97 | } |
@@ -31,57 +31,57 @@ |
||
31 | 31 | |
32 | 32 | class EventMapperTest extends UnitTestCase { |
33 | 33 | |
34 | - /** @var IDBConnection */ |
|
35 | - private $con; |
|
36 | - /** @var EventMapper */ |
|
37 | - private $eventMapper; |
|
34 | + /** @var IDBConnection */ |
|
35 | + private $con; |
|
36 | + /** @var EventMapper */ |
|
37 | + private $eventMapper; |
|
38 | 38 | |
39 | - /** |
|
40 | - * {@inheritDoc} |
|
41 | - */ |
|
42 | - public function setUp() { |
|
43 | - parent::setUp(); |
|
44 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
45 | - $this->eventMapper = new EventMapper($this->con); |
|
46 | - } |
|
39 | + /** |
|
40 | + * {@inheritDoc} |
|
41 | + */ |
|
42 | + public function setUp() { |
|
43 | + parent::setUp(); |
|
44 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
45 | + $this->eventMapper = new EventMapper($this->con); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Create some fake data and persist them to the database. |
|
50 | - * |
|
51 | - * @return Event |
|
52 | - */ |
|
53 | - public function testCreate() { |
|
54 | - /** @var Event $event */ |
|
55 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
56 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
48 | + /** |
|
49 | + * Create some fake data and persist them to the database. |
|
50 | + * |
|
51 | + * @return Event |
|
52 | + */ |
|
53 | + public function testCreate() { |
|
54 | + /** @var Event $event */ |
|
55 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
56 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
57 | 57 | |
58 | - return $event; |
|
59 | - } |
|
58 | + return $event; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Update the previously created entry and persist the changes. |
|
63 | - * |
|
64 | - * @depends testCreate |
|
65 | - * @param Event $event |
|
66 | - * @return Event |
|
67 | - */ |
|
68 | - public function testUpdate(Event $event) { |
|
69 | - $newTitle = Faker::sentence(10); |
|
70 | - $newDescription = Faker::paragraph(); |
|
71 | - $event->setTitle($newTitle()); |
|
72 | - $event->setDescription($newDescription()); |
|
73 | - $this->eventMapper->update($event); |
|
61 | + /** |
|
62 | + * Update the previously created entry and persist the changes. |
|
63 | + * |
|
64 | + * @depends testCreate |
|
65 | + * @param Event $event |
|
66 | + * @return Event |
|
67 | + */ |
|
68 | + public function testUpdate(Event $event) { |
|
69 | + $newTitle = Faker::sentence(10); |
|
70 | + $newDescription = Faker::paragraph(); |
|
71 | + $event->setTitle($newTitle()); |
|
72 | + $event->setDescription($newDescription()); |
|
73 | + $this->eventMapper->update($event); |
|
74 | 74 | |
75 | - return $event; |
|
76 | - } |
|
75 | + return $event; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Delete the previously created entry from the database. |
|
80 | - * |
|
81 | - * @depends testUpdate |
|
82 | - * @param Event $event |
|
83 | - */ |
|
84 | - public function testDelete(Event $event) { |
|
85 | - $this->eventMapper->delete($event); |
|
86 | - } |
|
78 | + /** |
|
79 | + * Delete the previously created entry from the database. |
|
80 | + * |
|
81 | + * @depends testUpdate |
|
82 | + * @param Event $event |
|
83 | + */ |
|
84 | + public function testDelete(Event $event) { |
|
85 | + $this->eventMapper->delete($event); |
|
86 | + } |
|
87 | 87 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | if (!defined('PHPUNIT_RUN')) { |
25 | - define('PHPUNIT_RUN', 1); |
|
25 | + define('PHPUNIT_RUN', 1); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | require_once __DIR__ . '/../../../lib/base.php'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | \OC_App::loadApp('polls'); |
33 | 33 | |
34 | 34 | if (!class_exists('PHPUnit_Framework_TestCase')) { |
35 | - require_once 'PHPUnit/Autoload.php'; |
|
35 | + require_once 'PHPUnit/Autoload.php'; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | \OC_Hook::clear(); |
@@ -27,5 +27,5 @@ |
||
27 | 27 | * General factory for the notification model. |
28 | 28 | */ |
29 | 29 | $fm->define('OCA\Polls\Db\Notification')->setDefinitions([ |
30 | - 'userId' => Faker::firstNameMale() |
|
30 | + 'userId' => Faker::firstNameMale() |
|
31 | 31 | ]); |
@@ -1,74 +1,74 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]> |
|
4 | - * |
|
5 | - * @author Vinzenz Rosenkranz <[email protected]> |
|
6 | - * |
|
7 | - * @license GNU AGPL version 3 or any later version |
|
8 | - * |
|
9 | - * This program is free software: you can redistribute it and/or modify |
|
10 | - * it under the terms of the GNU Affero General Public License as |
|
11 | - * published by the Free Software Foundation, either version 3 of the |
|
12 | - * License, or (at your option) any later version. |
|
13 | - * |
|
14 | - * This program is distributed in the hope that it will be useful, |
|
15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 | - * GNU Affero General Public License for more details. |
|
18 | - * |
|
19 | - * You should have received a copy of the GNU Affero General Public License |
|
20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21 | - * |
|
22 | - */ |
|
23 | - |
|
24 | - \OCP\Util::addStyle('polls', 'main'); |
|
25 | - \OCP\Util::addStyle('polls', 'createpoll'); |
|
26 | - \OCP\Util::addStyle('polls', 'vendor/jquery.datetimepicker'); |
|
27 | - \OCP\Util::addScript('polls', 'create_edit'); |
|
28 | - \OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min'); |
|
29 | - |
|
30 | - $userId = $_['userId']; |
|
31 | - /** @var \OCP\IUserManager $userMgr */ |
|
32 | - $userMgr = $_['userMgr']; |
|
33 | - /** @var \OCP\IURLGenerator $urlGenerator */ |
|
34 | - $urlGenerator = $_['urlGenerator']; |
|
35 | - $isUpdate = isset($_['poll']) && $_['poll'] !== null; |
|
36 | - $isAnonymous = false; |
|
37 | - $hideNames = false; |
|
38 | - |
|
39 | - if ($isUpdate) { |
|
40 | - /** @var OCA\Polls\Db\Event $poll */ |
|
41 | - $poll = $_['poll']; |
|
42 | - $isAnonymous = $poll->getIsAnonymous(); |
|
43 | - $hideNames = $isAnonymous && $poll->getFullAnonymous(); |
|
44 | - /** @var OCA\Polls\Db\Date[]|OCA\Polls\Db\Text[] $dates */ |
|
45 | - $dates = $_['dates']; |
|
46 | - $chosen = '['; |
|
47 | - foreach ($dates as $d) { |
|
48 | - if ($poll->getType() === 0) { |
|
49 | - $chosen .= strtotime($d->getDt()); |
|
50 | - } else { |
|
51 | - $chosen .= '"' . $d->getText() . '"'; |
|
52 | - } |
|
53 | - $chosen .= ','; |
|
54 | - } |
|
55 | - $chosen = trim($chosen, ','); |
|
56 | - $chosen .= ']'; |
|
57 | - $title = $poll->getTitle(); |
|
58 | - $desc = $poll->getDescription(); |
|
59 | - if ($poll->getExpire() !== null) { |
|
60 | - $expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day |
|
61 | - $expireStr = date('d.m.Y', $expireTs); |
|
62 | - } |
|
63 | - $access = $poll->getAccess(); |
|
64 | - $accessTypes = $access; |
|
65 | - if ( |
|
66 | - $access !== 'registered' |
|
67 | - && $access !== 'hidden' && $access !== 'public' |
|
68 | - ) { |
|
69 | - $access = 'select'; |
|
70 | - } |
|
71 | - } |
|
2 | + /** |
|
3 | + * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]> |
|
4 | + * |
|
5 | + * @author Vinzenz Rosenkranz <[email protected]> |
|
6 | + * |
|
7 | + * @license GNU AGPL version 3 or any later version |
|
8 | + * |
|
9 | + * This program is free software: you can redistribute it and/or modify |
|
10 | + * it under the terms of the GNU Affero General Public License as |
|
11 | + * published by the Free Software Foundation, either version 3 of the |
|
12 | + * License, or (at your option) any later version. |
|
13 | + * |
|
14 | + * This program is distributed in the hope that it will be useful, |
|
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 | + * GNU Affero General Public License for more details. |
|
18 | + * |
|
19 | + * You should have received a copy of the GNU Affero General Public License |
|
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21 | + * |
|
22 | + */ |
|
23 | + |
|
24 | + \OCP\Util::addStyle('polls', 'main'); |
|
25 | + \OCP\Util::addStyle('polls', 'createpoll'); |
|
26 | + \OCP\Util::addStyle('polls', 'vendor/jquery.datetimepicker'); |
|
27 | + \OCP\Util::addScript('polls', 'create_edit'); |
|
28 | + \OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min'); |
|
29 | + |
|
30 | + $userId = $_['userId']; |
|
31 | + /** @var \OCP\IUserManager $userMgr */ |
|
32 | + $userMgr = $_['userMgr']; |
|
33 | + /** @var \OCP\IURLGenerator $urlGenerator */ |
|
34 | + $urlGenerator = $_['urlGenerator']; |
|
35 | + $isUpdate = isset($_['poll']) && $_['poll'] !== null; |
|
36 | + $isAnonymous = false; |
|
37 | + $hideNames = false; |
|
38 | + |
|
39 | + if ($isUpdate) { |
|
40 | + /** @var OCA\Polls\Db\Event $poll */ |
|
41 | + $poll = $_['poll']; |
|
42 | + $isAnonymous = $poll->getIsAnonymous(); |
|
43 | + $hideNames = $isAnonymous && $poll->getFullAnonymous(); |
|
44 | + /** @var OCA\Polls\Db\Date[]|OCA\Polls\Db\Text[] $dates */ |
|
45 | + $dates = $_['dates']; |
|
46 | + $chosen = '['; |
|
47 | + foreach ($dates as $d) { |
|
48 | + if ($poll->getType() === 0) { |
|
49 | + $chosen .= strtotime($d->getDt()); |
|
50 | + } else { |
|
51 | + $chosen .= '"' . $d->getText() . '"'; |
|
52 | + } |
|
53 | + $chosen .= ','; |
|
54 | + } |
|
55 | + $chosen = trim($chosen, ','); |
|
56 | + $chosen .= ']'; |
|
57 | + $title = $poll->getTitle(); |
|
58 | + $desc = $poll->getDescription(); |
|
59 | + if ($poll->getExpire() !== null) { |
|
60 | + $expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day |
|
61 | + $expireStr = date('d.m.Y', $expireTs); |
|
62 | + } |
|
63 | + $access = $poll->getAccess(); |
|
64 | + $accessTypes = $access; |
|
65 | + if ( |
|
66 | + $access !== 'registered' |
|
67 | + && $access !== 'hidden' && $access !== 'public' |
|
68 | + ) { |
|
69 | + $access = 'select'; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | ?> |
73 | 73 | |
74 | 74 | <div id="app"> |
@@ -27,22 +27,22 @@ discard block |
||
27 | 27 | \OCP\Util::addScript('polls', 'create_edit'); |
28 | 28 | \OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min'); |
29 | 29 | |
30 | - $userId = $_['userId']; |
|
30 | + $userId = $_[ 'userId' ]; |
|
31 | 31 | /** @var \OCP\IUserManager $userMgr */ |
32 | - $userMgr = $_['userMgr']; |
|
32 | + $userMgr = $_[ 'userMgr' ]; |
|
33 | 33 | /** @var \OCP\IURLGenerator $urlGenerator */ |
34 | - $urlGenerator = $_['urlGenerator']; |
|
35 | - $isUpdate = isset($_['poll']) && $_['poll'] !== null; |
|
34 | + $urlGenerator = $_[ 'urlGenerator' ]; |
|
35 | + $isUpdate = isset($_[ 'poll' ]) && $_[ 'poll' ] !== null; |
|
36 | 36 | $isAnonymous = false; |
37 | 37 | $hideNames = false; |
38 | 38 | |
39 | 39 | if ($isUpdate) { |
40 | 40 | /** @var OCA\Polls\Db\Event $poll */ |
41 | - $poll = $_['poll']; |
|
41 | + $poll = $_[ 'poll' ]; |
|
42 | 42 | $isAnonymous = $poll->getIsAnonymous(); |
43 | 43 | $hideNames = $isAnonymous && $poll->getFullAnonymous(); |
44 | 44 | /** @var OCA\Polls\Db\Date[]|OCA\Polls\Db\Text[] $dates */ |
45 | - $dates = $_['dates']; |
|
45 | + $dates = $_[ 'dates' ]; |
|
46 | 46 | $chosen = '['; |
47 | 47 | foreach ($dates as $d) { |
48 | 48 | if ($poll->getType() === 0) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $title = $poll->getTitle(); |
58 | 58 | $desc = $poll->getDescription(); |
59 | 59 | if ($poll->getExpire() !== null) { |
60 | - $expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day |
|
60 | + $expireTs = strtotime($poll->getExpire()) - 60 * 60 * 24; //remove one day, which has been added to expire at the end of a day |
|
61 | 61 | $expireStr = date('d.m.Y', $expireTs); |
62 | 62 | } |
63 | 63 | $access = $poll->getAccess(); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | <table id="selected-dates-table" class="choices"> |
172 | 172 | </table> |
173 | 173 | </div> |
174 | - <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() === 0) print_unescaped('style="display:none;"'); ?> > |
|
174 | + <div id="text-select-container" <?php if (!$isUpdate || $poll->getType() === 0) print_unescaped('style="display:none;"'); ?> > |
|
175 | 175 | <label for="text-title" class="input_title"><?php p($l->t('Text item')); ?></label> |
176 | 176 | <div class="input-group"> |
177 | 177 | <input type="text" id="text-title" placeholder="<?php print_unescaped('Insert text...'); ?>" /> |
@@ -85,8 +85,11 @@ discard block |
||
85 | 85 | <span> |
86 | 86 | <?php if ($isUpdate): ?> |
87 | 87 | <?php p($l->t('Edit poll') . ' ' . $poll->getTitle()); ?> |
88 | - <?php else: ?> |
|
89 | - <?php p($l->t('Create new poll')); ?> |
|
88 | + <?php else { |
|
89 | + : ?> |
|
90 | + <?php p($l->t('Create new poll')); |
|
91 | +} |
|
92 | +?> |
|
90 | 93 | <?php endif; ?> |
91 | 94 | </span> |
92 | 95 | </div> |
@@ -96,11 +99,20 @@ discard block |
||
96 | 99 | <?php if ($isUpdate): ?> |
97 | 100 | <form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.update_poll')); ?>" method="POST"> |
98 | 101 | <input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" /> |
99 | - <?php else: ?> |
|
100 | - <form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_poll')); ?>" method="POST"> |
|
102 | + <?php else { |
|
103 | + : ?> |
|
104 | + <form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_poll')); |
|
105 | +} |
|
106 | +?>" method="POST"> |
|
101 | 107 | <?php endif; ?> |
102 | - <input type="hidden" name="chosenDates" id="chosenDates" value="<?php if (isset($chosen)) p($chosen); ?>" /> |
|
103 | - <input type="hidden" name="expireTs" id="expireTs" value="<?php if (isset($expireTs)) p($expireTs); ?>" /> |
|
108 | + <input type="hidden" name="chosenDates" id="chosenDates" value="<?php if (isset($chosen)) { |
|
109 | + p($chosen); |
|
110 | +} |
|
111 | +?>" /> |
|
112 | + <input type="hidden" name="expireTs" id="expireTs" value="<?php if (isset($expireTs)) { |
|
113 | + p($expireTs); |
|
114 | +} |
|
115 | +?>" /> |
|
104 | 116 | <input type="hidden" name="userId" id="userId" value="<?php p($userId); ?>" /> |
105 | 117 | |
106 | 118 | <header class="row"> |
@@ -109,22 +121,40 @@ discard block |
||
109 | 121 | <div class="new_poll row"> |
110 | 122 | <div class="col-50"> |
111 | 123 | <label for="pollTitle" class="input_title"><?php p($l->t('Title')); ?></label> |
112 | - <input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if (isset($title)) p($title); ?>" /> |
|
124 | + <input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if (isset($title)) { |
|
125 | + p($title); |
|
126 | +} |
|
127 | +?>" /> |
|
113 | 128 | <label for="pollDesc" class="input_title"><?php p($l->t('Description')); ?></label> |
114 | - <textarea class="input_field" id="pollDesc" name="pollDesc"><?php if (isset($desc)) p($desc); ?></textarea> |
|
129 | + <textarea class="input_field" id="pollDesc" name="pollDesc"><?php if (isset($desc)) { |
|
130 | + p($desc); |
|
131 | +} |
|
132 | +?></textarea> |
|
115 | 133 | |
116 | 134 | <label class="input_title"><?php p($l->t('Access')); ?></label> |
117 | 135 | |
118 | - <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access === 'registered') print_unescaped('checked'); ?> /> |
|
136 | + <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access === 'registered') { |
|
137 | + print_unescaped('checked'); |
|
138 | +} |
|
139 | +?> /> |
|
119 | 140 | <label for="private"><?php p($l->t('Registered users only')); ?></label> |
120 | 141 | |
121 | - <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access === 'hidden') print_unescaped('checked'); ?> /> |
|
142 | + <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access === 'hidden') { |
|
143 | + print_unescaped('checked'); |
|
144 | +} |
|
145 | +?> /> |
|
122 | 146 | <label for="hidden"><?php p($l->t('hidden')); ?></label> |
123 | 147 | |
124 | - <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access === 'public') print_unescaped('checked'); ?> /> |
|
148 | + <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access === 'public') { |
|
149 | + print_unescaped('checked'); |
|
150 | +} |
|
151 | +?> /> |
|
125 | 152 | <label for="public"><?php p($l->t('Public access')); ?></label> |
126 | 153 | |
127 | - <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access === 'select') print_unescaped('checked'); ?>> |
|
154 | + <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access === 'select') { |
|
155 | + print_unescaped('checked'); |
|
156 | +} |
|
157 | +?>> |
|
128 | 158 | <label for="select"><?php p($l->t('Select')); ?></label> |
129 | 159 | <span id="id_label_select">...</span> |
130 | 160 | |
@@ -140,9 +170,12 @@ discard block |
||
140 | 170 | </div> |
141 | 171 | </div> |
142 | 172 | |
143 | - <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access === 'select') p($accessTypes) ?>" /> |
|
173 | + <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access === 'select') { |
|
174 | + p($accessTypes) ?>" /> |
|
144 | 175 | |
145 | - <input id="isAnonymous" name="isAnonymous" type="checkbox" class="checkbox" <?php $isAnonymous ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> /> |
|
176 | + <input id="isAnonymous" name="isAnonymous" type="checkbox" class="checkbox" <?php $isAnonymous ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); |
|
177 | +} |
|
178 | +?> /> |
|
146 | 179 | <label for="isAnonymous" class="input_title"><?php p($l->t('Anonymous')) ?></label> |
147 | 180 | |
148 | 181 | <div id="anonOptions" style="display:none;"> |
@@ -158,20 +191,32 @@ discard block |
||
158 | 191 | </div> |
159 | 192 | <div class="col-50"> |
160 | 193 | |
161 | - <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() === 0) print_unescaped('checked'); ?> /> |
|
194 | + <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() === 0) { |
|
195 | + print_unescaped('checked'); |
|
196 | +} |
|
197 | +?> /> |
|
162 | 198 | <label for="event"><?php p($l->t('Event schedule')); ?></label> |
163 | 199 | |
164 | 200 | <!-- TODO texts to db --> |
165 | - <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() === 1) print_unescaped('checked'); ?>> |
|
201 | + <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() === 1) { |
|
202 | + print_unescaped('checked'); |
|
203 | +} |
|
204 | +?>> |
|
166 | 205 | <label for="text"><?php p($l->t('Text based')); ?></label> |
167 | 206 | |
168 | - <div id="date-select-container" <?php if ($isUpdate && $poll->getType() === 1) print_unescaped('style="display:none;"'); ?> > |
|
207 | + <div id="date-select-container" <?php if ($isUpdate && $poll->getType() === 1) { |
|
208 | + print_unescaped('style="display:none;"'); |
|
209 | +} |
|
210 | +?> > |
|
169 | 211 | <label for="datetimepicker" class="input_title"><?php p($l->t('Dates')); ?></label> |
170 | 212 | <input id="datetimepicker" type="text" /> |
171 | 213 | <table id="selected-dates-table" class="choices"> |
172 | 214 | </table> |
173 | 215 | </div> |
174 | - <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() === 0) print_unescaped('style="display:none;"'); ?> > |
|
216 | + <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() === 0) { |
|
217 | + print_unescaped('style="display:none;"'); |
|
218 | +} |
|
219 | +?> > |
|
175 | 220 | <label for="text-title" class="input_title"><?php p($l->t('Text item')); ?></label> |
176 | 221 | <div class="input-group"> |
177 | 222 | <input type="text" id="text-title" placeholder="<?php print_unescaped('Insert text...'); ?>" /> |
@@ -187,8 +232,11 @@ discard block |
||
187 | 232 | <div class="form-actions"> |
188 | 233 | <?php if ($isUpdate): ?> |
189 | 234 | <input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Update poll')); ?>" /> |
190 | - <?php else: ?> |
|
191 | - <input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Create poll')); ?>" /> |
|
235 | + <?php else { |
|
236 | + : ?> |
|
237 | + <input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Create poll')); |
|
238 | +} |
|
239 | +?>" /> |
|
192 | 240 | <?php endif; ?> |
193 | 241 | <a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>" id="submit_cancel_poll" class="button"><?php p($l->t('Cancel')); ?></a> |
194 | 242 | </div> |
@@ -28,41 +28,41 @@ |
||
28 | 28 | |
29 | 29 | class CommentMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * CommentMapper constructor. |
|
33 | - * @param IDBConnection $db |
|
34 | - */ |
|
35 | - public function __construct(IDBConnection $db) { |
|
36 | - parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment'); |
|
37 | - } |
|
31 | + /** |
|
32 | + * CommentMapper constructor. |
|
33 | + * @param IDBConnection $db |
|
34 | + */ |
|
35 | + public function __construct(IDBConnection $db) { |
|
36 | + parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment'); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $userId |
|
41 | - * @param int $limit |
|
42 | - * @param int $offset |
|
43 | - * @return Comment[] |
|
44 | - */ |
|
45 | - public function findDistinctByUser($userId, $limit = null, $offset = null) { |
|
46 | - $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?'; |
|
47 | - return $this->findEntities($sql, [$userId], $limit, $offset); |
|
48 | - } |
|
39 | + /** |
|
40 | + * @param string $userId |
|
41 | + * @param int $limit |
|
42 | + * @param int $offset |
|
43 | + * @return Comment[] |
|
44 | + */ |
|
45 | + public function findDistinctByUser($userId, $limit = null, $offset = null) { |
|
46 | + $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?'; |
|
47 | + return $this->findEntities($sql, [$userId], $limit, $offset); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param int $pollId |
|
52 | - * @param int $limit |
|
53 | - * @param int $offset |
|
54 | - * @return Comment[] |
|
55 | - */ |
|
56 | - public function findByPoll($pollId, $limit = null, $offset = null) { |
|
57 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC'; |
|
58 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
59 | - } |
|
50 | + /** |
|
51 | + * @param int $pollId |
|
52 | + * @param int $limit |
|
53 | + * @param int $offset |
|
54 | + * @return Comment[] |
|
55 | + */ |
|
56 | + public function findByPoll($pollId, $limit = null, $offset = null) { |
|
57 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC'; |
|
58 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param int $pollId |
|
63 | - */ |
|
64 | - public function deleteByPoll($pollId) { |
|
65 | - $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
66 | - $this->execute($sql, [$pollId]); |
|
67 | - } |
|
61 | + /** |
|
62 | + * @param int $pollId |
|
63 | + */ |
|
64 | + public function deleteByPoll($pollId) { |
|
65 | + $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
66 | + $this->execute($sql, [$pollId]); |
|
67 | + } |
|
68 | 68 | } |
@@ -35,16 +35,16 @@ |
||
35 | 35 | * @method void setType(integer $value) |
36 | 36 | */ |
37 | 37 | class Participation extends Model { |
38 | - protected $dt; |
|
39 | - protected $userId; |
|
40 | - protected $pollId; |
|
41 | - protected $type; |
|
38 | + protected $dt; |
|
39 | + protected $userId; |
|
40 | + protected $pollId; |
|
41 | + protected $type; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Participation constructor. |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->addType('pollId', 'integer'); |
|
48 | - $this->addType('type', 'integer'); |
|
49 | - } |
|
43 | + /** |
|
44 | + * Participation constructor. |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->addType('pollId', 'integer'); |
|
48 | + $this->addType('type', 'integer'); |
|
49 | + } |
|
50 | 50 | } |
@@ -28,64 +28,64 @@ |
||
28 | 28 | |
29 | 29 | class NotificationMapper extends Mapper { |
30 | 30 | |
31 | - public function __construct(IDBConnection $db) { |
|
32 | - parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification'); |
|
33 | - } |
|
31 | + public function __construct(IDBConnection $db) { |
|
32 | + parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param int $id |
|
37 | - * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
38 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
39 | - * @return Notification |
|
40 | - */ |
|
41 | - public function find($id) { |
|
42 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
43 | - return $this->findEntity($sql, [$id]); |
|
44 | - } |
|
35 | + /** |
|
36 | + * @param int $id |
|
37 | + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
38 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
39 | + * @return Notification |
|
40 | + */ |
|
41 | + public function find($id) { |
|
42 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
43 | + return $this->findEntity($sql, [$id]); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $userId |
|
48 | - * @param string $from |
|
49 | - * @param string $until |
|
50 | - * @param int $limit |
|
51 | - * @param int $offset |
|
52 | - * @return Notification[] |
|
53 | - */ |
|
54 | - public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
|
55 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
|
56 | - return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
57 | - } |
|
46 | + /** |
|
47 | + * @param string $userId |
|
48 | + * @param string $from |
|
49 | + * @param string $until |
|
50 | + * @param int $limit |
|
51 | + * @param int $offset |
|
52 | + * @return Notification[] |
|
53 | + */ |
|
54 | + public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
|
55 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
|
56 | + return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param int $limit |
|
61 | - * @param int $offset |
|
62 | - * @return Notification[] |
|
63 | - */ |
|
64 | - public function findAll($limit = null, $offset = null) { |
|
65 | - $sql = 'SELECT * FROM ' . $this->getTableName(); |
|
66 | - return $this->findEntities($sql, [], $limit, $offset); |
|
67 | - } |
|
59 | + /** |
|
60 | + * @param int $limit |
|
61 | + * @param int $offset |
|
62 | + * @return Notification[] |
|
63 | + */ |
|
64 | + public function findAll($limit = null, $offset = null) { |
|
65 | + $sql = 'SELECT * FROM ' . $this->getTableName(); |
|
66 | + return $this->findEntities($sql, [], $limit, $offset); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param int $pollId |
|
71 | - * @param int $limit |
|
72 | - * @param int $offset |
|
73 | - * @return Notification[] |
|
74 | - */ |
|
75 | - public function findAllByPoll($pollId, $limit = null, $offset = null) { |
|
76 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
77 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
78 | - } |
|
69 | + /** |
|
70 | + * @param int $pollId |
|
71 | + * @param int $limit |
|
72 | + * @param int $offset |
|
73 | + * @return Notification[] |
|
74 | + */ |
|
75 | + public function findAllByPoll($pollId, $limit = null, $offset = null) { |
|
76 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
77 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param int $pollId |
|
82 | - * @param string $userId |
|
83 | - * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
84 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
85 | - * @return Notification |
|
86 | - */ |
|
87 | - public function findByUserAndPoll($pollId, $userId) { |
|
88 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
89 | - return $this->findEntity($sql, [$pollId, $userId]); |
|
90 | - } |
|
80 | + /** |
|
81 | + * @param int $pollId |
|
82 | + * @param string $userId |
|
83 | + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
84 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
85 | + * @return Notification |
|
86 | + */ |
|
87 | + public function findByUserAndPoll($pollId, $userId) { |
|
88 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
89 | + return $this->findEntity($sql, [$pollId, $userId]); |
|
90 | + } |
|
91 | 91 | } |