@@ -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 | } |
@@ -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(); |
@@ -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()); ?> |
@@ -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"> |
@@ -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 | } |
@@ -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 | } |
@@ -28,62 +28,62 @@ |
||
28 | 28 | |
29 | 29 | class NotificationMapper extends Mapper { |
30 | 30 | |
31 | - public function __construct(IDBConnection $db) { |
|
32 | - parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification'); |
|
33 | - } |
|
31 | + public function __construct(IDBConnection $db) { |
|
32 | + parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param int $id |
|
37 | - * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
38 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
39 | - * @return Notification |
|
40 | - */ |
|
41 | - public function find($id) { |
|
42 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
43 | - return $this->findEntity($sql, [$id]); |
|
44 | - } |
|
35 | + /** |
|
36 | + * @param int $id |
|
37 | + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
38 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
39 | + * @return Notification |
|
40 | + */ |
|
41 | + public function find($id) { |
|
42 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
43 | + return $this->findEntity($sql, [$id]); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $userId |
|
48 | - * @param string $from |
|
49 | - * @param string $until |
|
50 | - * @param int $limit |
|
51 | - * @param int $offset |
|
52 | - * @return Notification[] |
|
53 | - */ |
|
54 | - public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
|
55 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
|
56 | - return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
57 | - } |
|
46 | + /** |
|
47 | + * @param string $userId |
|
48 | + * @param string $from |
|
49 | + * @param string $until |
|
50 | + * @param int $limit |
|
51 | + * @param int $offset |
|
52 | + * @return Notification[] |
|
53 | + */ |
|
54 | + public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
|
55 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
|
56 | + return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param int $limit |
|
61 | - * @param int $offset |
|
62 | - * @return Notification[] |
|
63 | - */ |
|
64 | - public function findAll($limit = null, $offset = null) { |
|
65 | - $sql = 'SELECT * FROM ' . $this->getTableName(); |
|
66 | - return $this->findEntities($sql, [], $limit, $offset); |
|
67 | - } |
|
59 | + /** |
|
60 | + * @param int $limit |
|
61 | + * @param int $offset |
|
62 | + * @return Notification[] |
|
63 | + */ |
|
64 | + public function findAll($limit = null, $offset = null) { |
|
65 | + $sql = 'SELECT * FROM ' . $this->getTableName(); |
|
66 | + return $this->findEntities($sql, [], $limit, $offset); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $pollId |
|
71 | - * @param int $limit |
|
72 | - * @param int $offset |
|
73 | - * @return Notification[] |
|
74 | - */ |
|
75 | - public function findAllByPoll($pollId, $limit = null, $offset = null) { |
|
76 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
77 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
78 | - } |
|
69 | + /** |
|
70 | + * @param string $pollId |
|
71 | + * @param int $limit |
|
72 | + * @param int $offset |
|
73 | + * @return Notification[] |
|
74 | + */ |
|
75 | + public function findAllByPoll($pollId, $limit = null, $offset = null) { |
|
76 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
77 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param string $pollId |
|
82 | - * @param string $userId |
|
83 | - * @return Notification if not found |
|
84 | - */ |
|
85 | - public function findByUserAndPoll($pollId, $userId) { |
|
86 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
87 | - return $this->findEntity($sql, [$pollId, $userId]); |
|
88 | - } |
|
80 | + /** |
|
81 | + * @param string $pollId |
|
82 | + * @param string $userId |
|
83 | + * @return Notification if not found |
|
84 | + */ |
|
85 | + public function findByUserAndPoll($pollId, $userId) { |
|
86 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
87 | + return $this->findEntity($sql, [$pollId, $userId]); |
|
88 | + } |
|
89 | 89 | } |
@@ -28,30 +28,30 @@ |
||
28 | 28 | |
29 | 29 | class TextMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * TextMapper constructor. |
|
33 | - * @param IDBConnection $db |
|
34 | - */ |
|
35 | - public function __construct(IDBConnection $db) { |
|
36 | - parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text'); |
|
37 | - } |
|
31 | + /** |
|
32 | + * TextMapper constructor. |
|
33 | + * @param IDBConnection $db |
|
34 | + */ |
|
35 | + public function __construct(IDBConnection $db) { |
|
36 | + parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text'); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $pollId |
|
41 | - * @param int $limit |
|
42 | - * @param int $offset |
|
43 | - * @return Text[] |
|
44 | - */ |
|
45 | - public function findByPoll($pollId, $limit = null, $offset = null) { |
|
46 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
47 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
48 | - } |
|
39 | + /** |
|
40 | + * @param string $pollId |
|
41 | + * @param int $limit |
|
42 | + * @param int $offset |
|
43 | + * @return Text[] |
|
44 | + */ |
|
45 | + public function findByPoll($pollId, $limit = null, $offset = null) { |
|
46 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
47 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $pollId |
|
52 | - */ |
|
53 | - public function deleteByPoll($pollId) { |
|
54 | - $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
55 | - $this->execute($sql, [$pollId]); |
|
56 | - } |
|
50 | + /** |
|
51 | + * @param string $pollId |
|
52 | + */ |
|
53 | + public function deleteByPoll($pollId) { |
|
54 | + $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
55 | + $this->execute($sql, [$pollId]); |
|
56 | + } |
|
57 | 57 | } |