Passed
Pull Request — master (#224)
by Kai
02:41
created
lib/Db/DateMapper.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,30 +28,30 @@
 block discarded – undo
28 28
 
29 29
 class DateMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * DateMapper constructor.
33
-	 * @param IDBConnection $db
34
-	 */
35
-	public function __construct(IDBConnection $db) {
36
-		parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
37
-	}
31
+    /**
32
+     * DateMapper constructor.
33
+     * @param IDBConnection $db
34
+     */
35
+    public function __construct(IDBConnection $db) {
36
+        parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $pollId
41
-	 * @param int $limit
42
-	 * @param int $offset
43
-	 * @return Date[]
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 Date[]
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
 }
Please login to merge, or discard this patch.
lib/Db/CommentMapper.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,41 +28,41 @@
 block discarded – undo
28 28
 
29 29
 class CommentMapper extends Mapper {
30 30
 
31
-	/**
32
-	 * CommentMapper constructor.
33
-	 * @param IDBConnection $db
34
-	 */
35
-	public function __construct(IDBConnection $db) {
36
-		parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
37
-	}
31
+    /**
32
+     * CommentMapper constructor.
33
+     * @param IDBConnection $db
34
+     */
35
+    public function __construct(IDBConnection $db) {
36
+        parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $userId
41
-	 * @param int $limit
42
-	 * @param int $offset
43
-	 * @return Comment[]
44
-	 */
45
-	public function findDistinctByUser($userId, $limit = null, $offset = null) {
46
-		$sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
47
-		return $this->findEntities($sql, [$userId], $limit, $offset);
48
-	}
39
+    /**
40
+     * @param string $userId
41
+     * @param int $limit
42
+     * @param int $offset
43
+     * @return Comment[]
44
+     */
45
+    public function findDistinctByUser($userId, $limit = null, $offset = null) {
46
+        $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
47
+        return $this->findEntities($sql, [$userId], $limit, $offset);
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $pollId
52
-	 * @param int $limit
53
-	 * @param int $offset
54
-	 * @return Comment[]
55
-	 */
56
-	public function findByPoll($pollId, $limit = null, $offset = null) {
57
-		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC';
58
-		return $this->findEntities($sql, [$pollId], $limit, $offset);
59
-	}
50
+    /**
51
+     * @param string $pollId
52
+     * @param int $limit
53
+     * @param int $offset
54
+     * @return Comment[]
55
+     */
56
+    public function findByPoll($pollId, $limit = null, $offset = null) {
57
+        $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC';
58
+        return $this->findEntities($sql, [$pollId], $limit, $offset);
59
+    }
60 60
 
61
-	/**
62
-	 * @param 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
 }
Please login to merge, or discard this patch.
templates/no.acc.tmpl.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
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
-	\OCP\Util::addStyle('polls', 'main');
24
+    \OCP\Util::addStyle('polls', 'main');
25 25
 ?>
26 26
 <div id="app">
27 27
 	<div id="app-content">
Please login to merge, or discard this patch.
templates/main.tmpl.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,35 +1,35 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 = $l->t('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 = $l->t('You did not vote');
99
+                        $participated_count = count($participated);
100 100
 
101
-						$comments = $_['comments'];
102
-						$commented_class = 'commented_no';
103
-						$commented_title = $l->t('You did not comment');
104
-						$commented_count = count($comments);
101
+                        $comments = $_['comments'];
102
+                        $commented_class = 'commented_no';
103
+                        $commented_title = $l->t('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 = $l->t('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 = $l->t('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 = $l->t('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 = $l->t('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
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.
lib/Db/Comment.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
  * @method void setPollId(integer $value)
35 35
  */
36 36
 class Comment extends Model {
37
-	protected $userId;
38
-	protected $dt;
39
-	protected $comment;
40
-	protected $pollId;
37
+    protected $userId;
38
+    protected $dt;
39
+    protected $comment;
40
+    protected $pollId;
41 41
 }
Please login to merge, or discard this patch.
lib/Db/Date.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,6 +30,6 @@
 block discarded – undo
30 30
  * @method void setPollId(integer $value)
31 31
  */
32 32
 class Date extends Model {
33
-	protected $dt;
34
-	protected $pollId;
33
+    protected $dt;
34
+    protected $pollId;
35 35
 }
Please login to merge, or discard this patch.
lib/Db/Event.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@
 block discarded – undo
46 46
  * @method void setFullAnonymous(integer $value)
47 47
  */
48 48
 class Event extends Model {
49
-	protected $type;
50
-	protected $title;
51
-	protected $description;
52
-	protected $owner;
53
-	protected $created;
54
-	protected $access;
55
-	protected $expire;
56
-	protected $hash;
57
-	protected $isAnonymous;
58
-	protected $fullAnonymous;
49
+    protected $type;
50
+    protected $title;
51
+    protected $description;
52
+    protected $owner;
53
+    protected $created;
54
+    protected $access;
55
+    protected $expire;
56
+    protected $hash;
57
+    protected $isAnonymous;
58
+    protected $fullAnonymous;
59 59
 }
Please login to merge, or discard this patch.
lib/Db/Participation.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
  * @method void setType(integer $value)
35 35
  */
36 36
 class Participation extends Model {
37
-	protected $dt;
38
-	protected $userId;
39
-	protected $pollId;
40
-	protected $type;
37
+    protected $dt;
38
+    protected $userId;
39
+    protected $pollId;
40
+    protected $type;
41 41
 }
Please login to merge, or discard this patch.
lib/Db/Text.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,6 +30,6 @@
 block discarded – undo
30 30
  * @method void setPollId(integer $value)
31 31
  */
32 32
 class Text extends Model {
33
-	protected $text;
34
-	protected $pollId;
33
+    protected $text;
34
+    protected $pollId;
35 35
 }
Please login to merge, or discard this patch.