@@ -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 | } |
@@ -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 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function find($id) { |
42 | 42 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
43 | - return $this->findEntity($sql, [$id]); |
|
43 | + return $this->findEntity($sql, [ $id ]); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
55 | 55 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
56 | - return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
56 | + return $this->findEntities($sql, [ $userId, $from, $until ], $limit, $offset); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function findAll($limit = null, $offset = null) { |
65 | 65 | $sql = 'SELECT * FROM ' . $this->getTableName(); |
66 | - return $this->findEntities($sql, [], $limit, $offset); |
|
66 | + return $this->findEntities($sql, [ ], $limit, $offset); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function findAllByPoll($pollId, $limit = null, $offset = null) { |
76 | 76 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
77 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
77 | + return $this->findEntities($sql, [ $pollId ], $limit, $offset); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -84,6 +84,6 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function findByUserAndPoll($pollId, $userId) { |
86 | 86 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
87 | - return $this->findEntity($sql, [$pollId, $userId]); |
|
87 | + return $this->findEntity($sql, [ $pollId, $userId ]); |
|
88 | 88 | } |
89 | 89 | } |
@@ -32,6 +32,6 @@ |
||
32 | 32 | * @method void setPollId(string $value) |
33 | 33 | */ |
34 | 34 | class Notification extends Entity { |
35 | - public $userId; |
|
36 | - public $pollId; |
|
35 | + public $userId; |
|
36 | + public $pollId; |
|
37 | 37 | } |
@@ -36,8 +36,8 @@ |
||
36 | 36 | * @method void setType(integer $value) |
37 | 37 | */ |
38 | 38 | class ParticipationText extends Entity { |
39 | - public $text; |
|
40 | - public $userId; |
|
41 | - public $pollId; |
|
42 | - public $type; |
|
39 | + public $text; |
|
40 | + public $userId; |
|
41 | + public $pollId; |
|
42 | + public $type; |
|
43 | 43 | } |
@@ -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 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function findByPoll($pollId, $limit = null, $offset = null) { |
46 | 46 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
47 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
47 | + return $this->findEntities($sql, [ $pollId ], $limit, $offset); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -52,6 +52,6 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function deleteByPoll($pollId) { |
54 | 54 | $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
55 | - $this->execute($sql, [$pollId]); |
|
55 | + $this->execute($sql, [ $pollId ]); |
|
56 | 56 | } |
57 | 57 | } |
@@ -28,55 +28,55 @@ discard block |
||
28 | 28 | |
29 | 29 | class EventMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * EventMapper constructor. |
|
33 | - * @param IDBConnection $db |
|
34 | - */ |
|
35 | - public function __construct(IDBConnection $db) { |
|
36 | - parent::__construct($db, 'polls_events', '\OCA\Polls\Db\Event'); |
|
37 | - } |
|
31 | + /** |
|
32 | + * EventMapper constructor. |
|
33 | + * @param IDBConnection $db |
|
34 | + */ |
|
35 | + public function __construct(IDBConnection $db) { |
|
36 | + parent::__construct($db, 'polls_events', '\OCA\Polls\Db\Event'); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param int $id |
|
41 | - * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
42 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
43 | - * @return Event |
|
44 | - */ |
|
45 | - public function find($id) { |
|
46 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
47 | - return $this->findEntity($sql, [$id]); |
|
48 | - } |
|
39 | + /** |
|
40 | + * @param int $id |
|
41 | + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
42 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
43 | + * @return Event |
|
44 | + */ |
|
45 | + public function find($id) { |
|
46 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
47 | + return $this->findEntity($sql, [$id]); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param $hash |
|
52 | - * @param int $limit |
|
53 | - * @param int $offset |
|
54 | - * @return Event |
|
55 | - */ |
|
56 | - public function findByHash($hash, $limit = null, $offset = null) { |
|
57 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE hash = ?'; |
|
58 | - return $this->findEntity($sql, [$hash], $limit, $offset); |
|
59 | - } |
|
50 | + /** |
|
51 | + * @param $hash |
|
52 | + * @param int $limit |
|
53 | + * @param int $offset |
|
54 | + * @return Event |
|
55 | + */ |
|
56 | + public function findByHash($hash, $limit = null, $offset = null) { |
|
57 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE hash = ?'; |
|
58 | + return $this->findEntity($sql, [$hash], $limit, $offset); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param $userId |
|
63 | - * @param int $limit |
|
64 | - * @param int $offset |
|
65 | - * @return Event[] |
|
66 | - */ |
|
67 | - public function findAllForUser($userId, $limit = null, $offset = null) { |
|
68 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE owner = ?'; |
|
69 | - return $this->findEntities($sql, [$userId], $limit, $offset); |
|
70 | - } |
|
61 | + /** |
|
62 | + * @param $userId |
|
63 | + * @param int $limit |
|
64 | + * @param int $offset |
|
65 | + * @return Event[] |
|
66 | + */ |
|
67 | + public function findAllForUser($userId, $limit = null, $offset = null) { |
|
68 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE owner = ?'; |
|
69 | + return $this->findEntities($sql, [$userId], $limit, $offset); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param string $userId |
|
74 | - * @param int $limit |
|
75 | - * @param int $offset |
|
76 | - * @return Event[] |
|
77 | - */ |
|
78 | - public function findAllForUserWithInfo($userId, $limit = null, $offset = null) { |
|
79 | - $sql = 'SELECT DISTINCT *PREFIX*polls_events.id, |
|
72 | + /** |
|
73 | + * @param string $userId |
|
74 | + * @param int $limit |
|
75 | + * @param int $offset |
|
76 | + * @return Event[] |
|
77 | + */ |
|
78 | + public function findAllForUserWithInfo($userId, $limit = null, $offset = null) { |
|
79 | + $sql = 'SELECT DISTINCT *PREFIX*polls_events.id, |
|
80 | 80 | *PREFIX*polls_events.hash, |
81 | 81 | *PREFIX*polls_events.type, |
82 | 82 | *PREFIX*polls_events.title, |
@@ -101,6 +101,6 @@ discard block |
||
101 | 101 | OR |
102 | 102 | *PREFIX*polls_comments.user_id = ? |
103 | 103 | ORDER BY created'; |
104 | - return $this->findEntities($sql, ['hidden', $userId, 'hidden', $userId, $userId], $limit, $offset); |
|
105 | - } |
|
104 | + return $this->findEntities($sql, ['hidden', $userId, 'hidden', $userId, $userId], $limit, $offset); |
|
105 | + } |
|
106 | 106 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function find($id) { |
46 | 46 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
47 | - return $this->findEntity($sql, [$id]); |
|
47 | + return $this->findEntity($sql, [ $id ]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function findByHash($hash, $limit = null, $offset = null) { |
57 | 57 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE hash = ?'; |
58 | - return $this->findEntity($sql, [$hash], $limit, $offset); |
|
58 | + return $this->findEntity($sql, [ $hash ], $limit, $offset); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function findAllForUser($userId, $limit = null, $offset = null) { |
68 | 68 | $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE owner = ?'; |
69 | - return $this->findEntities($sql, [$userId], $limit, $offset); |
|
69 | + return $this->findEntities($sql, [ $userId ], $limit, $offset); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -101,6 +101,6 @@ discard block |
||
101 | 101 | OR |
102 | 102 | *PREFIX*polls_comments.user_id = ? |
103 | 103 | ORDER BY created'; |
104 | - return $this->findEntities($sql, ['hidden', $userId, 'hidden', $userId, $userId], $limit, $offset); |
|
104 | + return $this->findEntities($sql, [ 'hidden', $userId, 'hidden', $userId, $userId ], $limit, $offset); |
|
105 | 105 | } |
106 | 106 | } |
@@ -36,8 +36,8 @@ |
||
36 | 36 | * @method void setType(integer $value) |
37 | 37 | */ |
38 | 38 | class Participation extends Entity { |
39 | - public $dt; |
|
40 | - public $userId; |
|
41 | - public $pollId; |
|
42 | - public $type; |
|
39 | + public $dt; |
|
40 | + public $userId; |
|
41 | + public $pollId; |
|
42 | + public $type; |
|
43 | 43 | } |