@@ -28,16 +28,16 @@ |
||
28 | 28 | |
29 | 29 | class AppTest extends TestCase { |
30 | 30 | |
31 | - private $container; |
|
31 | + private $container; |
|
32 | 32 | |
33 | - public function setUp() { |
|
34 | - parent::setUp(); |
|
35 | - $app = new App('polls'); |
|
36 | - $this->container = $app->getContainer(); |
|
37 | - } |
|
33 | + public function setUp() { |
|
34 | + parent::setUp(); |
|
35 | + $app = new App('polls'); |
|
36 | + $this->container = $app->getContainer(); |
|
37 | + } |
|
38 | 38 | |
39 | - public function testAppInstalled() { |
|
40 | - $appManager = $this->container->query('OCP\App\IAppManager'); |
|
41 | - $this->assertTrue($appManager->isInstalled('polls')); |
|
42 | - } |
|
39 | + public function testAppInstalled() { |
|
40 | + $appManager = $this->container->query('OCP\App\IAppManager'); |
|
41 | + $this->assertTrue($appManager->isInstalled('polls')); |
|
42 | + } |
|
43 | 43 | } |
@@ -29,77 +29,77 @@ |
||
29 | 29 | |
30 | 30 | class PageControllerTest extends PHPUnit_Framework_TestCase { |
31 | 31 | |
32 | - private $controller; |
|
33 | - private $userId = 'john'; |
|
32 | + private $controller; |
|
33 | + private $userId = 'john'; |
|
34 | 34 | |
35 | - public function setUp() { |
|
36 | - $request = $this->getMockBuilder('OCP\IRequest') |
|
37 | - ->disableOriginalConstructor() |
|
38 | - ->getMock(); |
|
39 | - $userManager = $this->getMockBuilder('OCP\IUserManager') |
|
40 | - ->disableOriginalConstructor() |
|
41 | - ->getMock(); |
|
42 | - $groupManager = $this->getMockBuilder('OCP\IGroupManager') |
|
43 | - ->disableOriginalConstructor() |
|
44 | - ->getMock(); |
|
45 | - $avatarManager = $this->getMockBuilder('OCP\IAvatarManager') |
|
46 | - ->disableOriginalConstructor() |
|
47 | - ->getMock(); |
|
48 | - $logger = $this->getMockBuilder('OCP\ILogger') |
|
49 | - ->disableOriginalConstructor() |
|
50 | - ->getMock(); |
|
51 | - $l10n = $this->getMockBuilder('OCP\IL10N') |
|
52 | - ->disableOriginalConstructor() |
|
53 | - ->getMock(); |
|
54 | - $urlGenerator = $this->getMockBuilder('OCP\IURLGenerator') |
|
55 | - ->disableOriginalConstructor() |
|
56 | - ->getMock(); |
|
57 | - $commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper') |
|
58 | - ->disableOriginalConstructor() |
|
59 | - ->getMock(); |
|
60 | - $dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper') |
|
61 | - ->disableOriginalConstructor() |
|
62 | - ->getMock(); |
|
63 | - $eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper') |
|
64 | - ->disableOriginalConstructor() |
|
65 | - ->getMock(); |
|
66 | - $notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper') |
|
67 | - ->disableOriginalConstructor() |
|
68 | - ->getMock(); |
|
69 | - $participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper') |
|
70 | - ->disableOriginalConstructor() |
|
71 | - ->getMock(); |
|
72 | - $participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper') |
|
73 | - ->disableOriginalConstructor() |
|
74 | - ->getMock(); |
|
75 | - $textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper') |
|
76 | - ->disableOriginalConstructor() |
|
77 | - ->getMock(); |
|
35 | + public function setUp() { |
|
36 | + $request = $this->getMockBuilder('OCP\IRequest') |
|
37 | + ->disableOriginalConstructor() |
|
38 | + ->getMock(); |
|
39 | + $userManager = $this->getMockBuilder('OCP\IUserManager') |
|
40 | + ->disableOriginalConstructor() |
|
41 | + ->getMock(); |
|
42 | + $groupManager = $this->getMockBuilder('OCP\IGroupManager') |
|
43 | + ->disableOriginalConstructor() |
|
44 | + ->getMock(); |
|
45 | + $avatarManager = $this->getMockBuilder('OCP\IAvatarManager') |
|
46 | + ->disableOriginalConstructor() |
|
47 | + ->getMock(); |
|
48 | + $logger = $this->getMockBuilder('OCP\ILogger') |
|
49 | + ->disableOriginalConstructor() |
|
50 | + ->getMock(); |
|
51 | + $l10n = $this->getMockBuilder('OCP\IL10N') |
|
52 | + ->disableOriginalConstructor() |
|
53 | + ->getMock(); |
|
54 | + $urlGenerator = $this->getMockBuilder('OCP\IURLGenerator') |
|
55 | + ->disableOriginalConstructor() |
|
56 | + ->getMock(); |
|
57 | + $commentMapper = $this->getMockBuilder('OCA\Polls\Db\CommentMapper') |
|
58 | + ->disableOriginalConstructor() |
|
59 | + ->getMock(); |
|
60 | + $dateMapper = $this->getMockBuilder('OCA\Polls\Db\DateMapper') |
|
61 | + ->disableOriginalConstructor() |
|
62 | + ->getMock(); |
|
63 | + $eventMapper = $this->getMockBuilder('OCA\Polls\Db\EventMapper') |
|
64 | + ->disableOriginalConstructor() |
|
65 | + ->getMock(); |
|
66 | + $notificationMapper = $this->getMockBuilder('OCA\Polls\Db\NotificationMapper') |
|
67 | + ->disableOriginalConstructor() |
|
68 | + ->getMock(); |
|
69 | + $participationMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationMapper') |
|
70 | + ->disableOriginalConstructor() |
|
71 | + ->getMock(); |
|
72 | + $participationTextMapper = $this->getMockBuilder('OCA\Polls\Db\ParticipationTextMapper') |
|
73 | + ->disableOriginalConstructor() |
|
74 | + ->getMock(); |
|
75 | + $textMapper = $this->getMockBuilder('OCA\Polls\Db\TextMapper') |
|
76 | + ->disableOriginalConstructor() |
|
77 | + ->getMock(); |
|
78 | 78 | |
79 | - $this->controller = new PageController( |
|
80 | - 'polls', |
|
81 | - $request, |
|
82 | - $userManager, |
|
83 | - $groupManager, |
|
84 | - $avatarManager, |
|
85 | - $logger, |
|
86 | - $l10n, |
|
87 | - $urlGenerator, |
|
88 | - $this->userId, |
|
89 | - $commentMapper, |
|
90 | - $dateMapper, |
|
91 | - $eventMapper, |
|
92 | - $notificationMapper, |
|
93 | - $participationMapper, |
|
94 | - $participationTextMapper, |
|
95 | - $textMapper |
|
96 | - ); |
|
97 | - } |
|
79 | + $this->controller = new PageController( |
|
80 | + 'polls', |
|
81 | + $request, |
|
82 | + $userManager, |
|
83 | + $groupManager, |
|
84 | + $avatarManager, |
|
85 | + $logger, |
|
86 | + $l10n, |
|
87 | + $urlGenerator, |
|
88 | + $this->userId, |
|
89 | + $commentMapper, |
|
90 | + $dateMapper, |
|
91 | + $eventMapper, |
|
92 | + $notificationMapper, |
|
93 | + $participationMapper, |
|
94 | + $participationTextMapper, |
|
95 | + $textMapper |
|
96 | + ); |
|
97 | + } |
|
98 | 98 | |
99 | - public function testIndex() { |
|
100 | - $result = $this->controller->index(); |
|
99 | + public function testIndex() { |
|
100 | + $result = $this->controller->index(); |
|
101 | 101 | |
102 | - $this->assertEquals('main.tmpl', $result->getTemplateName()); |
|
103 | - $this->assertTrue($result instanceof TemplateResponse); |
|
104 | - } |
|
102 | + $this->assertEquals('main.tmpl', $result->getTemplateName()); |
|
103 | + $this->assertTrue($result instanceof TemplateResponse); |
|
104 | + } |
|
105 | 105 | } |
@@ -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'); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | \OC_App::loadApp('polls'); |
35 | 35 | |
36 | 36 | if (!class_exists('PHPUnit_Framework_TestCase')) { |
37 | - require_once('PHPUnit/Autoload.php'); |
|
37 | + require_once('PHPUnit/Autoload.php'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | OC_Hook::clear(); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | define('PHPUNIT_RUN', 1); |
26 | 26 | } |
27 | 27 | |
28 | -require_once(__DIR__.'/../../../lib/base.php'); |
|
28 | +require_once(__DIR__ . '/../../../lib/base.php'); |
|
29 | 29 | |
30 | 30 | // Fix for "Autoload path not allowed: .../tests/lib/testcase.php" |
31 | 31 | \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
@@ -1,35 +1,35 @@ discard block |
||
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 | - */ |
|
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 | 23 | |
24 | - use OCP\User; |
|
24 | + use OCP\User; |
|
25 | 25 | |
26 | - \OCP\Util::addStyle('polls', 'main'); |
|
27 | - \OCP\Util::addStyle('polls', 'list'); |
|
28 | - \OCP\Util::addScript('polls', 'start'); |
|
26 | + \OCP\Util::addStyle('polls', 'main'); |
|
27 | + \OCP\Util::addStyle('polls', 'list'); |
|
28 | + \OCP\Util::addScript('polls', 'start'); |
|
29 | 29 | |
30 | - $userId = $_['userId']; |
|
31 | - $userMgr = $_['userMgr']; |
|
32 | - $urlGenerator = $_['urlGenerator']; |
|
30 | + $userId = $_['userId']; |
|
31 | + $userMgr = $_['userMgr']; |
|
32 | + $urlGenerator = $_['urlGenerator']; |
|
33 | 33 | ?> |
34 | 34 | <div id="app-content"> |
35 | 35 | <div id="app-content-wrapper"> |
@@ -83,61 +83,61 @@ discard block |
||
83 | 83 | |
84 | 84 | <?php foreach ($_['polls'] as $poll) : ?> |
85 | 85 | <?php |
86 | - if (!userHasAccess($poll, $userId)) continue; |
|
87 | - // direct url to poll |
|
88 | - $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash())); |
|
89 | - $owner = $poll->getOwner(); |
|
86 | + if (!userHasAccess($poll, $userId)) continue; |
|
87 | + // direct url to poll |
|
88 | + $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash())); |
|
89 | + $owner = $poll->getOwner(); |
|
90 | 90 | |
91 | - $expiry_style = ''; |
|
92 | - if ($poll->getType() == '0') { |
|
93 | - $participated = $_['participations']; |
|
94 | - } else { |
|
95 | - $participated = $_['participations_text']; |
|
96 | - } |
|
97 | - $participated_class = 'partic_no'; |
|
98 | - $participated_title = 'You did not vote'; |
|
99 | - $participated_count = count($participated); |
|
91 | + $expiry_style = ''; |
|
92 | + if ($poll->getType() == '0') { |
|
93 | + $participated = $_['participations']; |
|
94 | + } else { |
|
95 | + $participated = $_['participations_text']; |
|
96 | + } |
|
97 | + $participated_class = 'partic_no'; |
|
98 | + $participated_title = 'You did not vote'; |
|
99 | + $participated_count = count($participated); |
|
100 | 100 | |
101 | - $comments = $_['comments']; |
|
102 | - $commented_class = 'commented_no'; |
|
103 | - $commented_title = 'You did not comment'; |
|
104 | - $commented_count = count($comments); |
|
101 | + $comments = $_['comments']; |
|
102 | + $commented_class = 'commented_no'; |
|
103 | + $commented_title = 'You did not comment'; |
|
104 | + $commented_count = count($comments); |
|
105 | 105 | |
106 | - if ($owner == $userId) { |
|
107 | - $owner = $l->t('Yourself'); |
|
108 | - } |
|
106 | + if ($owner == $userId) { |
|
107 | + $owner = $l->t('Yourself'); |
|
108 | + } |
|
109 | 109 | |
110 | - if ($poll->getExpire() != null) { |
|
111 | - // $expiry_date = date('d.m.Y', strtotime($poll->getExpire())); |
|
112 | - $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); // does not work, because relative_modified_date seems not to recognise future time diffs |
|
113 | - $expiry_style = ' progress'; |
|
114 | - if (date('U') > strtotime($poll->getExpire())) { |
|
115 | - $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); |
|
116 | - $expiry_style = ' expired'; |
|
117 | - } |
|
118 | - } else { |
|
119 | - $expiry_style = ' endless'; |
|
120 | - $expiry_date = $l->t('Never'); |
|
121 | - } |
|
110 | + if ($poll->getExpire() != null) { |
|
111 | + // $expiry_date = date('d.m.Y', strtotime($poll->getExpire())); |
|
112 | + $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); // does not work, because relative_modified_date seems not to recognise future time diffs |
|
113 | + $expiry_style = ' progress'; |
|
114 | + if (date('U') > strtotime($poll->getExpire())) { |
|
115 | + $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); |
|
116 | + $expiry_style = ' expired'; |
|
117 | + } |
|
118 | + } else { |
|
119 | + $expiry_style = ' endless'; |
|
120 | + $expiry_date = $l->t('Never'); |
|
121 | + } |
|
122 | 122 | |
123 | - for ($i = 0; $i < count($participated); $i++) { |
|
124 | - if ($poll->getId() == intval($participated[$i]->getPollId())) { |
|
125 | - $participated_class = 'partic_yes'; |
|
126 | - $participated_title = 'You voted'; |
|
127 | - array_splice($participated, $i, 1); |
|
128 | - break; |
|
129 | - } |
|
130 | - } |
|
123 | + for ($i = 0; $i < count($participated); $i++) { |
|
124 | + if ($poll->getId() == intval($participated[$i]->getPollId())) { |
|
125 | + $participated_class = 'partic_yes'; |
|
126 | + $participated_title = 'You voted'; |
|
127 | + array_splice($participated, $i, 1); |
|
128 | + break; |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - for ($i = 0; $i < count($comments); $i++) { |
|
133 | - if ($poll->getId() == intval($comments[$i]->getPollId())) { |
|
134 | - $commented_class = 'commented_yes'; |
|
135 | - $commented_title = 'You commented'; |
|
136 | - array_splice($comments, $i, 1); |
|
137 | - break; |
|
138 | - } |
|
139 | - } |
|
140 | - ?> |
|
132 | + for ($i = 0; $i < count($comments); $i++) { |
|
133 | + if ($poll->getId() == intval($comments[$i]->getPollId())) { |
|
134 | + $commented_class = 'commented_yes'; |
|
135 | + $commented_title = 'You commented'; |
|
136 | + array_splice($comments, $i, 1); |
|
137 | + break; |
|
138 | + } |
|
139 | + } |
|
140 | + ?> |
|
141 | 141 | |
142 | 142 | |
143 | 143 | <div class="row table-body"> |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | * @return array with groups |
214 | 214 | */ |
215 | 215 | function getGroups($userId) { |
216 | - // $this->requireLogin(); |
|
217 | - if (class_exists('\OC_Group', true)) { |
|
218 | - // Nextcloud <= 11, ownCloud |
|
219 | - return \OC_Group::getUserGroups($userId); |
|
220 | - } |
|
221 | - // Nextcloud >= 12 |
|
222 | - $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser()); |
|
223 | - return array_map(function ($group) { |
|
224 | - return $group->getGID(); |
|
225 | - }, $groups); |
|
216 | + // $this->requireLogin(); |
|
217 | + if (class_exists('\OC_Group', true)) { |
|
218 | + // Nextcloud <= 11, ownCloud |
|
219 | + return \OC_Group::getUserGroups($userId); |
|
220 | + } |
|
221 | + // Nextcloud >= 12 |
|
222 | + $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser()); |
|
223 | + return array_map(function ($group) { |
|
224 | + return $group->getGID(); |
|
225 | + }, $groups); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -231,42 +231,42 @@ discard block |
||
231 | 231 | * @return boolean |
232 | 232 | */ |
233 | 233 | function userHasAccess($poll, $userId) { |
234 | - if ($poll == null) { |
|
235 | - return false; |
|
236 | - } |
|
237 | - $access = $poll->getAccess(); |
|
238 | - $owner = $poll->getOwner(); |
|
239 | - if (!User::isLoggedIn()) { |
|
240 | - return false; |
|
241 | - } |
|
242 | - if ($access == 'public') { |
|
243 | - return true; |
|
244 | - } |
|
245 | - if ($access == 'hidden') { |
|
246 | - return true; |
|
247 | - } |
|
248 | - if ($access == 'registered') { |
|
249 | - return true; |
|
250 | - } |
|
251 | - if ($owner == $userId) { |
|
252 | - return true; |
|
253 | - } |
|
254 | - $user_groups = getGroups($userId); |
|
234 | + if ($poll == null) { |
|
235 | + return false; |
|
236 | + } |
|
237 | + $access = $poll->getAccess(); |
|
238 | + $owner = $poll->getOwner(); |
|
239 | + if (!User::isLoggedIn()) { |
|
240 | + return false; |
|
241 | + } |
|
242 | + if ($access == 'public') { |
|
243 | + return true; |
|
244 | + } |
|
245 | + if ($access == 'hidden') { |
|
246 | + return true; |
|
247 | + } |
|
248 | + if ($access == 'registered') { |
|
249 | + return true; |
|
250 | + } |
|
251 | + if ($owner == $userId) { |
|
252 | + return true; |
|
253 | + } |
|
254 | + $user_groups = getGroups($userId); |
|
255 | 255 | |
256 | - $arr = explode(';', $access); |
|
256 | + $arr = explode(';', $access); |
|
257 | 257 | |
258 | - foreach ($arr as $item) { |
|
259 | - if (strpos($item, 'group_') == 0) { |
|
260 | - $grp = substr($item, 6); |
|
261 | - foreach ($user_groups as $user_group) { |
|
262 | - if ($user_group == $grp) return true; |
|
263 | - } |
|
264 | - } |
|
265 | - else if (strpos($item, 'user_') == 0) { |
|
266 | - $usr = substr($item, 5); |
|
267 | - if ($usr == $userId) return true; |
|
268 | - } |
|
269 | - } |
|
270 | - return false; |
|
258 | + foreach ($arr as $item) { |
|
259 | + if (strpos($item, 'group_') == 0) { |
|
260 | + $grp = substr($item, 6); |
|
261 | + foreach ($user_groups as $user_group) { |
|
262 | + if ($user_group == $grp) return true; |
|
263 | + } |
|
264 | + } |
|
265 | + else if (strpos($item, 'user_') == 0) { |
|
266 | + $usr = substr($item, 5); |
|
267 | + if ($usr == $userId) return true; |
|
268 | + } |
|
269 | + } |
|
270 | + return false; |
|
271 | 271 | } |
272 | 272 | ?> |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | \OCP\Util::addStyle('polls', 'list'); |
28 | 28 | \OCP\Util::addScript('polls', 'start'); |
29 | 29 | |
30 | - $userId = $_['userId']; |
|
31 | - $userMgr = $_['userMgr']; |
|
32 | - $urlGenerator = $_['urlGenerator']; |
|
30 | + $userId = $_[ 'userId' ]; |
|
31 | + $userMgr = $_[ 'userMgr' ]; |
|
32 | + $urlGenerator = $_[ 'urlGenerator' ]; |
|
33 | 33 | ?> |
34 | 34 | <div id="app-content"> |
35 | 35 | <div id="app-content-wrapper"> |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | <input class="stop icon-close" style="display:none" value="" type="button"> |
49 | 49 | </div> |
50 | 50 | </div> |
51 | - <?php if (count($_['polls']) == 0) : ?> |
|
51 | + <?php if (count($_[ 'polls' ]) == 0) : ?> |
|
52 | 52 | <div id="emptycontent" class=""> |
53 | 53 | <div class="icon-polls"></div> |
54 | 54 | <h2><?php p($l->t('No existing polls.')); ?></h2> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | </div> |
82 | 82 | </div> |
83 | 83 | |
84 | - <?php foreach ($_['polls'] as $poll) : ?> |
|
84 | + <?php foreach ($_[ 'polls' ] as $poll) : ?> |
|
85 | 85 | <?php |
86 | 86 | if (!userHasAccess($poll, $userId)) continue; |
87 | 87 | // direct url to poll |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | |
91 | 91 | $expiry_style = ''; |
92 | 92 | if ($poll->getType() == '0') { |
93 | - $participated = $_['participations']; |
|
93 | + $participated = $_[ 'participations' ]; |
|
94 | 94 | } else { |
95 | - $participated = $_['participations_text']; |
|
95 | + $participated = $_[ 'participations_text' ]; |
|
96 | 96 | } |
97 | 97 | $participated_class = 'partic_no'; |
98 | 98 | $participated_title = 'You did not vote'; |
99 | 99 | $participated_count = count($participated); |
100 | 100 | |
101 | - $comments = $_['comments']; |
|
101 | + $comments = $_[ 'comments' ]; |
|
102 | 102 | $commented_class = 'commented_no'; |
103 | 103 | $commented_title = 'You did not comment'; |
104 | 104 | $commented_count = count($comments); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | for ($i = 0; $i < count($participated); $i++) { |
124 | - if ($poll->getId() == intval($participated[$i]->getPollId())) { |
|
124 | + if ($poll->getId() == intval($participated[ $i ]->getPollId())) { |
|
125 | 125 | $participated_class = 'partic_yes'; |
126 | 126 | $participated_title = 'You voted'; |
127 | 127 | array_splice($participated, $i, 1); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | for ($i = 0; $i < count($comments); $i++) { |
133 | - if ($poll->getId() == intval($comments[$i]->getPollId())) { |
|
133 | + if ($poll->getId() == intval($comments[ $i ]->getPollId())) { |
|
134 | 134 | $commented_class = 'commented_yes'; |
135 | 135 | $commented_title = 'You commented'; |
136 | 136 | array_splice($comments, $i, 1); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | <div class="row table-body"> |
144 | 144 | <div class="wrapper group-master"> |
145 | 145 | <div class="wrapper group-1"> |
146 | - <div class="thumbnail <?php p($expiry_style . " " . $commented_class. " " . $participated_class); ?>"></div> <!-- Image to display status or type of poll */ --> |
|
146 | + <div class="thumbnail <?php p($expiry_style . " " . $commented_class . " " . $participated_class); ?>"></div> <!-- Image to display status or type of poll */ --> |
|
147 | 147 | <a href="<?php p($pollUrl); ?>" class="wrapper group-1-1"> |
148 | 148 | <div class="column name"> <?php p($poll->getTitle()); ?></div> |
149 | 149 | <div class="column description"> <?php p($poll->getDescription()); ?></div> |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | </button> |
167 | 167 | </li> |
168 | 168 | <li> |
169 | - <a href="<?php p($urlGenerator->linkToRoute('polls.page.edit_poll', ['hash' => $poll->getHash()])); ?>" class="menuitem action permanent" id="id_edit_<?php p($poll->getId()); ?>"> |
|
169 | + <a href="<?php p($urlGenerator->linkToRoute('polls.page.edit_poll', [ 'hash' => $poll->getHash() ])); ?>" class="menuitem action permanent" id="id_edit_<?php p($poll->getId()); ?>"> |
|
170 | 170 | <span class="icon-rename"></span> |
171 | 171 | <span>Edit Poll</span> |
172 | 172 | </a> |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | // Nextcloud >= 12 |
222 | 222 | $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser()); |
223 | - return array_map(function ($group) { |
|
223 | + return array_map(function($group) { |
|
224 | 224 | return $group->getGID(); |
225 | 225 | }, $groups); |
226 | 226 | } |
@@ -53,14 +53,17 @@ discard block |
||
53 | 53 | <div class="icon-polls"></div> |
54 | 54 | <h2><?php p($l->t('No existing polls.')); ?></h2> |
55 | 55 | </div> |
56 | - <?php else : ?> |
|
56 | + <?php else { |
|
57 | + : ?> |
|
57 | 58 | <div class="table has-controls"> |
58 | 59 | <div class ="row table-header"> |
59 | 60 | |
60 | 61 | <div class="wrapper group-master"> |
61 | 62 | <div class="wrapper group-1"> |
62 | 63 | <div class="wrapper group-1-1"> |
63 | - <div class="column name"> <?php p($l->t('Title')); ?></div> |
|
64 | + <div class="column name"> <?php p($l->t('Title')); |
|
65 | +} |
|
66 | +?></div> |
|
64 | 67 | <div class="column description"></div> |
65 | 68 | </div> |
66 | 69 | <div class="wrapper group-1-2"> |
@@ -83,7 +86,9 @@ discard block |
||
83 | 86 | |
84 | 87 | <?php foreach ($_['polls'] as $poll) : ?> |
85 | 88 | <?php |
86 | - if (!userHasAccess($poll, $userId)) continue; |
|
89 | + if (!userHasAccess($poll, $userId)) { |
|
90 | + continue; |
|
91 | + } |
|
87 | 92 | // direct url to poll |
88 | 93 | $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash())); |
89 | 94 | $owner = $poll->getOwner(); |
@@ -259,12 +264,15 @@ discard block |
||
259 | 264 | if (strpos($item, 'group_') == 0) { |
260 | 265 | $grp = substr($item, 6); |
261 | 266 | foreach ($user_groups as $user_group) { |
262 | - if ($user_group == $grp) return true; |
|
267 | + if ($user_group == $grp) { |
|
268 | + return true; |
|
269 | + } |
|
263 | 270 | } |
264 | - } |
|
265 | - else if (strpos($item, 'user_') == 0) { |
|
271 | + } else if (strpos($item, 'user_') == 0) { |
|
266 | 272 | $usr = substr($item, 5); |
267 | - if ($usr == $userId) return true; |
|
273 | + if ($usr == $userId) { |
|
274 | + return true; |
|
275 | + } |
|
268 | 276 | } |
269 | 277 | } |
270 | 278 | return false; |
@@ -80,8 +80,11 @@ discard block |
||
80 | 80 | <span> |
81 | 81 | <?php if ($isUpdate): ?> |
82 | 82 | <?php p($l->t('Edit poll') . ' ' . $poll->getTitle()); ?> |
83 | - <?php else: ?> |
|
84 | - <?php p($l->t('Create new poll')); ?> |
|
83 | + <?php else { |
|
84 | + : ?> |
|
85 | + <?php p($l->t('Create new poll')); |
|
86 | +} |
|
87 | +?> |
|
85 | 88 | <?php endif; ?> |
86 | 89 | </span> |
87 | 90 | </div> |
@@ -91,11 +94,20 @@ discard block |
||
91 | 94 | <?php if ($isUpdate): ?> |
92 | 95 | <form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.update_poll')); ?>" method="POST"> |
93 | 96 | <input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" /> |
94 | - <?php else: ?> |
|
95 | - <form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_poll')); ?>" method="POST"> |
|
97 | + <?php else { |
|
98 | + : ?> |
|
99 | + <form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_poll')); |
|
100 | +} |
|
101 | +?>" method="POST"> |
|
96 | 102 | <?php endif; ?> |
97 | - <input type="hidden" name="chosenDates" id="chosenDates" value="<?php if (isset($chosen)) p($chosen); ?>" /> |
|
98 | - <input type="hidden" name="expireTs" id="expireTs" value="<?php if (isset($expireTs)) p($expireTs); ?>" /> |
|
103 | + <input type="hidden" name="chosenDates" id="chosenDates" value="<?php if (isset($chosen)) { |
|
104 | + p($chosen); |
|
105 | +} |
|
106 | +?>" /> |
|
107 | + <input type="hidden" name="expireTs" id="expireTs" value="<?php if (isset($expireTs)) { |
|
108 | + p($expireTs); |
|
109 | +} |
|
110 | +?>" /> |
|
99 | 111 | <input type="hidden" name="userId" id="userId" value="<?php p($userId); ?>" /> |
100 | 112 | |
101 | 113 | <header class="row"> |
@@ -104,22 +116,40 @@ discard block |
||
104 | 116 | <div class="new_poll row"> |
105 | 117 | <div class="col-50"> |
106 | 118 | <label for="pollTitle" class="input_title"><?php p($l->t('Title')); ?></label> |
107 | - <input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if (isset($title)) p($title); ?>" /> |
|
119 | + <input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if (isset($title)) { |
|
120 | + p($title); |
|
121 | +} |
|
122 | +?>" /> |
|
108 | 123 | <label for="pollDesc" class="input_title"><?php p($l->t('Description')); ?></label> |
109 | - <textarea class="input_field" id="pollDesc" name="pollDesc"><?php if (isset($desc)) p($desc); ?></textarea> |
|
124 | + <textarea class="input_field" id="pollDesc" name="pollDesc"><?php if (isset($desc)) { |
|
125 | + p($desc); |
|
126 | +} |
|
127 | +?></textarea> |
|
110 | 128 | |
111 | 129 | <label class="input_title"><?php p($l->t('Access')); ?></label> |
112 | 130 | |
113 | - <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access == 'registered') print_unescaped('checked'); ?> /> |
|
131 | + <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access == 'registered') { |
|
132 | + print_unescaped('checked'); |
|
133 | +} |
|
134 | +?> /> |
|
114 | 135 | <label for="private"><?php p($l->t('Registered users only')); ?></label> |
115 | 136 | |
116 | - <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access == 'hidden') print_unescaped('checked'); ?> /> |
|
137 | + <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access == 'hidden') { |
|
138 | + print_unescaped('checked'); |
|
139 | +} |
|
140 | +?> /> |
|
117 | 141 | <label for="hidden"><?php p($l->t('hidden')); ?></label> |
118 | 142 | |
119 | - <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access == 'public') print_unescaped('checked'); ?> /> |
|
143 | + <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access == 'public') { |
|
144 | + print_unescaped('checked'); |
|
145 | +} |
|
146 | +?> /> |
|
120 | 147 | <label for="public"><?php p($l->t('Public access')); ?></label> |
121 | 148 | |
122 | - <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access == 'select') print_unescaped('checked'); ?>> |
|
149 | + <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access == 'select') { |
|
150 | + print_unescaped('checked'); |
|
151 | +} |
|
152 | +?>> |
|
123 | 153 | <label for="select"><?php p($l->t('Select')); ?></label> |
124 | 154 | <span id="id_label_select">...</span> |
125 | 155 | |
@@ -135,9 +165,12 @@ discard block |
||
135 | 165 | </div> |
136 | 166 | </div> |
137 | 167 | |
138 | - <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access == 'select') p($accessTypes) ?>" /> |
|
168 | + <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access == 'select') { |
|
169 | + p($accessTypes) ?>" /> |
|
139 | 170 | |
140 | - <input id="isAnonymous" name="isAnonymous" type="checkbox" class="checkbox" <?php $isAnonymous ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> /> |
|
171 | + <input id="isAnonymous" name="isAnonymous" type="checkbox" class="checkbox" <?php $isAnonymous ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); |
|
172 | +} |
|
173 | +?> /> |
|
141 | 174 | <label for="isAnonymous" class="input_title"><?php p($l->t('Anonymous')) ?></label> |
142 | 175 | |
143 | 176 | <div id="anonOptions" style="display:none;"> |
@@ -153,20 +186,32 @@ discard block |
||
153 | 186 | </div> |
154 | 187 | <div class="col-50"> |
155 | 188 | |
156 | - <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() == '0') print_unescaped('checked'); ?> /> |
|
189 | + <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() == '0') { |
|
190 | + print_unescaped('checked'); |
|
191 | +} |
|
192 | +?> /> |
|
157 | 193 | <label for="event"><?php p($l->t('Event schedule')); ?></label> |
158 | 194 | |
159 | 195 | <!-- TODO texts to db --> |
160 | - <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() == '1') print_unescaped('checked'); ?>> |
|
196 | + <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() == '1') { |
|
197 | + print_unescaped('checked'); |
|
198 | +} |
|
199 | +?>> |
|
161 | 200 | <label for="text"><?php p($l->t('Text based')); ?></label> |
162 | 201 | |
163 | - <div id="date-select-container" <?php if ($isUpdate && $poll->getType() == '1') print_unescaped('style="display:none;"'); ?> > |
|
202 | + <div id="date-select-container" <?php if ($isUpdate && $poll->getType() == '1') { |
|
203 | + print_unescaped('style="display:none;"'); |
|
204 | +} |
|
205 | +?> > |
|
164 | 206 | <label for="datetimepicker" class="input_title"><?php p($l->t('Dates')); ?></label> |
165 | 207 | <input id="datetimepicker" type="text" /> |
166 | 208 | <table id="selected-dates-table" class="choices"> |
167 | 209 | </table> |
168 | 210 | </div> |
169 | - <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() == '0') print_unescaped('style="display:none;"'); ?> > |
|
211 | + <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() == '0') { |
|
212 | + print_unescaped('style="display:none;"'); |
|
213 | +} |
|
214 | +?> > |
|
170 | 215 | <label for="text-title" class="input_title"><?php p($l->t('Text item')); ?></label> |
171 | 216 | <div class="input-group"> |
172 | 217 | <input type="text" id="text-title" placeholder="<?php print_unescaped('Insert text...'); ?>" /> |
@@ -182,8 +227,11 @@ discard block |
||
182 | 227 | <div class="form-actions"> |
183 | 228 | <?php if ($isUpdate): ?> |
184 | 229 | <input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Update poll')); ?>" /> |
185 | - <?php else: ?> |
|
186 | - <input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Create poll')); ?>" /> |
|
230 | + <?php else { |
|
231 | + : ?> |
|
232 | + <input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Create poll')); |
|
233 | +} |
|
234 | +?>" /> |
|
187 | 235 | <?php endif; ?> |
188 | 236 | <a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>" id="submit_cancel_poll" class="button"><?php p($l->t('Cancel')); ?></a> |
189 | 237 | </div> |
@@ -1,69 +1,69 @@ |
||
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', 'jquery.datetimepicker'); |
|
27 | - \OCP\Util::addScript('polls', 'create_edit'); |
|
28 | - \OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min'); |
|
29 | - |
|
30 | - $userId = $_['userId']; |
|
31 | - $userMgr = $_['userMgr']; |
|
32 | - $urlGenerator = $_['urlGenerator']; |
|
33 | - $isUpdate = isset($_['poll']) && $_['poll'] != null; |
|
34 | - $isAnonymous = false; |
|
35 | - $hideNames = false; |
|
36 | - |
|
37 | - if ($isUpdate) { |
|
38 | - $poll = $_['poll']; |
|
39 | - $isAnonymous = $poll->getIsAnonymous(); |
|
40 | - $hideNames = $isAnonymous && $poll->getFullAnonymous(); |
|
41 | - $dates = $_['dates']; |
|
42 | - $chosen = '['; |
|
43 | - foreach ($dates as $d) { |
|
44 | - if ($poll->getType() == '0') { |
|
45 | - $chosen .= strtotime($d->getDt()); |
|
46 | - } else { |
|
47 | - $chosen .= '"' . $d->getText() . '"'; |
|
48 | - } |
|
49 | - $chosen .= ','; |
|
50 | - } |
|
51 | - $chosen = trim($chosen, ','); |
|
52 | - $chosen .= ']'; |
|
53 | - $title = $poll->getTitle(); |
|
54 | - $desc = $poll->getDescription(); |
|
55 | - if ($poll->getExpire() != null) { |
|
56 | - $expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day |
|
57 | - $expireStr = date('d.m.Y', $expireTs); |
|
58 | - } |
|
59 | - $access = $poll->getAccess(); |
|
60 | - $accessTypes = $access; |
|
61 | - if ( $access != 'registered' |
|
62 | - && $access != 'hidden' && $access != 'public' |
|
63 | - ) { |
|
64 | - $access = 'select'; |
|
65 | - } |
|
66 | - } |
|
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', 'jquery.datetimepicker'); |
|
27 | + \OCP\Util::addScript('polls', 'create_edit'); |
|
28 | + \OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min'); |
|
29 | + |
|
30 | + $userId = $_['userId']; |
|
31 | + $userMgr = $_['userMgr']; |
|
32 | + $urlGenerator = $_['urlGenerator']; |
|
33 | + $isUpdate = isset($_['poll']) && $_['poll'] != null; |
|
34 | + $isAnonymous = false; |
|
35 | + $hideNames = false; |
|
36 | + |
|
37 | + if ($isUpdate) { |
|
38 | + $poll = $_['poll']; |
|
39 | + $isAnonymous = $poll->getIsAnonymous(); |
|
40 | + $hideNames = $isAnonymous && $poll->getFullAnonymous(); |
|
41 | + $dates = $_['dates']; |
|
42 | + $chosen = '['; |
|
43 | + foreach ($dates as $d) { |
|
44 | + if ($poll->getType() == '0') { |
|
45 | + $chosen .= strtotime($d->getDt()); |
|
46 | + } else { |
|
47 | + $chosen .= '"' . $d->getText() . '"'; |
|
48 | + } |
|
49 | + $chosen .= ','; |
|
50 | + } |
|
51 | + $chosen = trim($chosen, ','); |
|
52 | + $chosen .= ']'; |
|
53 | + $title = $poll->getTitle(); |
|
54 | + $desc = $poll->getDescription(); |
|
55 | + if ($poll->getExpire() != null) { |
|
56 | + $expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day |
|
57 | + $expireStr = date('d.m.Y', $expireTs); |
|
58 | + } |
|
59 | + $access = $poll->getAccess(); |
|
60 | + $accessTypes = $access; |
|
61 | + if ( $access != 'registered' |
|
62 | + && $access != 'hidden' && $access != 'public' |
|
63 | + ) { |
|
64 | + $access = 'select'; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | ?> |
68 | 68 | |
69 | 69 | <div id="app"> |
@@ -27,18 +27,18 @@ 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']; |
|
31 | - $userMgr = $_['userMgr']; |
|
32 | - $urlGenerator = $_['urlGenerator']; |
|
33 | - $isUpdate = isset($_['poll']) && $_['poll'] != null; |
|
30 | + $userId = $_[ 'userId' ]; |
|
31 | + $userMgr = $_[ 'userMgr' ]; |
|
32 | + $urlGenerator = $_[ 'urlGenerator' ]; |
|
33 | + $isUpdate = isset($_[ 'poll' ]) && $_[ 'poll' ] != null; |
|
34 | 34 | $isAnonymous = false; |
35 | 35 | $hideNames = false; |
36 | 36 | |
37 | 37 | if ($isUpdate) { |
38 | - $poll = $_['poll']; |
|
38 | + $poll = $_[ 'poll' ]; |
|
39 | 39 | $isAnonymous = $poll->getIsAnonymous(); |
40 | 40 | $hideNames = $isAnonymous && $poll->getFullAnonymous(); |
41 | - $dates = $_['dates']; |
|
41 | + $dates = $_[ 'dates' ]; |
|
42 | 42 | $chosen = '['; |
43 | 43 | foreach ($dates as $d) { |
44 | 44 | if ($poll->getType() == '0') { |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $title = $poll->getTitle(); |
54 | 54 | $desc = $poll->getDescription(); |
55 | 55 | if ($poll->getExpire() != null) { |
56 | - $expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day |
|
56 | + $expireTs = strtotime($poll->getExpire()) - 60 * 60 * 24; //remove one day, which has been added to expire at the end of a day |
|
57 | 57 | $expireStr = date('d.m.Y', $expireTs); |
58 | 58 | } |
59 | 59 | $access = $poll->getAccess(); |
60 | 60 | $accessTypes = $access; |
61 | - if ( $access != 'registered' |
|
61 | + if ($access != 'registered' |
|
62 | 62 | && $access != 'hidden' && $access != 'public' |
63 | 63 | ) { |
64 | 64 | $access = 'select'; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | <table id="selected-dates-table" class="choices"> |
167 | 167 | </table> |
168 | 168 | </div> |
169 | - <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() == '0') print_unescaped('style="display:none;"'); ?> > |
|
169 | + <div id="text-select-container" <?php if (!$isUpdate || $poll->getType() == '0') print_unescaped('style="display:none;"'); ?> > |
|
170 | 170 | <label for="text-title" class="input_title"><?php p($l->t('Text item')); ?></label> |
171 | 171 | <div class="input-group"> |
172 | 172 | <input type="text" id="text-title" placeholder="<?php print_unescaped('Insert text...'); ?>" /> |
@@ -1,50 +1,50 @@ discard block |
||
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 | - */ |
|
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 | 23 | |
24 | - use OCP\User; |
|
24 | + use OCP\User; |
|
25 | 25 | |
26 | - \OCP\Util::addStyle('polls', 'main'); |
|
27 | - \OCP\Util::addStyle('polls', 'vote'); |
|
28 | - \OCP\Util::addScript('polls', 'vote'); |
|
26 | + \OCP\Util::addStyle('polls', 'main'); |
|
27 | + \OCP\Util::addStyle('polls', 'vote'); |
|
28 | + \OCP\Util::addScript('polls', 'vote'); |
|
29 | 29 | |
30 | - $userId = $_['userId']; |
|
31 | - $userMgr = $_['userMgr']; |
|
32 | - $urlGenerator = $_['urlGenerator']; |
|
33 | - $avaMgr = $_['avatarManager']; |
|
30 | + $userId = $_['userId']; |
|
31 | + $userMgr = $_['userMgr']; |
|
32 | + $urlGenerator = $_['urlGenerator']; |
|
33 | + $avaMgr = $_['avatarManager']; |
|
34 | 34 | |
35 | - $poll = $_['poll']; |
|
36 | - $dates = $_['dates']; |
|
37 | - $votes = $_['votes']; |
|
38 | - $comments = $_['comments']; |
|
39 | - $isAnonymous = $poll->getIsAnonymous() && $userId != $poll->getOwner(); |
|
40 | - $hideNames = $poll->getIsAnonymous() && $poll->getFullAnonymous(); |
|
41 | - $notification = $_['notification']; |
|
35 | + $poll = $_['poll']; |
|
36 | + $dates = $_['dates']; |
|
37 | + $votes = $_['votes']; |
|
38 | + $comments = $_['comments']; |
|
39 | + $isAnonymous = $poll->getIsAnonymous() && $userId != $poll->getOwner(); |
|
40 | + $hideNames = $poll->getIsAnonymous() && $poll->getFullAnonymous(); |
|
41 | + $notification = $_['notification']; |
|
42 | 42 | |
43 | - if ($poll->getExpire() == null) { |
|
44 | - $expired = false; |
|
45 | - } else { |
|
46 | - $expired = time() > strtotime($poll->getExpire()); |
|
47 | - } |
|
43 | + if ($poll->getExpire() == null) { |
|
44 | + $expired = false; |
|
45 | + } else { |
|
46 | + $expired = time() > strtotime($poll->getExpire()); |
|
47 | + } |
|
48 | 48 | ?> |
49 | 49 | |
50 | 50 | <?php if($poll->getType() == '0') : ?> |
@@ -55,19 +55,19 @@ discard block |
||
55 | 55 | |
56 | 56 | <?php |
57 | 57 | if ( $poll->getDescription() != null |
58 | - && $poll->getDescription() != '' |
|
58 | + && $poll->getDescription() != '' |
|
59 | 59 | ) { |
60 | - $description = nl2br($poll->getDescription()); |
|
60 | + $description = nl2br($poll->getDescription()); |
|
61 | 61 | } else { |
62 | - $description = $l->t('No description provided.'); |
|
62 | + $description = $l->t('No description provided.'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // init array for counting 'yes'-votes for each date |
66 | 66 | $total_y = array(); |
67 | 67 | $total_n = array(); |
68 | 68 | for ($i = 0 ; $i < count($dates) ; $i++) { |
69 | - $total_y[$i] = 0; |
|
70 | - $total_n[$i] = 0; |
|
69 | + $total_y[$i] = 0; |
|
70 | + $total_n[$i] = 0; |
|
71 | 71 | } |
72 | 72 | $user_voted = array(); |
73 | 73 | |
@@ -106,189 +106,189 @@ discard block |
||
106 | 106 | <table class="vote_table"> |
107 | 107 | <thead> |
108 | 108 | <?php |
109 | - if ($poll->getType() == '0') { |
|
110 | - print_unescaped('<tr id="time-slots-header"><th class="first_header_cell" colspan="3"></th>'); |
|
111 | - } else { |
|
112 | - print_unescaped('<tr id="vote-options-header"><th class="first_header_cell" colspan="3"></th>'); |
|
113 | - foreach ($dates as $el) { |
|
114 | - print_unescaped('<th title="' . preg_replace('/_\d+$/', '', $el->getText()) . '" class="vote-option">' . preg_replace('/_\d+$/', '', $el->getText()) . '</th>'); |
|
115 | - } |
|
116 | - } |
|
117 | - print_unescaped('</tr>'); |
|
118 | - ?> |
|
109 | + if ($poll->getType() == '0') { |
|
110 | + print_unescaped('<tr id="time-slots-header"><th class="first_header_cell" colspan="3"></th>'); |
|
111 | + } else { |
|
112 | + print_unescaped('<tr id="vote-options-header"><th class="first_header_cell" colspan="3"></th>'); |
|
113 | + foreach ($dates as $el) { |
|
114 | + print_unescaped('<th title="' . preg_replace('/_\d+$/', '', $el->getText()) . '" class="vote-option">' . preg_replace('/_\d+$/', '', $el->getText()) . '</th>'); |
|
115 | + } |
|
116 | + } |
|
117 | + print_unescaped('</tr>'); |
|
118 | + ?> |
|
119 | 119 | </thead> |
120 | 120 | <tbody class="votes"> |
121 | 121 | <?php |
122 | - if ($votes != null) { |
|
123 | - //group by user |
|
124 | - $others = array(); |
|
125 | - foreach ($votes as $vote) { |
|
126 | - if (!isset($others[$vote->getUserId()])) { |
|
127 | - $others[$vote->getUserId()] = array(); |
|
128 | - } |
|
129 | - array_push($others[$vote->getUserId()], $vote); |
|
130 | - } |
|
131 | - $userCnt = 0; |
|
132 | - foreach (array_keys($others) as $usr) { |
|
133 | - $userCnt++; |
|
134 | - if ($usr == $userId) { |
|
135 | - // if poll expired, just put current user among the others; |
|
136 | - // otherwise skip here to add current user as last row (to vote) |
|
137 | - if (!$expired) { |
|
138 | - $user_voted = $others[$usr]; |
|
139 | - continue; |
|
140 | - } |
|
141 | - } |
|
142 | - print_unescaped('<tr>'); |
|
143 | - print_unescaped('<td class="avatar-cell">'); |
|
144 | - if ( $userMgr->get($usr) != null |
|
145 | - && !$isAnonymous && !$hideNames |
|
146 | - ) { |
|
147 | - print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>'); |
|
148 | - print_unescaped('</td>'); |
|
149 | - print_unescaped('<td colspan="2" class="name">'); |
|
150 | - p($userMgr->get($usr)->getDisplayName()); |
|
151 | - } else { |
|
152 | - if ($isAnonymous || $hideNames) { |
|
153 | - print_unescaped('<div class="poll avatardiv" title="'.($userCnt).'"></div>'); |
|
154 | - print_unescaped('</td>'); |
|
155 | - print_unescaped('<td colspan="2" class="name">'); |
|
156 | - } else { |
|
157 | - print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>'); |
|
158 | - print_unescaped('</td>'); |
|
159 | - print_unescaped('<td colspan="2" class="name">'); |
|
160 | - p($usr); |
|
161 | - } |
|
162 | - } |
|
163 | - print_unescaped('</td>'); |
|
122 | + if ($votes != null) { |
|
123 | + //group by user |
|
124 | + $others = array(); |
|
125 | + foreach ($votes as $vote) { |
|
126 | + if (!isset($others[$vote->getUserId()])) { |
|
127 | + $others[$vote->getUserId()] = array(); |
|
128 | + } |
|
129 | + array_push($others[$vote->getUserId()], $vote); |
|
130 | + } |
|
131 | + $userCnt = 0; |
|
132 | + foreach (array_keys($others) as $usr) { |
|
133 | + $userCnt++; |
|
134 | + if ($usr == $userId) { |
|
135 | + // if poll expired, just put current user among the others; |
|
136 | + // otherwise skip here to add current user as last row (to vote) |
|
137 | + if (!$expired) { |
|
138 | + $user_voted = $others[$usr]; |
|
139 | + continue; |
|
140 | + } |
|
141 | + } |
|
142 | + print_unescaped('<tr>'); |
|
143 | + print_unescaped('<td class="avatar-cell">'); |
|
144 | + if ( $userMgr->get($usr) != null |
|
145 | + && !$isAnonymous && !$hideNames |
|
146 | + ) { |
|
147 | + print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>'); |
|
148 | + print_unescaped('</td>'); |
|
149 | + print_unescaped('<td colspan="2" class="name">'); |
|
150 | + p($userMgr->get($usr)->getDisplayName()); |
|
151 | + } else { |
|
152 | + if ($isAnonymous || $hideNames) { |
|
153 | + print_unescaped('<div class="poll avatardiv" title="'.($userCnt).'"></div>'); |
|
154 | + print_unescaped('</td>'); |
|
155 | + print_unescaped('<td colspan="2" class="name">'); |
|
156 | + } else { |
|
157 | + print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>'); |
|
158 | + print_unescaped('</td>'); |
|
159 | + print_unescaped('<td colspan="2" class="name">'); |
|
160 | + p($usr); |
|
161 | + } |
|
162 | + } |
|
163 | + print_unescaped('</td>'); |
|
164 | 164 | |
165 | - // loop over dts |
|
166 | - $i_tot = 0; |
|
167 | - foreach ($dates as $dt) { |
|
168 | - if ($poll->getType() == '0') { |
|
169 | - $date_id = strtotime($dt->getDt()); |
|
170 | - $poll_id = "pollid_" . $dt->getId(); |
|
171 | - } else { |
|
172 | - $date_id = $dt->getText(); |
|
173 | - $poll_id = "pollid_" . $dt->getId(); |
|
174 | - } |
|
175 | - // look what user voted for this dts |
|
176 | - $found = false; |
|
177 | - foreach ($others[$usr] as $vote) { |
|
178 | - $voteVal = null; |
|
179 | - if ($poll->getType() == '0') { |
|
180 | - $voteVal = strtotime($vote->getDt()); |
|
181 | - } else { |
|
182 | - $voteVal = $vote->getText(); |
|
183 | - } |
|
184 | - if ($date_id == $voteVal) { |
|
185 | - if ($vote->getType() == '1') { |
|
186 | - $cl = 'poll-cell yes'; |
|
187 | - $total_y[$i_tot]++; |
|
188 | - } else if ($vote->getType() == '0') { |
|
189 | - $cl = 'poll-cell no'; |
|
190 | - $total_n[$i_tot]++; |
|
191 | - } else if ($vote->getType() == '2') { |
|
192 | - $cl = 'poll-cell maybe'; |
|
193 | - } else { |
|
194 | - $cl = 'poll-cell unvoted'; |
|
195 | - } |
|
196 | - $found = true; |
|
197 | - break; |
|
198 | - } |
|
199 | - } |
|
200 | - if (!$found) { |
|
201 | - $cl = 'poll-cell unvoted'; |
|
202 | - } |
|
203 | - // Make the td clickable |
|
204 | - print_unescaped('<td class="' . $cl . '"><div></div></td>'); |
|
205 | - // Make the div clickable |
|
206 | - // print_unescaped('<td><div class="' . $cl . '"></div></td>'); |
|
207 | - $i_tot++; |
|
208 | - } |
|
209 | - print_unescaped('</tr>'); |
|
210 | - } |
|
211 | - } |
|
212 | - $total_y_others = array_merge(array(), $total_y); |
|
213 | - $total_n_others = array_merge(array(), $total_n); |
|
214 | - if (!$expired) { |
|
215 | - print_unescaped('<tr class="current-user">'); |
|
216 | - print_unescaped('<td class="avatar-cell">'); |
|
217 | - if (User::isLoggedIn()) { |
|
218 | - print_unescaped('<div class="poll avatardiv" title="'.($userId).'"></div>'); |
|
219 | - print_unescaped('</td>'); |
|
220 | - print_unescaped('<td class="name">'); |
|
221 | - p($userMgr->get($userId)->getDisplayName()); |
|
222 | - } else { |
|
223 | - print_unescaped('<div class="poll avatardiv" title="?"></div>'); |
|
224 | - print_unescaped('</td>'); |
|
225 | - print_unescaped('<td id="id_ac_detected" class="external current-user"><input type="text" name="user_name" id="user_name" placeholder="' . $l->t('Your name here') . '" />'); |
|
226 | - } |
|
227 | - print_unescaped('</td><td class="toggle-all toggle maybe"><div id="toggle" class=""></div><img class="svg" src="../../../../core/img/actions/play-next.svg" "="" alt=""></td>'); |
|
228 | - // print_unescaped('</td><td class="toggle-cell"><div id="toggle" class="toggle-all toggle maybe"></div><img class="svg" src="../../../../core/img/actions/play-next.svg" "="" alt=""></td>'); |
|
229 | - $i_tot = 0; |
|
230 | - foreach ($dates as $dt) { |
|
231 | - if ($poll->getType() == '0') { |
|
232 | - $date_id = strtotime($dt->getDt()); |
|
233 | - $poll_id = "pollid_" . $dt->getId(); |
|
234 | - } else { |
|
235 | - $date_id = $dt->getText(); |
|
236 | - $poll_id = "pollid_" . $dt->getId(); |
|
237 | - } |
|
238 | - // see if user already has data for this event |
|
239 | - $cl = 'poll-cell active unvoted '; |
|
240 | - if (isset($user_voted)) { |
|
241 | - foreach ($user_voted as $obj) { |
|
242 | - $voteVal = null; |
|
243 | - if($poll->getType() == '0') { |
|
244 | - $voteVal = strtotime($obj->getDt()); |
|
245 | - } else { |
|
246 | - $voteVal = $obj->getText(); |
|
247 | - } |
|
248 | - if ($voteVal == $date_id) { |
|
249 | - if ($obj->getType() == '1') { |
|
250 | - $cl = 'poll-cell active yes'; |
|
251 | - $total_y[$i_tot]++; |
|
252 | - } else if ($obj->getType() == '0') { |
|
253 | - $cl = 'poll-cell active no'; |
|
254 | - $total_n[$i_tot]++; |
|
255 | - } else if($obj->getType() == '2') { |
|
256 | - $cl = 'poll-cell active maybe'; |
|
257 | - } |
|
258 | - break; |
|
259 | - } |
|
260 | - } |
|
261 | - } |
|
262 | - // Make the td clickable |
|
263 | - print_unescaped('<td id="' . $poll_id . '" class="cl_click ' . $cl . '" data-value="' . $date_id . '"><div></div></td>'); |
|
264 | - // Make the div clickable |
|
265 | - // print_unescaped('<td><div id="' . $date_id . '" class="cl_click ' . $cl . '"></div></td>'); |
|
165 | + // loop over dts |
|
166 | + $i_tot = 0; |
|
167 | + foreach ($dates as $dt) { |
|
168 | + if ($poll->getType() == '0') { |
|
169 | + $date_id = strtotime($dt->getDt()); |
|
170 | + $poll_id = "pollid_" . $dt->getId(); |
|
171 | + } else { |
|
172 | + $date_id = $dt->getText(); |
|
173 | + $poll_id = "pollid_" . $dt->getId(); |
|
174 | + } |
|
175 | + // look what user voted for this dts |
|
176 | + $found = false; |
|
177 | + foreach ($others[$usr] as $vote) { |
|
178 | + $voteVal = null; |
|
179 | + if ($poll->getType() == '0') { |
|
180 | + $voteVal = strtotime($vote->getDt()); |
|
181 | + } else { |
|
182 | + $voteVal = $vote->getText(); |
|
183 | + } |
|
184 | + if ($date_id == $voteVal) { |
|
185 | + if ($vote->getType() == '1') { |
|
186 | + $cl = 'poll-cell yes'; |
|
187 | + $total_y[$i_tot]++; |
|
188 | + } else if ($vote->getType() == '0') { |
|
189 | + $cl = 'poll-cell no'; |
|
190 | + $total_n[$i_tot]++; |
|
191 | + } else if ($vote->getType() == '2') { |
|
192 | + $cl = 'poll-cell maybe'; |
|
193 | + } else { |
|
194 | + $cl = 'poll-cell unvoted'; |
|
195 | + } |
|
196 | + $found = true; |
|
197 | + break; |
|
198 | + } |
|
199 | + } |
|
200 | + if (!$found) { |
|
201 | + $cl = 'poll-cell unvoted'; |
|
202 | + } |
|
203 | + // Make the td clickable |
|
204 | + print_unescaped('<td class="' . $cl . '"><div></div></td>'); |
|
205 | + // Make the div clickable |
|
206 | + // print_unescaped('<td><div class="' . $cl . '"></div></td>'); |
|
207 | + $i_tot++; |
|
208 | + } |
|
209 | + print_unescaped('</tr>'); |
|
210 | + } |
|
211 | + } |
|
212 | + $total_y_others = array_merge(array(), $total_y); |
|
213 | + $total_n_others = array_merge(array(), $total_n); |
|
214 | + if (!$expired) { |
|
215 | + print_unescaped('<tr class="current-user">'); |
|
216 | + print_unescaped('<td class="avatar-cell">'); |
|
217 | + if (User::isLoggedIn()) { |
|
218 | + print_unescaped('<div class="poll avatardiv" title="'.($userId).'"></div>'); |
|
219 | + print_unescaped('</td>'); |
|
220 | + print_unescaped('<td class="name">'); |
|
221 | + p($userMgr->get($userId)->getDisplayName()); |
|
222 | + } else { |
|
223 | + print_unescaped('<div class="poll avatardiv" title="?"></div>'); |
|
224 | + print_unescaped('</td>'); |
|
225 | + print_unescaped('<td id="id_ac_detected" class="external current-user"><input type="text" name="user_name" id="user_name" placeholder="' . $l->t('Your name here') . '" />'); |
|
226 | + } |
|
227 | + print_unescaped('</td><td class="toggle-all toggle maybe"><div id="toggle" class=""></div><img class="svg" src="../../../../core/img/actions/play-next.svg" "="" alt=""></td>'); |
|
228 | + // print_unescaped('</td><td class="toggle-cell"><div id="toggle" class="toggle-all toggle maybe"></div><img class="svg" src="../../../../core/img/actions/play-next.svg" "="" alt=""></td>'); |
|
229 | + $i_tot = 0; |
|
230 | + foreach ($dates as $dt) { |
|
231 | + if ($poll->getType() == '0') { |
|
232 | + $date_id = strtotime($dt->getDt()); |
|
233 | + $poll_id = "pollid_" . $dt->getId(); |
|
234 | + } else { |
|
235 | + $date_id = $dt->getText(); |
|
236 | + $poll_id = "pollid_" . $dt->getId(); |
|
237 | + } |
|
238 | + // see if user already has data for this event |
|
239 | + $cl = 'poll-cell active unvoted '; |
|
240 | + if (isset($user_voted)) { |
|
241 | + foreach ($user_voted as $obj) { |
|
242 | + $voteVal = null; |
|
243 | + if($poll->getType() == '0') { |
|
244 | + $voteVal = strtotime($obj->getDt()); |
|
245 | + } else { |
|
246 | + $voteVal = $obj->getText(); |
|
247 | + } |
|
248 | + if ($voteVal == $date_id) { |
|
249 | + if ($obj->getType() == '1') { |
|
250 | + $cl = 'poll-cell active yes'; |
|
251 | + $total_y[$i_tot]++; |
|
252 | + } else if ($obj->getType() == '0') { |
|
253 | + $cl = 'poll-cell active no'; |
|
254 | + $total_n[$i_tot]++; |
|
255 | + } else if($obj->getType() == '2') { |
|
256 | + $cl = 'poll-cell active maybe'; |
|
257 | + } |
|
258 | + break; |
|
259 | + } |
|
260 | + } |
|
261 | + } |
|
262 | + // Make the td clickable |
|
263 | + print_unescaped('<td id="' . $poll_id . '" class="cl_click ' . $cl . '" data-value="' . $date_id . '"><div></div></td>'); |
|
264 | + // Make the div clickable |
|
265 | + // print_unescaped('<td><div id="' . $date_id . '" class="cl_click ' . $cl . '"></div></td>'); |
|
266 | 266 | |
267 | - $i_tot++; |
|
268 | - } |
|
269 | - } |
|
270 | - ?> |
|
267 | + $i_tot++; |
|
268 | + } |
|
269 | + } |
|
270 | + ?> |
|
271 | 271 | </tbody> |
272 | 272 | <tbody class="summary"> |
273 | 273 | <?php |
274 | - $diff_array = $total_y; |
|
275 | - for($i = 0 ; $i < count($diff_array) ; $i++) { |
|
276 | - $diff_array[$i] = ($total_y[$i] - $total_n[$i]); |
|
277 | - } |
|
278 | - $max_votes = max($diff_array); |
|
279 | - ?> |
|
274 | + $diff_array = $total_y; |
|
275 | + for($i = 0 ; $i < count($diff_array) ; $i++) { |
|
276 | + $diff_array[$i] = ($total_y[$i] - $total_n[$i]); |
|
277 | + } |
|
278 | + $max_votes = max($diff_array); |
|
279 | + ?> |
|
280 | 280 | <tr class="total"> |
281 | 281 | <th colspan="3"><?php p($l->t('Total')); ?></th> |
282 | 282 | <?php for ($i = 0 ; $i < count($dates) ; $i++) : ?> |
283 | 283 | <td class="total"> |
284 | 284 | <?php |
285 | - $classSuffix = "pollid_" . $dates[$i]->getId(); |
|
286 | - if (isset($total_y[$i])) { |
|
287 | - $val = $total_y[$i]; |
|
288 | - } else { |
|
289 | - $val = 0; |
|
290 | - } |
|
291 | - ?> |
|
285 | + $classSuffix = "pollid_" . $dates[$i]->getId(); |
|
286 | + if (isset($total_y[$i])) { |
|
287 | + $val = $total_y[$i]; |
|
288 | + } else { |
|
289 | + $val = 0; |
|
290 | + } |
|
291 | + ?> |
|
292 | 292 | <div id="id_y_<?php p($classSuffix); ?>" class="result-cell yes" data-value=<?php p(isset($total_y_others[$i]) ? $total_y_others[$i] : '0'); ?>> |
293 | 293 | <?php p($val); ?> |
294 | 294 | </div> |
@@ -301,14 +301,14 @@ discard block |
||
301 | 301 | <tr class="best"> |
302 | 302 | <th colspan="3"><?php p($l->t('Best option')); ?></th> |
303 | 303 | <?php |
304 | - for ($i = 0; $i < count($dates); $i++) { |
|
305 | - $check = ''; |
|
306 | - if ($total_y[$i] - $total_n[$i] == $max_votes) { |
|
307 | - $check = 'icon-checkmark'; |
|
308 | - } |
|
309 | - print_unescaped('<td class="win_row ' . $check . '" id="id_total_' . $i . '"></td>'); |
|
310 | - } |
|
311 | - ?> |
|
304 | + for ($i = 0; $i < count($dates); $i++) { |
|
305 | + $check = ''; |
|
306 | + if ($total_y[$i] - $total_n[$i] == $max_votes) { |
|
307 | + $check = 'icon-checkmark'; |
|
308 | + } |
|
309 | + print_unescaped('<td class="win_row ' . $check . '" id="id_total_' . $i . '"></td>'); |
|
310 | + } |
|
311 | + ?> |
|
312 | 312 | </tr> |
313 | 313 | </tbody> |
314 | 314 | </table> |
@@ -371,19 +371,19 @@ discard block |
||
371 | 371 | <div class="comment"> |
372 | 372 | <div class="comment-header"> |
373 | 373 | <?php |
374 | - print_unescaped('<span class="comment-date">' . date('d.m.Y H:i:s', strtotime($comment->getDt())) . '</span>'); |
|
375 | - if ($isAnonymous || $hideNames) { |
|
376 | - p('Anonymous'); |
|
377 | - } else { |
|
378 | - if ($userMgr->get($comment->getUserId()) != null) { |
|
379 | - p($userMgr->get($comment->getUserId())->getDisplayName()); |
|
380 | - } else { |
|
381 | - print_unescaped('<i>'); |
|
382 | - p($comment->getUserId()); |
|
383 | - print_unescaped('</i>'); |
|
384 | - } |
|
385 | - } |
|
386 | - ?> |
|
374 | + print_unescaped('<span class="comment-date">' . date('d.m.Y H:i:s', strtotime($comment->getDt())) . '</span>'); |
|
375 | + if ($isAnonymous || $hideNames) { |
|
376 | + p('Anonymous'); |
|
377 | + } else { |
|
378 | + if ($userMgr->get($comment->getUserId()) != null) { |
|
379 | + p($userMgr->get($comment->getUserId())->getDisplayName()); |
|
380 | + } else { |
|
381 | + print_unescaped('<i>'); |
|
382 | + p($comment->getUserId()); |
|
383 | + print_unescaped('</i>'); |
|
384 | + } |
|
385 | + } |
|
386 | + ?> |
|
387 | 387 | </div> |
388 | 388 | <div class="wordwrap comment-content"> |
389 | 389 | <?php p($comment->getComment()); ?> |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | \OCP\Util::addStyle('polls', 'vote'); |
28 | 28 | \OCP\Util::addScript('polls', 'vote'); |
29 | 29 | |
30 | - $userId = $_['userId']; |
|
31 | - $userMgr = $_['userMgr']; |
|
32 | - $urlGenerator = $_['urlGenerator']; |
|
33 | - $avaMgr = $_['avatarManager']; |
|
30 | + $userId = $_[ 'userId' ]; |
|
31 | + $userMgr = $_[ 'userMgr' ]; |
|
32 | + $urlGenerator = $_[ 'urlGenerator' ]; |
|
33 | + $avaMgr = $_[ 'avatarManager' ]; |
|
34 | 34 | |
35 | - $poll = $_['poll']; |
|
36 | - $dates = $_['dates']; |
|
37 | - $votes = $_['votes']; |
|
38 | - $comments = $_['comments']; |
|
35 | + $poll = $_[ 'poll' ]; |
|
36 | + $dates = $_[ 'dates' ]; |
|
37 | + $votes = $_[ 'votes' ]; |
|
38 | + $comments = $_[ 'comments' ]; |
|
39 | 39 | $isAnonymous = $poll->getIsAnonymous() && $userId != $poll->getOwner(); |
40 | 40 | $hideNames = $poll->getIsAnonymous() && $poll->getFullAnonymous(); |
41 | - $notification = $_['notification']; |
|
41 | + $notification = $_[ 'notification' ]; |
|
42 | 42 | |
43 | 43 | if ($poll->getExpire() == null) { |
44 | 44 | $expired = false; |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | } |
48 | 48 | ?> |
49 | 49 | |
50 | -<?php if($poll->getType() == '0') : ?> |
|
51 | - <?php foreach($dates as $d) : ?> |
|
50 | +<?php if ($poll->getType() == '0') : ?> |
|
51 | + <?php foreach ($dates as $d) : ?> |
|
52 | 52 | <input class="hidden-dates" type="hidden" value="<?php print_unescaped($d->getDt()); ?>" /> |
53 | 53 | <?php endforeach ?> |
54 | 54 | <?php endif ?> |
55 | 55 | |
56 | 56 | <?php |
57 | -if ( $poll->getDescription() != null |
|
57 | +if ($poll->getDescription() != null |
|
58 | 58 | && $poll->getDescription() != '' |
59 | 59 | ) { |
60 | 60 | $description = nl2br($poll->getDescription()); |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | // init array for counting 'yes'-votes for each date |
66 | 66 | $total_y = array(); |
67 | 67 | $total_n = array(); |
68 | -for ($i = 0 ; $i < count($dates) ; $i++) { |
|
69 | - $total_y[$i] = 0; |
|
70 | - $total_n[$i] = 0; |
|
68 | +for ($i = 0; $i < count($dates); $i++) { |
|
69 | + $total_y[ $i ] = 0; |
|
70 | + $total_n[ $i ] = 0; |
|
71 | 71 | } |
72 | 72 | $user_voted = array(); |
73 | 73 | |
74 | -$pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' => $poll->getHash()]); |
|
74 | +$pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', [ 'hash' => $poll->getHash() ]); |
|
75 | 75 | ?> |
76 | 76 | |
77 | 77 | <div id="app"> |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | //group by user |
124 | 124 | $others = array(); |
125 | 125 | foreach ($votes as $vote) { |
126 | - if (!isset($others[$vote->getUserId()])) { |
|
127 | - $others[$vote->getUserId()] = array(); |
|
126 | + if (!isset($others[ $vote->getUserId() ])) { |
|
127 | + $others[ $vote->getUserId() ] = array(); |
|
128 | 128 | } |
129 | - array_push($others[$vote->getUserId()], $vote); |
|
129 | + array_push($others[ $vote->getUserId() ], $vote); |
|
130 | 130 | } |
131 | 131 | $userCnt = 0; |
132 | 132 | foreach (array_keys($others) as $usr) { |
@@ -135,26 +135,26 @@ discard block |
||
135 | 135 | // if poll expired, just put current user among the others; |
136 | 136 | // otherwise skip here to add current user as last row (to vote) |
137 | 137 | if (!$expired) { |
138 | - $user_voted = $others[$usr]; |
|
138 | + $user_voted = $others[ $usr ]; |
|
139 | 139 | continue; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | print_unescaped('<tr>'); |
143 | 143 | print_unescaped('<td class="avatar-cell">'); |
144 | - if ( $userMgr->get($usr) != null |
|
144 | + if ($userMgr->get($usr) != null |
|
145 | 145 | && !$isAnonymous && !$hideNames |
146 | 146 | ) { |
147 | - print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>'); |
|
147 | + print_unescaped('<div class="poll avatardiv" title="' . ($usr) . '"></div>'); |
|
148 | 148 | print_unescaped('</td>'); |
149 | 149 | print_unescaped('<td colspan="2" class="name">'); |
150 | 150 | p($userMgr->get($usr)->getDisplayName()); |
151 | 151 | } else { |
152 | 152 | if ($isAnonymous || $hideNames) { |
153 | - print_unescaped('<div class="poll avatardiv" title="'.($userCnt).'"></div>'); |
|
153 | + print_unescaped('<div class="poll avatardiv" title="' . ($userCnt) . '"></div>'); |
|
154 | 154 | print_unescaped('</td>'); |
155 | 155 | print_unescaped('<td colspan="2" class="name">'); |
156 | 156 | } else { |
157 | - print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>'); |
|
157 | + print_unescaped('<div class="poll avatardiv" title="' . ($usr) . '"></div>'); |
|
158 | 158 | print_unescaped('</td>'); |
159 | 159 | print_unescaped('<td colspan="2" class="name">'); |
160 | 160 | p($usr); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | // look what user voted for this dts |
176 | 176 | $found = false; |
177 | - foreach ($others[$usr] as $vote) { |
|
177 | + foreach ($others[ $usr ] as $vote) { |
|
178 | 178 | $voteVal = null; |
179 | 179 | if ($poll->getType() == '0') { |
180 | 180 | $voteVal = strtotime($vote->getDt()); |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | if ($date_id == $voteVal) { |
185 | 185 | if ($vote->getType() == '1') { |
186 | 186 | $cl = 'poll-cell yes'; |
187 | - $total_y[$i_tot]++; |
|
187 | + $total_y[ $i_tot ]++; |
|
188 | 188 | } else if ($vote->getType() == '0') { |
189 | 189 | $cl = 'poll-cell no'; |
190 | - $total_n[$i_tot]++; |
|
190 | + $total_n[ $i_tot ]++; |
|
191 | 191 | } else if ($vote->getType() == '2') { |
192 | 192 | $cl = 'poll-cell maybe'; |
193 | 193 | } else { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | print_unescaped('<tr class="current-user">'); |
216 | 216 | print_unescaped('<td class="avatar-cell">'); |
217 | 217 | if (User::isLoggedIn()) { |
218 | - print_unescaped('<div class="poll avatardiv" title="'.($userId).'"></div>'); |
|
218 | + print_unescaped('<div class="poll avatardiv" title="' . ($userId) . '"></div>'); |
|
219 | 219 | print_unescaped('</td>'); |
220 | 220 | print_unescaped('<td class="name">'); |
221 | 221 | p($userMgr->get($userId)->getDisplayName()); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | if (isset($user_voted)) { |
241 | 241 | foreach ($user_voted as $obj) { |
242 | 242 | $voteVal = null; |
243 | - if($poll->getType() == '0') { |
|
243 | + if ($poll->getType() == '0') { |
|
244 | 244 | $voteVal = strtotime($obj->getDt()); |
245 | 245 | } else { |
246 | 246 | $voteVal = $obj->getText(); |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | if ($voteVal == $date_id) { |
249 | 249 | if ($obj->getType() == '1') { |
250 | 250 | $cl = 'poll-cell active yes'; |
251 | - $total_y[$i_tot]++; |
|
251 | + $total_y[ $i_tot ]++; |
|
252 | 252 | } else if ($obj->getType() == '0') { |
253 | 253 | $cl = 'poll-cell active no'; |
254 | - $total_n[$i_tot]++; |
|
255 | - } else if($obj->getType() == '2') { |
|
254 | + $total_n[ $i_tot ]++; |
|
255 | + } else if ($obj->getType() == '2') { |
|
256 | 256 | $cl = 'poll-cell active maybe'; |
257 | 257 | } |
258 | 258 | break; |
@@ -272,28 +272,28 @@ discard block |
||
272 | 272 | <tbody class="summary"> |
273 | 273 | <?php |
274 | 274 | $diff_array = $total_y; |
275 | - for($i = 0 ; $i < count($diff_array) ; $i++) { |
|
276 | - $diff_array[$i] = ($total_y[$i] - $total_n[$i]); |
|
275 | + for ($i = 0; $i < count($diff_array); $i++) { |
|
276 | + $diff_array[ $i ] = ($total_y[ $i ] - $total_n[ $i ]); |
|
277 | 277 | } |
278 | 278 | $max_votes = max($diff_array); |
279 | 279 | ?> |
280 | 280 | <tr class="total"> |
281 | 281 | <th colspan="3"><?php p($l->t('Total')); ?></th> |
282 | - <?php for ($i = 0 ; $i < count($dates) ; $i++) : ?> |
|
282 | + <?php for ($i = 0; $i < count($dates); $i++) : ?> |
|
283 | 283 | <td class="total"> |
284 | 284 | <?php |
285 | - $classSuffix = "pollid_" . $dates[$i]->getId(); |
|
286 | - if (isset($total_y[$i])) { |
|
287 | - $val = $total_y[$i]; |
|
285 | + $classSuffix = "pollid_" . $dates[ $i ]->getId(); |
|
286 | + if (isset($total_y[ $i ])) { |
|
287 | + $val = $total_y[ $i ]; |
|
288 | 288 | } else { |
289 | 289 | $val = 0; |
290 | 290 | } |
291 | 291 | ?> |
292 | - <div id="id_y_<?php p($classSuffix); ?>" class="result-cell yes" data-value=<?php p(isset($total_y_others[$i]) ? $total_y_others[$i] : '0'); ?>> |
|
292 | + <div id="id_y_<?php p($classSuffix); ?>" class="result-cell yes" data-value=<?php p(isset($total_y_others[ $i ]) ? $total_y_others[ $i ] : '0'); ?>> |
|
293 | 293 | <?php p($val); ?> |
294 | 294 | </div> |
295 | - <div id="id_n_<?php p($classSuffix); ?>" class="result-cell no" data-value=<?php p(isset($total_n_others[$i]) ? $total_n_others[$i] : '0'); ?>> |
|
296 | - <?php p(isset($total_n[$i]) ? $total_n[$i] : '0'); ?> |
|
295 | + <div id="id_n_<?php p($classSuffix); ?>" class="result-cell no" data-value=<?php p(isset($total_n_others[ $i ]) ? $total_n_others[ $i ] : '0'); ?>> |
|
296 | + <?php p(isset($total_n[ $i ]) ? $total_n[ $i ] : '0'); ?> |
|
297 | 297 | </div> |
298 | 298 | </td> |
299 | 299 | <?php endfor; ?> |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | <?php |
304 | 304 | for ($i = 0; $i < count($dates); $i++) { |
305 | 305 | $check = ''; |
306 | - if ($total_y[$i] - $total_n[$i] == $max_votes) { |
|
306 | + if ($total_y[ $i ] - $total_n[ $i ] == $max_votes) { |
|
307 | 307 | $check = 'icon-checkmark'; |
308 | 308 | } |
309 | 309 | print_unescaped('<td class="win_row ' . $check . '" id="id_total_' . $i . '"></td>'); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | <div class="input-group-addon"> |
335 | 335 | <span class="icon-share"></span><?php p($l->t('Link')); ?> |
336 | 336 | </div> |
337 | - <input type="text" value="<?php p($pollUrl);?>" readonly="readonly"> |
|
337 | + <input type="text" value="<?php p($pollUrl); ?>" readonly="readonly"> |
|
338 | 338 | </div> |
339 | 339 | <?php if ($expired) : ?> |
340 | 340 | <div id="expired_info"> |
@@ -323,7 +323,10 @@ discard block |
||
323 | 323 | </form> |
324 | 324 | <?php if (User::isLoggedIn()) : ?> |
325 | 325 | <span class="notification"> |
326 | - <input type="checkbox" id="check_notif" class="checkbox" <?php if ($notification != null) print_unescaped(' checked'); ?> /> |
|
326 | + <input type="checkbox" id="check_notif" class="checkbox" <?php if ($notification != null) { |
|
327 | + print_unescaped(' checked'); |
|
328 | +} |
|
329 | +?> /> |
|
327 | 330 | <label for="check_notif"><?php p($l->t('Receive notification email on activity')); ?></label> |
328 | 331 | </span> |
329 | 332 | <?php endif; ?> |
@@ -355,8 +358,11 @@ discard block |
||
355 | 358 | <a href="<?php p($urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); ?>"><?php p($l->t('Login')); ?></a> |
356 | 359 | <?php p($l->t('or')); ?> |
357 | 360 | <?php print_unescaped('<th id="id_ac_detected" class="external current-user"><input type="text" name="user_name_comm" id="user_name_comm" placeholder="' . $l->t('Your name here') . '" /></th>'); ?> |
358 | - <?php else: ?> |
|
359 | - <?php p($l->t('Logged in as') . ' ' . $userId); ?> |
|
361 | + <?php else { |
|
362 | + : ?> |
|
363 | + <?php p($l->t('Logged in as') . ' ' . $userId); |
|
364 | +} |
|
365 | +?> |
|
360 | 366 | <?php endif; ?> |
361 | 367 | <textarea id="commentBox" name="commentBox"></textarea> |
362 | 368 | <p> |
@@ -390,8 +396,11 @@ discard block |
||
390 | 396 | </div> |
391 | 397 | </div> |
392 | 398 | <?php endforeach; ?> |
393 | - <?php else : ?> |
|
394 | - <?php p($l->t('No comments yet. Be the first.')); ?> |
|
399 | + <?php else { |
|
400 | + : ?> |
|
401 | + <?php p($l->t('No comments yet. Be the first.')); |
|
402 | +} |
|
403 | +?> |
|
395 | 404 | <?php endif; ?> |
396 | 405 | </div> |
397 | 406 | </div> |
@@ -23,17 +23,17 @@ |
||
23 | 23 | |
24 | 24 | $app = new \OCA\Polls\AppInfo\Application(); |
25 | 25 | $app->registerRoutes($this, array( |
26 | - 'routes' => array( |
|
27 | - array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'), |
|
28 | - array('name' => 'page#goto_poll', 'url' => '/poll/{hash}', 'verb' => 'GET'), |
|
29 | - array('name' => 'page#edit_poll', 'url' => '/edit/{hash}', 'verb' => 'GET'), |
|
30 | - array('name' => 'page#create_poll', 'url' => '/create', 'verb' => 'GET'), |
|
31 | - array('name' => 'page#delete_poll', 'url' => '/delete', 'verb' => 'POST'), |
|
32 | - array('name' => 'page#update_poll', 'url' => '/update', 'verb' => 'POST'), |
|
33 | - array('name' => 'page#insert_poll', 'url' => '/insert', 'verb' => 'POST'), |
|
34 | - array('name' => 'page#insert_vote', 'url' => '/insert/vote', 'verb' => 'POST'), |
|
35 | - array('name' => 'page#insert_comment', 'url' => '/insert/comment', 'verb' => 'POST'), |
|
36 | - array('name' => 'page#search', 'url' => '/search', 'verb' => 'POST'), |
|
37 | - array('name' => 'page#get_display_name', 'url' => '/get/displayname', 'verb' => 'POST'), |
|
38 | - ) |
|
26 | + 'routes' => array( |
|
27 | + array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'), |
|
28 | + array('name' => 'page#goto_poll', 'url' => '/poll/{hash}', 'verb' => 'GET'), |
|
29 | + array('name' => 'page#edit_poll', 'url' => '/edit/{hash}', 'verb' => 'GET'), |
|
30 | + array('name' => 'page#create_poll', 'url' => '/create', 'verb' => 'GET'), |
|
31 | + array('name' => 'page#delete_poll', 'url' => '/delete', 'verb' => 'POST'), |
|
32 | + array('name' => 'page#update_poll', 'url' => '/update', 'verb' => 'POST'), |
|
33 | + array('name' => 'page#insert_poll', 'url' => '/insert', 'verb' => 'POST'), |
|
34 | + array('name' => 'page#insert_vote', 'url' => '/insert/vote', 'verb' => 'POST'), |
|
35 | + array('name' => 'page#insert_comment', 'url' => '/insert/comment', 'verb' => 'POST'), |
|
36 | + array('name' => 'page#search', 'url' => '/search', 'verb' => 'POST'), |
|
37 | + array('name' => 'page#get_display_name', 'url' => '/get/displayname', 'verb' => 'POST'), |
|
38 | + ) |
|
39 | 39 | )); |
@@ -37,130 +37,130 @@ |
||
37 | 37 | |
38 | 38 | class Application extends App { |
39 | 39 | |
40 | - /** |
|
41 | - * Application constructor. |
|
42 | - * @param array $urlParams |
|
43 | - */ |
|
44 | - public function __construct(array $urlParams = array()) { |
|
45 | - parent::__construct('polls', $urlParams); |
|
46 | - |
|
47 | - $container = $this->getContainer(); |
|
48 | - $server = $container->getServer(); |
|
49 | - |
|
50 | - /** |
|
51 | - * Controllers |
|
52 | - */ |
|
53 | - $container->registerService('PageController', function ($c) use ($server) { |
|
54 | - /** @var SimpleContainer $c */ |
|
55 | - return new PageController( |
|
56 | - $c->query('AppName'), |
|
57 | - $c->query('Request'), |
|
58 | - $c->query('UserManager'), |
|
59 | - $c->query('GroupManager'), |
|
60 | - $c->query('AvatarManager'), |
|
61 | - $c->query('Logger'), |
|
62 | - $c->query('L10N'), |
|
63 | - $c->query('ServerContainer')->getURLGenerator(), |
|
64 | - $c->query('UserId'), |
|
65 | - $c->query('CommentMapper'), |
|
66 | - $c->query('DateMapper'), |
|
67 | - $c->query('EventMapper'), |
|
68 | - $c->query('NotificationMapper'), |
|
69 | - $c->query('ParticipationMapper'), |
|
70 | - $c->query('ParticipationTextMapper'), |
|
71 | - $c->query('TextMapper') |
|
72 | - ); |
|
73 | - }); |
|
74 | - |
|
75 | - $container->registerService('UserManager', function ($c) { |
|
76 | - /** @var SimpleContainer $c */ |
|
77 | - return $c->query('ServerContainer')->getUserManager(); |
|
78 | - }); |
|
79 | - |
|
80 | - $container->registerService('GroupManager', function ($c) { |
|
81 | - /** @var SimpleContainer $c */ |
|
82 | - return $c->query('ServerContainer')->getGroupManager(); |
|
83 | - }); |
|
84 | - |
|
85 | - $container->registerService('AvatarManager', function ($c) { |
|
86 | - /** @var SimpleContainer $c */ |
|
87 | - return $c->query('ServerContainer')->getAvatarManager(); |
|
88 | - }); |
|
89 | - |
|
90 | - $container->registerService('Logger', function ($c) { |
|
91 | - /** @var SimpleContainer $c */ |
|
92 | - return $c->query('ServerContainer')->getLogger(); |
|
93 | - }); |
|
94 | - |
|
95 | - $container->registerService('L10N', function ($c) { |
|
96 | - return $c->query('ServerContainer')->getL10N($c->query('AppName')); |
|
97 | - }); |
|
98 | - |
|
99 | - $container->registerService('CommentMapper', function ($c) use ($server) { |
|
100 | - /** @var SimpleContainer $c */ |
|
101 | - return new CommentMapper( |
|
102 | - $server->getDatabaseConnection() |
|
103 | - ); |
|
104 | - }); |
|
105 | - |
|
106 | - $container->registerService('DateMapper', function ($c) use ($server) { |
|
107 | - /** @var SimpleContainer $c */ |
|
108 | - return new DateMapper( |
|
109 | - $server->getDatabaseConnection() |
|
110 | - ); |
|
111 | - }); |
|
112 | - |
|
113 | - $container->registerService('EventMapper', function ($c) use ($server) { |
|
114 | - /** @var SimpleContainer $c */ |
|
115 | - return new EventMapper( |
|
116 | - $server->getDatabaseConnection() |
|
117 | - ); |
|
118 | - }); |
|
119 | - |
|
120 | - $container->registerService('NotificationMapper', function ($c) use ($server) { |
|
121 | - /** @var SimpleContainer $c */ |
|
122 | - return new NotificationMapper( |
|
123 | - $server->getDatabaseConnection() |
|
124 | - ); |
|
125 | - }); |
|
126 | - |
|
127 | - $container->registerService('ParticipationMapper', function ($c) use ($server) { |
|
128 | - /** @var SimpleContainer $c */ |
|
129 | - return new ParticipationMapper( |
|
130 | - $server->getDatabaseConnection() |
|
131 | - ); |
|
132 | - }); |
|
133 | - |
|
134 | - $container->registerService('ParticipationTextMapper', function ($c) use ($server) { |
|
135 | - /** @var SimpleContainer $c */ |
|
136 | - return new ParticipationTextMapper( |
|
137 | - $server->getDatabaseConnection() |
|
138 | - ); |
|
139 | - }); |
|
140 | - |
|
141 | - $container->registerService('TextMapper', function ($c) use ($server) { |
|
142 | - /** @var SimpleContainer $c */ |
|
143 | - return new TextMapper( |
|
144 | - $server->getDatabaseConnection() |
|
145 | - ); |
|
146 | - }); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Register navigation entry for main navigation. |
|
151 | - */ |
|
152 | - public function registerNavigationEntry() { |
|
153 | - $container = $this->getContainer(); |
|
154 | - $container->query('OCP\INavigationManager')->add(function () use ($container) { |
|
155 | - $urlGenerator = $container->query('OCP\IURLGenerator'); |
|
156 | - $l10n = $container->query('OCP\IL10N'); |
|
157 | - return [ |
|
158 | - 'id' => 'polls', |
|
159 | - 'order' => 77, |
|
160 | - 'href' => $urlGenerator->linkToRoute('polls.page.index'), |
|
161 | - 'icon' => $urlGenerator->imagePath('polls', 'app-logo-polls.svg'), |
|
162 | - 'name' => $l10n->t('Polls') |
|
163 | - ]; |
|
164 | - }); |
|
165 | - } |
|
40 | + /** |
|
41 | + * Application constructor. |
|
42 | + * @param array $urlParams |
|
43 | + */ |
|
44 | + public function __construct(array $urlParams = array()) { |
|
45 | + parent::__construct('polls', $urlParams); |
|
46 | + |
|
47 | + $container = $this->getContainer(); |
|
48 | + $server = $container->getServer(); |
|
49 | + |
|
50 | + /** |
|
51 | + * Controllers |
|
52 | + */ |
|
53 | + $container->registerService('PageController', function ($c) use ($server) { |
|
54 | + /** @var SimpleContainer $c */ |
|
55 | + return new PageController( |
|
56 | + $c->query('AppName'), |
|
57 | + $c->query('Request'), |
|
58 | + $c->query('UserManager'), |
|
59 | + $c->query('GroupManager'), |
|
60 | + $c->query('AvatarManager'), |
|
61 | + $c->query('Logger'), |
|
62 | + $c->query('L10N'), |
|
63 | + $c->query('ServerContainer')->getURLGenerator(), |
|
64 | + $c->query('UserId'), |
|
65 | + $c->query('CommentMapper'), |
|
66 | + $c->query('DateMapper'), |
|
67 | + $c->query('EventMapper'), |
|
68 | + $c->query('NotificationMapper'), |
|
69 | + $c->query('ParticipationMapper'), |
|
70 | + $c->query('ParticipationTextMapper'), |
|
71 | + $c->query('TextMapper') |
|
72 | + ); |
|
73 | + }); |
|
74 | + |
|
75 | + $container->registerService('UserManager', function ($c) { |
|
76 | + /** @var SimpleContainer $c */ |
|
77 | + return $c->query('ServerContainer')->getUserManager(); |
|
78 | + }); |
|
79 | + |
|
80 | + $container->registerService('GroupManager', function ($c) { |
|
81 | + /** @var SimpleContainer $c */ |
|
82 | + return $c->query('ServerContainer')->getGroupManager(); |
|
83 | + }); |
|
84 | + |
|
85 | + $container->registerService('AvatarManager', function ($c) { |
|
86 | + /** @var SimpleContainer $c */ |
|
87 | + return $c->query('ServerContainer')->getAvatarManager(); |
|
88 | + }); |
|
89 | + |
|
90 | + $container->registerService('Logger', function ($c) { |
|
91 | + /** @var SimpleContainer $c */ |
|
92 | + return $c->query('ServerContainer')->getLogger(); |
|
93 | + }); |
|
94 | + |
|
95 | + $container->registerService('L10N', function ($c) { |
|
96 | + return $c->query('ServerContainer')->getL10N($c->query('AppName')); |
|
97 | + }); |
|
98 | + |
|
99 | + $container->registerService('CommentMapper', function ($c) use ($server) { |
|
100 | + /** @var SimpleContainer $c */ |
|
101 | + return new CommentMapper( |
|
102 | + $server->getDatabaseConnection() |
|
103 | + ); |
|
104 | + }); |
|
105 | + |
|
106 | + $container->registerService('DateMapper', function ($c) use ($server) { |
|
107 | + /** @var SimpleContainer $c */ |
|
108 | + return new DateMapper( |
|
109 | + $server->getDatabaseConnection() |
|
110 | + ); |
|
111 | + }); |
|
112 | + |
|
113 | + $container->registerService('EventMapper', function ($c) use ($server) { |
|
114 | + /** @var SimpleContainer $c */ |
|
115 | + return new EventMapper( |
|
116 | + $server->getDatabaseConnection() |
|
117 | + ); |
|
118 | + }); |
|
119 | + |
|
120 | + $container->registerService('NotificationMapper', function ($c) use ($server) { |
|
121 | + /** @var SimpleContainer $c */ |
|
122 | + return new NotificationMapper( |
|
123 | + $server->getDatabaseConnection() |
|
124 | + ); |
|
125 | + }); |
|
126 | + |
|
127 | + $container->registerService('ParticipationMapper', function ($c) use ($server) { |
|
128 | + /** @var SimpleContainer $c */ |
|
129 | + return new ParticipationMapper( |
|
130 | + $server->getDatabaseConnection() |
|
131 | + ); |
|
132 | + }); |
|
133 | + |
|
134 | + $container->registerService('ParticipationTextMapper', function ($c) use ($server) { |
|
135 | + /** @var SimpleContainer $c */ |
|
136 | + return new ParticipationTextMapper( |
|
137 | + $server->getDatabaseConnection() |
|
138 | + ); |
|
139 | + }); |
|
140 | + |
|
141 | + $container->registerService('TextMapper', function ($c) use ($server) { |
|
142 | + /** @var SimpleContainer $c */ |
|
143 | + return new TextMapper( |
|
144 | + $server->getDatabaseConnection() |
|
145 | + ); |
|
146 | + }); |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Register navigation entry for main navigation. |
|
151 | + */ |
|
152 | + public function registerNavigationEntry() { |
|
153 | + $container = $this->getContainer(); |
|
154 | + $container->query('OCP\INavigationManager')->add(function () use ($container) { |
|
155 | + $urlGenerator = $container->query('OCP\IURLGenerator'); |
|
156 | + $l10n = $container->query('OCP\IL10N'); |
|
157 | + return [ |
|
158 | + 'id' => 'polls', |
|
159 | + 'order' => 77, |
|
160 | + 'href' => $urlGenerator->linkToRoute('polls.page.index'), |
|
161 | + 'icon' => $urlGenerator->imagePath('polls', 'app-logo-polls.svg'), |
|
162 | + 'name' => $l10n->t('Polls') |
|
163 | + ]; |
|
164 | + }); |
|
165 | + } |
|
166 | 166 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Controllers |
52 | 52 | */ |
53 | - $container->registerService('PageController', function ($c) use ($server) { |
|
53 | + $container->registerService('PageController', function($c) use ($server) { |
|
54 | 54 | /** @var SimpleContainer $c */ |
55 | 55 | return new PageController( |
56 | 56 | $c->query('AppName'), |
@@ -72,73 +72,73 @@ discard block |
||
72 | 72 | ); |
73 | 73 | }); |
74 | 74 | |
75 | - $container->registerService('UserManager', function ($c) { |
|
75 | + $container->registerService('UserManager', function($c) { |
|
76 | 76 | /** @var SimpleContainer $c */ |
77 | 77 | return $c->query('ServerContainer')->getUserManager(); |
78 | 78 | }); |
79 | 79 | |
80 | - $container->registerService('GroupManager', function ($c) { |
|
80 | + $container->registerService('GroupManager', function($c) { |
|
81 | 81 | /** @var SimpleContainer $c */ |
82 | 82 | return $c->query('ServerContainer')->getGroupManager(); |
83 | 83 | }); |
84 | 84 | |
85 | - $container->registerService('AvatarManager', function ($c) { |
|
85 | + $container->registerService('AvatarManager', function($c) { |
|
86 | 86 | /** @var SimpleContainer $c */ |
87 | 87 | return $c->query('ServerContainer')->getAvatarManager(); |
88 | 88 | }); |
89 | 89 | |
90 | - $container->registerService('Logger', function ($c) { |
|
90 | + $container->registerService('Logger', function($c) { |
|
91 | 91 | /** @var SimpleContainer $c */ |
92 | 92 | return $c->query('ServerContainer')->getLogger(); |
93 | 93 | }); |
94 | 94 | |
95 | - $container->registerService('L10N', function ($c) { |
|
95 | + $container->registerService('L10N', function($c) { |
|
96 | 96 | return $c->query('ServerContainer')->getL10N($c->query('AppName')); |
97 | 97 | }); |
98 | 98 | |
99 | - $container->registerService('CommentMapper', function ($c) use ($server) { |
|
99 | + $container->registerService('CommentMapper', function($c) use ($server) { |
|
100 | 100 | /** @var SimpleContainer $c */ |
101 | 101 | return new CommentMapper( |
102 | 102 | $server->getDatabaseConnection() |
103 | 103 | ); |
104 | 104 | }); |
105 | 105 | |
106 | - $container->registerService('DateMapper', function ($c) use ($server) { |
|
106 | + $container->registerService('DateMapper', function($c) use ($server) { |
|
107 | 107 | /** @var SimpleContainer $c */ |
108 | 108 | return new DateMapper( |
109 | 109 | $server->getDatabaseConnection() |
110 | 110 | ); |
111 | 111 | }); |
112 | 112 | |
113 | - $container->registerService('EventMapper', function ($c) use ($server) { |
|
113 | + $container->registerService('EventMapper', function($c) use ($server) { |
|
114 | 114 | /** @var SimpleContainer $c */ |
115 | 115 | return new EventMapper( |
116 | 116 | $server->getDatabaseConnection() |
117 | 117 | ); |
118 | 118 | }); |
119 | 119 | |
120 | - $container->registerService('NotificationMapper', function ($c) use ($server) { |
|
120 | + $container->registerService('NotificationMapper', function($c) use ($server) { |
|
121 | 121 | /** @var SimpleContainer $c */ |
122 | 122 | return new NotificationMapper( |
123 | 123 | $server->getDatabaseConnection() |
124 | 124 | ); |
125 | 125 | }); |
126 | 126 | |
127 | - $container->registerService('ParticipationMapper', function ($c) use ($server) { |
|
127 | + $container->registerService('ParticipationMapper', function($c) use ($server) { |
|
128 | 128 | /** @var SimpleContainer $c */ |
129 | 129 | return new ParticipationMapper( |
130 | 130 | $server->getDatabaseConnection() |
131 | 131 | ); |
132 | 132 | }); |
133 | 133 | |
134 | - $container->registerService('ParticipationTextMapper', function ($c) use ($server) { |
|
134 | + $container->registerService('ParticipationTextMapper', function($c) use ($server) { |
|
135 | 135 | /** @var SimpleContainer $c */ |
136 | 136 | return new ParticipationTextMapper( |
137 | 137 | $server->getDatabaseConnection() |
138 | 138 | ); |
139 | 139 | }); |
140 | 140 | |
141 | - $container->registerService('TextMapper', function ($c) use ($server) { |
|
141 | + $container->registerService('TextMapper', function($c) use ($server) { |
|
142 | 142 | /** @var SimpleContainer $c */ |
143 | 143 | return new TextMapper( |
144 | 144 | $server->getDatabaseConnection() |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function registerNavigationEntry() { |
153 | 153 | $container = $this->getContainer(); |
154 | - $container->query('OCP\INavigationManager')->add(function () use ($container) { |
|
154 | + $container->query('OCP\INavigationManager')->add(function() use ($container) { |
|
155 | 155 | $urlGenerator = $container->query('OCP\IURLGenerator'); |
156 | 156 | $l10n = $container->query('OCP\IL10N'); |
157 | 157 | return [ |
@@ -28,50 +28,50 @@ |
||
28 | 28 | |
29 | 29 | class ParticipationMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * ParticipationMapper constructor. |
|
33 | - * @param IDBConnection $db |
|
34 | - */ |
|
35 | - public function __construct(IDBConnection $db) { |
|
36 | - parent::__construct($db, 'polls_particip', '\OCA\Polls\Db\Participation'); |
|
37 | - } |
|
31 | + /** |
|
32 | + * ParticipationMapper constructor. |
|
33 | + * @param IDBConnection $db |
|
34 | + */ |
|
35 | + public function __construct(IDBConnection $db) { |
|
36 | + parent::__construct($db, 'polls_particip', '\OCA\Polls\Db\Participation'); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $userId |
|
41 | - * @param int $limit |
|
42 | - * @param int $offset |
|
43 | - * @return Participation[] |
|
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 Participation[] |
|
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 string $pollId |
|
52 | - * @param int $limit |
|
53 | - * @param int $offset |
|
54 | - * @return Participation[] |
|
55 | - */ |
|
56 | - public function findByPoll($pollId, $limit = null, $offset = null) { |
|
57 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
58 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
59 | - } |
|
50 | + /** |
|
51 | + * @param string $pollId |
|
52 | + * @param int $limit |
|
53 | + * @param int $offset |
|
54 | + * @return Participation[] |
|
55 | + */ |
|
56 | + public function findByPoll($pollId, $limit = null, $offset = null) { |
|
57 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
58 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param string $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 string $pollId |
|
63 | + */ |
|
64 | + public function deleteByPoll($pollId) { |
|
65 | + $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
66 | + $this->execute($sql, [$pollId]); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $pollId |
|
71 | - * @param string $userId |
|
72 | - */ |
|
73 | - public function deleteByPollAndUser($pollId, $userId) { |
|
74 | - $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
75 | - $this->execute($sql, [$pollId, $userId]); |
|
76 | - } |
|
69 | + /** |
|
70 | + * @param string $pollId |
|
71 | + * @param string $userId |
|
72 | + */ |
|
73 | + public function deleteByPollAndUser($pollId, $userId) { |
|
74 | + $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
75 | + $this->execute($sql, [$pollId, $userId]); |
|
76 | + } |
|
77 | 77 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function findDistinctByUser($userId, $limit = null, $offset = null) { |
46 | 46 | $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?'; |
47 | - return $this->findEntities($sql, [$userId], $limit, $offset); |
|
47 | + return $this->findEntities($sql, [ $userId ], $limit, $offset); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function findByPoll($pollId, $limit = null, $offset = null) { |
57 | 57 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
58 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
58 | + return $this->findEntities($sql, [ $pollId ], $limit, $offset); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function deleteByPoll($pollId) { |
65 | 65 | $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
66 | - $this->execute($sql, [$pollId]); |
|
66 | + $this->execute($sql, [ $pollId ]); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,6 +72,6 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function deleteByPollAndUser($pollId, $userId) { |
74 | 74 | $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
75 | - $this->execute($sql, [$pollId, $userId]); |
|
75 | + $this->execute($sql, [ $pollId, $userId ]); |
|
76 | 76 | } |
77 | 77 | } |