Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig16
-rw-r--r--appinfo/app.php47
-rw-r--r--appinfo/application.php135
-rw-r--r--appinfo/routes.php33
-rw-r--r--db/access.php15
-rw-r--r--db/comment.php21
-rw-r--r--db/date.php15
-rw-r--r--db/notification.php15
-rw-r--r--db/participation.php21
-rw-r--r--db/participationtext.php21
-rw-r--r--db/text.php15
-rw-r--r--index.php27
-rw-r--r--lib/AppInfo/Application.php175
-rw-r--r--lib/Controller/PageController.php (renamed from controller/pagecontroller.php)190
-rw-r--r--lib/Controller/PollController.php30
-rw-r--r--lib/Db/Access.php37
-rw-r--r--lib/Db/AccessMapper.php (renamed from db/accessmapper.php)120
-rw-r--r--lib/Db/Comment.php43
-rw-r--r--lib/Db/CommentMapper.php (renamed from db/commentmapper.php)180
-rw-r--r--lib/Db/Date.php37
-rw-r--r--lib/Db/DateMapper.php (renamed from db/datemapper.php)158
-rw-r--r--lib/Db/Event.php (renamed from db/event.php)100
-rw-r--r--lib/Db/EventMapper.php (renamed from db/eventmapper.php)228
-rw-r--r--lib/Db/Notification.php37
-rw-r--r--lib/Db/NotificationMapper.php (renamed from db/notificationmapper.php)158
-rw-r--r--lib/Db/Participation.php43
-rw-r--r--lib/Db/ParticipationMapper.php (renamed from db/participationmapper.php)190
-rw-r--r--lib/Db/ParticipationText.php43
-rw-r--r--lib/Db/ParticipationTextMapper.php (renamed from db/participationtextmapper.php)190
-rw-r--r--lib/Db/Text.php37
-rw-r--r--lib/Db/TextMapper.php (renamed from db/textmapper.php)128
-rw-r--r--templates/create.tmpl.php69
-rw-r--r--templates/goto.tmpl.php51
-rw-r--r--templates/main.tmpl.php90
-rw-r--r--templates/no.acc.tmpl.php24
35 files changed, 1664 insertions, 1075 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..89f760d2
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+
+# Set default charset
+charset = utf-8
+
+# 4 space indentation
+indent_style = space
+indent_size = 4
diff --git a/appinfo/app.php b/appinfo/app.php
index 113fc033..9d5dc861 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -1,34 +1,25 @@
<?php
/**
- * ownCloud - polls
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- * @copyright Vinzenz Rosenkranz 2016
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
-namespace OCA\Polls\AppInfo;
-
-$l = \OC::$server->getL10N('polls');
-
-\OC::$server->getNavigationManager()->add(array(
- // the string under which your app will be referenced in owncloud
- 'id' => 'polls',
-
- // sorting weight for the navigation. The higher the number, the higher
- // will it be listed in the navigation
- 'order' => 77,
-
- // the route that will be shown on startup
- 'href' => \OC::$server->getURLGenerator()->linkToRoute('polls.page.index'),
-
- // the icon that will be shown in the navigation
- // this file needs to exist in img/
- 'icon' => \OC::$server->getURLGenerator()->imagePath('polls', 'app-logo-polls.svg'),
-
- // the title of your application. This will be used in the
- // navigation or on the settings page of your app
- 'name' => $l->t('Polls')
-));
+$app = new \OCA\Polls\AppInfo\Application();
+$app->registerNavigationEntry();
diff --git a/appinfo/application.php b/appinfo/application.php
deleted file mode 100644
index 0cf11dc0..00000000
--- a/appinfo/application.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-/**
- * ownCloud - polls
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- * @copyright Vinzenz Rosenkranz 2016
- */
-
-namespace OCA\Polls\AppInfo;
-
-
-use OC\AppFramework\Utility\SimpleContainer;
-use \OCP\AppFramework\App;
-use \OCA\Polls\Db\AccessMapper;
-use \OCA\Polls\Db\CommentMapper;
-use \OCA\Polls\Db\DateMapper;
-use \OCA\Polls\Db\EventMapper;
-use \OCA\Polls\Db\NotificationMapper;
-use \OCA\Polls\Db\ParticipationMapper;
-use \OCA\Polls\Db\ParticipationTextMapper;
-use \OCA\Polls\Db\TextMapper;
-use \OCA\Polls\Controller\PageController;
-
-
-class Application extends App {
-
-
- public function __construct (array $urlParams=array()) {
- parent::__construct('polls', $urlParams);
-
- $container = $this->getContainer();
- $server = $container->getServer();
-
- /**
- * Controllers
- */
- $container->registerService('PageController', function($c) use($server) {
- /** @var SimpleContainer $c */
- return new PageController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->query('UserManager'),
- $c->query('GroupManager'),
- $c->query('AvatarManager'),
- $c->query('Logger'),
- $c->query('L10N'),
- $c->query('ServerContainer')->getURLGenerator(),
- $c->query('UserId'),
- $c->query('AccessMapper'),
- $c->query('CommentMapper'),
- $c->query('DateMapper'),
- $c->query('EventMapper'),
- $c->query('NotificationMapper'),
- $c->query('ParticipationMapper'),
- $c->query('ParticipationTextMapper'),
- $c->query('TextMapper')
- );
- });
-
- $container->registerService('UserManager', function($c) {
- return $c->query('ServerContainer')->getUserManager();
- });
-
- $container->registerService('GroupManager', function($c) {
- return $c->query('ServerContainer')->getGroupManager();
- });
-
- $container->registerService('AvatarManager', function($c) {
- return $c->query('ServerContainer')->getAvatarManager();
- });
-
- $container->registerService('Logger', function($c) {
- return $c->query('ServerContainer')->getLogger();
- });
-
- $container->registerService('L10N', function($c) {
- return $c->query('ServerContainer')->getL10N($c->query('AppName'));
- });
-
- $container->registerService('AccessMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new AccessMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('CommentMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new CommentMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('DateMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new DateMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('EventMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new EventMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('NotificationMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new NotificationMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('ParticipationMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new ParticipationMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('ParticipationTextMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new ParticipationTextMapper(
- $server->getDatabaseConnection()
- );
- });
- $container->registerService('TextMapper', function($c) use ($server) {
- /** @var SimpleContainer $c */
- return new TextMapper(
- $server->getDatabaseConnection()
- );
- });
-
- }
-
-
-}
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 312856e1..51476186 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -1,25 +1,28 @@
<?php
/**
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- * @copyright Vinzenz Rosenkranz 2016
- */
-
-namespace OCA\Polls\AppInfo;
-
-/**
- * Create your routes in here. The name is the lowercase name of the controller
- * without the controller part, the stuff after the hash is the method.
- * e.g. page#index -> PageController->index()
*
- * The controller class has to be registered in the application.php file since
- * it's instantiated in there
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
-$application = new Application();
-$application->registerRoutes($this, array('routes' => array(
+$app = new \OCA\Polls\AppInfo\Application();
+$app->registerRoutes($this, array('routes' => array(
array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'),
array('name' => 'page#goto_poll', 'url' => '/poll/{hash}', 'verb' => 'GET'),
array('name' => 'page#edit_poll', 'url' => '/edit/{hash}', 'verb' => 'GET'),
diff --git a/db/access.php b/db/access.php
deleted file mode 100644
index e5af9bbd..00000000
--- a/db/access.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method integer getPId()
- * @method void setPId(integer $value)
- * @method string getAccessType()
- * @method void setAccessType(string $value)
- */
-class Access extends Entity {
- public $pId;
- public $accessType;
-}
diff --git a/db/comment.php b/db/comment.php
deleted file mode 100644
index c6fca666..00000000
--- a/db/comment.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method string getUserId()
- * @method void setUserId(string $value)
- * @method string getDt()
- * @method void setDt(string $value)
- * @method string getComment()
- * @method void setComment(string $value)
- * @method integer getPollId()
- * @method void setPollId(integer $value)
- */
-class Comment extends Entity {
- public $userId;
- public $dt;
- public $comment;
- public $pollId;
-}
diff --git a/db/date.php b/db/date.php
deleted file mode 100644
index c5bad99b..00000000
--- a/db/date.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method timestamp getDt()
- * @method void setDt(timestamp $value)
- * @method integer getPollId()
- * @method void setPollId(integer $value
- */
-class Date extends Entity {
- public $dt;
- public $pollId;
-}
diff --git a/db/notification.php b/db/notification.php
deleted file mode 100644
index 2144fec9..00000000
--- a/db/notification.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method string getUserId()
- * @method void setUserId(string $value)
- * @method string getPollId()
- * @method void setPollId(string $value)
- */
-class Notification extends Entity {
- public $userId;
- public $pollId;
-}
diff --git a/db/participation.php b/db/participation.php
deleted file mode 100644
index c744f8f8..00000000
--- a/db/participation.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method timestamp getDt()
- * @method void setDt(timestamp $value)
- * @method string getUserId()
- * @method void setUserId(string $value)
- * @method integer getPollId()
- * @method void setPollId(integer $value)
- * @method integer getType()
- * @method void setType(integer $value)
- */
-class Participation extends Entity {
- public $dt;
- public $userId;
- public $pollId;
- public $type;
-}
diff --git a/db/participationtext.php b/db/participationtext.php
deleted file mode 100644
index edc65787..00000000
--- a/db/participationtext.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method text getText()
- * @method void setText(text $value)
- * @method string getUserId()
- * @method void setUserId(string $value)
- * @method integer getPollId()
- * @method void setPollId(integer $value)
- * @method integer getType()
- * @method void setType(integer $value)
- */
-class ParticipationText extends Entity {
- public $text;
- public $userId;
- public $pollId;
- public $type;
-}
diff --git a/db/text.php b/db/text.php
deleted file mode 100644
index dd2deb9e..00000000
--- a/db/text.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method string getText()
- * @method void setText(string $value)
- * @method integer getPollId()
- * @method void setPollId(integer $value
- */
-class Text extends Entity {
- public $text;
- public $pollId;
-}
diff --git a/index.php b/index.php
index 275f30f7..7aed9ea1 100644
--- a/index.php
+++ b/index.php
@@ -1,14 +1,31 @@
<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
-// Check if we are a user
-//OCP\User::checkLoggedIn();
\OC::$server->getNavigationManager()->setActiveEntry( 'polls' );
-//echo '<pre>r_uri: '; print_r($_SERVER); '</pre>';
if (OCP\User::isLoggedIn()) {
$tmpl = new OCP\Template('polls', 'main', 'user');
-}
-else {
+} else {
$tmpl = new OCP\Template('polls', 'main', 'base');
}
$tmpl->printPage();
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
new file mode 100644
index 00000000..0c660506
--- /dev/null
+++ b/lib/AppInfo/Application.php
@@ -0,0 +1,175 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\AppInfo;
+
+use OC\AppFramework\Utility\SimpleContainer;
+use \OCP\AppFramework\App;
+use \OCA\Polls\Db\AccessMapper;
+use \OCA\Polls\Db\CommentMapper;
+use \OCA\Polls\Db\DateMapper;
+use \OCA\Polls\Db\EventMapper;
+use \OCA\Polls\Db\NotificationMapper;
+use \OCA\Polls\Db\ParticipationMapper;
+use \OCA\Polls\Db\ParticipationTextMapper;
+use \OCA\Polls\Db\TextMapper;
+use \OCA\Polls\Controller\PageController;
+
+class Application extends App {
+
+ /**
+ * Application constructor.
+ *
+ * @param array $urlParams
+ */
+ public function __construct(array $urlParams = array()) {
+ parent::__construct('polls', $urlParams);
+
+ $container = $this->getContainer();
+ $server = $container->getServer();
+
+ /**
+ * Controllers
+ */
+ $container->registerService('PageController', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new PageController(
+ $c->query('AppName'),
+ $c->query('Request'),
+ $c->query('UserManager'),
+ $c->query('GroupManager'),
+ $c->query('AvatarManager'),
+ $c->query('Logger'),
+ $c->query('L10N'),
+ $c->query('ServerContainer')->getURLGenerator(),
+ $c->query('UserId'),
+ $c->query('AccessMapper'),
+ $c->query('CommentMapper'),
+ $c->query('DateMapper'),
+ $c->query('EventMapper'),
+ $c->query('NotificationMapper'),
+ $c->query('ParticipationMapper'),
+ $c->query('ParticipationTextMapper'),
+ $c->query('TextMapper')
+ );
+ });
+
+ $container->registerService('UserManager', function ($c) {
+ /** @var SimpleContainer $c */
+ return $c->query('ServerContainer')->getUserManager();
+ });
+
+ $container->registerService('GroupManager', function ($c) {
+ /** @var SimpleContainer $c */
+ return $c->query('ServerContainer')->getGroupManager();
+ });
+
+ $container->registerService('AvatarManager', function ($c) {
+ /** @var SimpleContainer $c */
+ return $c->query('ServerContainer')->getAvatarManager();
+ });
+
+ $container->registerService('Logger', function ($c) {
+ /** @var SimpleContainer $c */
+ return $c->query('ServerContainer')->getLogger();
+ });
+
+ $container->registerService('L10N', function ($c) {
+ return $c->query('ServerContainer')->getL10N($c->query('AppName'));
+ });
+
+ $container->registerService('AccessMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new AccessMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('CommentMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new CommentMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('DateMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new DateMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('EventMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new EventMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('NotificationMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new NotificationMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('ParticipationMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new ParticipationMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('ParticipationTextMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new ParticipationTextMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+
+ $container->registerService('TextMapper', function ($c) use ($server) {
+ /** @var SimpleContainer $c */
+ return new TextMapper(
+ $server->getDatabaseConnection()
+ );
+ });
+ }
+
+ /**
+ * Register navigation entry for main navigation.
+ */
+ public function registerNavigationEntry() {
+ $container = $this->getContainer();
+ $container->query('OCP\INavigationManager')->add(function () use ($container) {
+ $urlGenerator = $container->query('OCP\IURLGenerator');
+ $l10n = $container->query('OCP\IL10N');
+ return [
+ 'id' => 'polls',
+ 'order' => 77,
+ 'href' => $urlGenerator->linkToRoute('polls.page.index'),
+ 'icon' => $urlGenerator->imagePath('polls', 'app-logo-polls.svg'),
+ 'name' => $l10n->t('Polls')
+ ];
+ });
+ }
+}
diff --git a/controller/pagecontroller.php b/lib/Controller/PageController.php
index b1cf5f45..408a01bb 100644
--- a/controller/pagecontroller.php
+++ b/lib/Controller/PageController.php
@@ -1,17 +1,28 @@
<?php
/**
- * ownCloud - polls
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- * @copyright Vinzenz Rosenkranz 2016
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
namespace OCA\Polls\Controller;
-use \OCA\Polls\Db\Access;
use \OCA\Polls\Db\Comment;
use \OCA\Polls\Db\Date;
use \OCA\Polls\Db\Event;
@@ -59,8 +70,7 @@ class PageController extends Controller {
private $trans;
private $userMgr;
private $groupManager;
- private $allowedGroups;
- private $allowedUsers;
+
public function __construct($appName, IRequest $request,
IUserManager $manager,
IGroupManager $groupManager,
@@ -97,12 +107,6 @@ class PageController extends Controller {
}
/**
- * CAUTION: the @Stuff turn off security checks, for this page no admin is
- * required and no CSRF check. If you don't know what CSRF is, read
- * it up in the docs or you might create a security hole. This is
- * basically the only required method to add this exemption, don't
- * add it to any other method if you don't exactly know what it does
- *
* @NoAdminRequired
* @NoCSRFRequired
*/
@@ -121,17 +125,23 @@ class PageController extends Controller {
private function sendNotifications($pollId, $from) {
$poll = $this->eventMapper->find($pollId);
$notifs = $this->notificationMapper->findAllByPoll($pollId);
- foreach($notifs as $notif) {
- if($from === $notif->getUserId()) continue;
+ foreach ($notifs as $notif) {
+ if ($from === $notif->getUserId()) {
+ continue;
+ }
$email = \OC::$server->getConfig()->getUserValue($notif->getUserId(), 'settings', 'email');
- if(strlen($email) === 0 || !isset($email)) continue;
+ if (strlen($email) === 0 || !isset($email)) {
+ continue;
+ }
$url = \OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getURLGenerator()->linkToRoute('polls.page.goto_poll', array('hash' => $poll->getHash())));
$recUser = $this->userMgr->get($notif->getUserId());
$sendUser = $this->userMgr->get($from);
$rec = "";
- if($recUser !== null) $rec = $recUser->getDisplayName();
- if($sendUser !== null) {
+ if ($recUser !== null) {
+ $rec = $recUser->getDisplayName();
+ }
+ if ($sendUser !== null) {
$sender = $sendUser->getDisplayName();
} else {
$sender = $from;
@@ -168,11 +178,10 @@ class PageController extends Controller {
*/
public function gotoPoll($hash) {
$poll = $this->eventMapper->findByHash($hash);
- if($poll->getType() == '0') {
+ if ($poll->getType() == '0') {
$dates = $this->dateMapper->findByPoll($poll->getId());
$votes = $this->participationMapper->findByPoll($poll->getId());
- }
- else {
+ } else {
$dates = $this->textMapper->findByPoll($poll->getId());
$votes = $this->participationTextMapper->findByPoll($poll->getId());
}
@@ -182,7 +191,7 @@ class PageController extends Controller {
} catch(\OCP\AppFramework\Db\DoesNotExistException $e) {
$notification = null;
}
- if($this->hasUserAccess($poll)) {
+ if ($this->hasUserAccess($poll)) {
return new TemplateResponse('polls', 'goto.tmpl', ['poll' => $poll, 'dates' => $dates, 'comments' => $comments, 'votes' => $votes, 'notification' => $notification, 'userId' => $this->userId, 'userMgr' => $this->manager, 'urlGenerator' => $this->urlGenerator, 'avatarManager' => $this->avatarManager]);
} else {
\OCP\User::checkLoggedIn();
@@ -213,9 +222,14 @@ class PageController extends Controller {
*/
public function editPoll($hash) {
$poll = $this->eventMapper->findByHash($hash);
- if($this->userId !== $poll->getOwner()) return new TemplateResponse('polls', 'no.create.tmpl');
- if($poll->getType() == '0') $dates = $this->dateMapper->findByPoll($poll->getId());
- else $dates = $this->textMapper->findByPoll($poll->getId());
+ if ($this->userId !== $poll->getOwner()) {
+ return new TemplateResponse('polls', 'no.create.tmpl');
+ }
+ if ($poll->getType() == '0') {
+ $dates = $this->dateMapper->findByPoll($poll->getId());
+ } else {
+ $dates = $this->textMapper->findByPoll($poll->getId());
+ }
return new TemplateResponse('polls', 'create.tmpl', ['poll' => $poll, 'dates' => $dates, 'userId' => $this->userId, 'userMgr' => $this->manager, 'urlGenerator' => $this->urlGenerator]);
}
@@ -228,14 +242,18 @@ class PageController extends Controller {
$event->setTitle(htmlspecialchars($pollTitle));
$event->setDescription(htmlspecialchars($pollDesc));
- if($accessType === 'select') {
+ if ($accessType === 'select') {
if (isset($accessValues)) {
$accessValues = json_decode($accessValues);
- if($accessValues !== null) {
+ if ($accessValues !== null) {
$groups = array();
$users = array();
- if($accessValues->groups !== null) $groups = $accessValues->groups;
- if($accessValues->users !== null) $users = $accessValues->users;
+ if ($accessValues->groups !== null) {
+ $groups = $accessValues->groups;
+ }
+ if ($accessValues->users !== null) {
+ $users = $accessValues->users;
+ }
$accessType = '';
foreach ($groups as $gid) {
$accessType .= $gid . ';';
@@ -251,14 +269,14 @@ class PageController extends Controller {
$chosenDates = json_decode($chosenDates);
$expire = null;
- if($expireTs !== null && $expireTs !== '') {
+ if ($expireTs !== null && $expireTs !== '') {
$expire = date('Y-m-d H:i:s', $expireTs + 60*60*24); //add one day, so it expires at the end of a day
}
$event->setExpire($expire);
$this->dateMapper->deleteByPoll($pollId);
$this->textMapper->deleteByPoll($pollId);
- if($pollType === 'event') {
+ if ($pollType === 'event') {
$event->setType(0);
$this->eventMapper->update($event);
sort($chosenDates);
@@ -271,7 +289,7 @@ class PageController extends Controller {
} else {
$event->setType(1);
$this->eventMapper->update($event);
- foreach($chosenDates as $el) {
+ foreach ($chosenDates as $el) {
$text = new Text();
$text->setText($el);
$text->setPollId($pollId);
@@ -310,11 +328,15 @@ class PageController extends Controller {
if ($accessType === 'select') {
if (isset($accessValues)) {
$accessValues = json_decode($accessValues);
- if($accessValues !== null) {
+ if ($accessValues !== null) {
$groups = array();
$users = array();
- if($accessValues->groups !== null) $groups = $accessValues->groups;
- if($accessValues->users !== null) $users = $accessValues->users;
+ if ($accessValues->groups !== null) {
+ $groups = $accessValues->groups;
+ }
+ if ($accessValues->users !== null) {
+ $users = $accessValues->users;
+ }
$accessType = '';
foreach ($groups as $gid) {
$accessType .= $gid . ';';
@@ -330,13 +352,12 @@ class PageController extends Controller {
$chosenDates = json_decode($chosenDates);
$expire = null;
- if($expireTs !== null && $expireTs !== '') {
+ if ($expireTs !== null && $expireTs !== '') {
$expire = date('Y-m-d H:i:s', $expireTs + 60*60*24); //add one day, so it expires at the end of a day
}
$event->setExpire($expire);
- $poll_id = -1;
- if($pollType === 'event') {
+ if ($pollType === 'event') {
$event->setType(0);
$ins = $this->eventMapper->insert($event);
$poll_id = $ins->getId();
@@ -352,7 +373,7 @@ class PageController extends Controller {
$ins = $this->eventMapper->insert($event);
$poll_id = $ins->getId();
$cnt = 1;
- foreach($chosenDates as $el) {
+ foreach ($chosenDates as $el) {
$text = new Text();
$text->setText($el . '_' . $cnt);
$text->setPollId($poll_id);
@@ -370,8 +391,8 @@ class PageController extends Controller {
* @PublicPage
*/
public function insertVote($pollId, $userId, $types, $dates, $notif, $changed) {
- if($this->userId !== null) {
- if($notif === 'true') {
+ if ($this->userId !== null) {
+ if ($notif === 'true') {
try {
//check if user already set notification for this poll
$this->notificationMapper->findByUserAndPoll($pollId, $userId);
@@ -392,16 +413,20 @@ class PageController extends Controller {
}
}
} else {
+ // TODO: Needs investigation!
$userId = $userId;
}
$poll = $this->eventMapper->find($pollId);
- if($changed === 'true') {
+ if ($changed === 'true') {
$dates = json_decode($dates);
$types = json_decode($types);
- if($poll->getType() == '0') $this->participationMapper->deleteByPollAndUser($pollId, $userId);
- else $this->participationTextMapper->deleteByPollAndUser($pollId, $userId);
- for($i=0; $i<count($dates); $i++) {
- if($poll->getType() == '0') {
+ if ($poll->getType() == '0') {
+ $this->participationMapper->deleteByPollAndUser($pollId, $userId);
+ } else {
+ $this->participationTextMapper->deleteByPollAndUser($pollId, $userId);
+ }
+ for ($i=0; $i<count($dates); $i++) {
+ if ($poll->getType() == '0') {
$part = new Participation();
$part->setPollId($pollId);
$part->setUserId($userId);
@@ -441,7 +466,7 @@ class PageController extends Controller {
$this->sendNotifications($pollId, $userId);
$hash = $this->eventMapper->find($pollId)->getHash();
$url = $this->urlGenerator->linkToRoute('polls.page.goto_poll', ['hash' => $hash]);
- if($this->manager->get($userId) !== null) {
+ if ($this->manager->get($userId) !== null) {
$newUserId = $this->manager->get($userId)->getDisplayName();
} else {
$newUserId = $userId;
@@ -466,15 +491,15 @@ class PageController extends Controller {
$groups = $this->groupManager->search($searchTerm);
$gids = array();
$sgids = array();
- foreach($selectedGroups as $sg) {
+ foreach ($selectedGroups as $sg) {
$sgids[] = str_replace('group_', '', $sg);
}
- foreach($groups as $g) {
+ foreach ($groups as $g) {
$gids[] = $g->getGID();
}
$diffGids = array_diff($gids, $sgids);
$gids = array();
- foreach($diffGids as $g) {
+ foreach ($diffGids as $g) {
$gids[] = ['gid' => $g, 'isGroup' => true];
}
return $gids;
@@ -490,19 +515,19 @@ class PageController extends Controller {
$userNames = $this->userMgr->searchDisplayName($searchTerm);
$users = array();
$susers = array();
- foreach($selectedUsers as $su) {
+ foreach ($selectedUsers as $su) {
$susers[] = str_replace('user_', '', $su);
}
- foreach($userNames as $u) {
+ foreach ($userNames as $u) {
$alreadyAdded = false;
- foreach($susers as &$su) {
- if($su === $u->getUID()) {
+ foreach ($susers as &$su) {
+ if ($su === $u->getUID()) {
unset($su);
$alreadyAdded = true;
break;
}
}
- if(!$alreadyAdded) {
+ if (!$alreadyAdded) {
$users[] = array('uid' => $u->getUID(), 'displayName' => $u->getDisplayName(), 'isGroup' => false);
} else {
continue;
@@ -528,28 +553,37 @@ class PageController extends Controller {
else return $this->eventMapper->findAllForUserWithInfo($user);
}
- function getGroups() {
- // $this->requireLogin();
- if (class_exists('\OC_Group', true)) {
- // Nextcloud <= 11, ownCloud
- return \OC_Group::getUserGroups($this->$userId);
- }
- // Nextcloud >= 12
- $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
- return array_map(function ($group) {
- return $group->getGID();
- }, $groups);
+ public function getGroups() {
+ // $this->requireLogin();
+ if (class_exists('\OC_Group', true)) {
+ // Nextcloud <= 11, ownCloud
+ return \OC_Group::getUserGroups($this->$userId);
}
-
+ // Nextcloud >= 12
+ $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
+ return array_map(function ($group) {
+ return $group->getGID();
+ }, $groups);
+ }
private function hasUserAccess($poll) {
$access = $poll->getAccess();
$owner = $poll->getOwner();
- if ($access === 'public') return true;
- if ($access === 'hidden') return true;
- if ($this->userId === null) return false;
- if ($access === 'registered') return true;
- if ($owner === $this->userId) return true;
+ if ($access === 'public') {
+ return true;
+ }
+ if ($access === 'hidden') {
+ return true;
+ }
+ if ($this->userId === null) {
+ return false;
+ }
+ if ($access === 'registered') {
+ return true;
+ }
+ if ($owner === $this->userId) {
+ return true;
+ }
\OCP\Util::writeLog("polls", $this->userId, \OCP\Util::ERROR);
$user_groups = $this->getGroups();
$arr = explode(';', $access);
@@ -557,15 +591,17 @@ class PageController extends Controller {
if (strpos($item, 'group_') === 0) {
$grp = substr($item, 6);
foreach ($user_groups as $user_group) {
- if ($user_group === $grp) return true;
+ if ($user_group === $grp) {
+ return true;
+ }
}
} else if (strpos($item, 'user_') === 0) {
$usr = substr($item, 5);
- if ($usr === \OCP\User::getUser()) return true;
+ if ($usr === \OCP\User::getUser()) {
+ return true;
+ }
}
}
return false;
}
}
-
-
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php
new file mode 100644
index 00000000..70fd9691
--- /dev/null
+++ b/lib/Controller/PollController.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Controller;
+
+use \OCP\AppFramework\Controller;
+
+class PollController extends Controller {
+
+}
diff --git a/lib/Db/Access.php b/lib/Db/Access.php
new file mode 100644
index 00000000..6456cf74
--- /dev/null
+++ b/lib/Db/Access.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method integer getPId()
+ * @method void setPId(integer $value)
+ * @method string getAccessType()
+ * @method void setAccessType(string $value)
+ */
+class Access extends Entity {
+ public $pId;
+ public $accessType;
+}
diff --git a/db/accessmapper.php b/lib/Db/AccessMapper.php
index e1109335..fa391214 100644
--- a/db/accessmapper.php
+++ b/lib/Db/AccessMapper.php
@@ -1,49 +1,71 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class AccessMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_access', '\OCA\Polls\Db\Access');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Favorite
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_access` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return Favorite[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_access` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Favorite[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_access`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class AccessMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_access', '\OCA\Polls\Db\Access');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Favorite
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_access` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return Favorite[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_access` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Favorite[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_access`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+}
diff --git a/lib/Db/Comment.php b/lib/Db/Comment.php
new file mode 100644
index 00000000..fa0481f1
--- /dev/null
+++ b/lib/Db/Comment.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method string getUserId()
+ * @method void setUserId(string $value)
+ * @method string getDt()
+ * @method void setDt(string $value)
+ * @method string getComment()
+ * @method void setComment(string $value)
+ * @method integer getPollId()
+ * @method void setPollId(integer $value)
+ */
+class Comment extends Entity {
+ public $userId;
+ public $dt;
+ public $comment;
+ public $pollId;
+}
diff --git a/db/commentmapper.php b/lib/Db/CommentMapper.php
index 09d43abe..10cad506 100644
--- a/db/commentmapper.php
+++ b/lib/Db/CommentMapper.php
@@ -1,79 +1,101 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class CommentMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Comment
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_comments` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return Comment[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_comments` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Comment[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_comments`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param string $userId
- * @param int $limit
- * @param int $offset
- * @return Comment[]
- */
- public function findDistinctByUser($userId, $limit=null, $offset=null) {
- $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_comments` WHERE user_id=?';
- return $this->findEntities($sql, [$userId], $limit, $offset);
- }
-
- /**
- * @param string $userId
- * @param int $limit
- * @param int $offset
- * @return Comment[]
- */
- public function findByPoll($pollId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_comments` WHERE poll_id=? ORDER BY Dt DESC';
- return $this->findEntities($sql, [$pollId], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- */
- public function deleteByPoll($pollId) {
- $sql = 'DELETE FROM `*PREFIX*polls_comments` WHERE poll_id=?';
- $this->execute($sql, [$pollId]);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class CommentMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Comment
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_comments` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return Comment[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_comments` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Comment[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_comments`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return Comment[]
+ */
+ public function findDistinctByUser($userId, $limit=null, $offset=null) {
+ $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_comments` WHERE user_id=?';
+ return $this->findEntities($sql, [$userId], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return Comment[]
+ */
+ public function findByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_comments` WHERE poll_id=? ORDER BY Dt DESC';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ */
+ public function deleteByPoll($pollId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_comments` WHERE poll_id=?';
+ $this->execute($sql, [$pollId]);
+ }
+}
diff --git a/lib/Db/Date.php b/lib/Db/Date.php
new file mode 100644
index 00000000..05ff0a06
--- /dev/null
+++ b/lib/Db/Date.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method timestamp getDt()
+ * @method void setDt(timestamp $value)
+ * @method integer getPollId()
+ * @method void setPollId(integer $value)
+ */
+class Date extends Entity {
+ public $dt;
+ public $pollId;
+}
diff --git a/db/datemapper.php b/lib/Db/DateMapper.php
index 7c2e1211..9a16ebda 100644
--- a/db/datemapper.php
+++ b/lib/Db/DateMapper.php
@@ -1,68 +1,90 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class DateMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Date
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_dts` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return Date[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_dts` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Date[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_dts`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- * @param int $limit
- * @param int $offset
- * @return Date[]
- */
- public function findByPoll($pollId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_dts` WHERE poll_id=?';
- return $this->findEntities($sql, [$pollId], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- */
- public function deleteByPoll($pollId) {
- $sql = 'DELETE FROM `*PREFIX*polls_dts` WHERE poll_id=?';
- $this->execute($sql, [$pollId]);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class DateMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Date
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_dts` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return Date[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_dts` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Date[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_dts`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ * @param int $limit
+ * @param int $offset
+ * @return Date[]
+ */
+ public function findByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_dts` WHERE poll_id=?';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ */
+ public function deleteByPoll($pollId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_dts` WHERE poll_id=?';
+ $this->execute($sql, [$pollId]);
+ }
+}
diff --git a/db/event.php b/lib/Db/Event.php
index 5de8216b..8882adcb 100644
--- a/db/event.php
+++ b/lib/Db/Event.php
@@ -1,39 +1,61 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Entity;
-
-/**
- * @method integer getType()
- * @method void setType(integer $value)
- * @method string getTitle()
- * @method void setTitle(string $value)
- * @method string getDescription()
- * @method void setDescription(string $value)
- * @method string getOwner()
- * @method void setOwner(string $value)
- * @method timestamp getCreated()
- * @method void setCreated(timestamp $value)
- * @method string getAccess()
- * @method void setAccess(string $value)
- * @method timestamp getExpire()
- * @method void setExpire(timestamp $value)
- * @method string getHash()
- * @method void setHash(string $value)
- * @method integer getIsAnonymous()
- * @method void setIsAnonymous(integer $value)
- * @method integer getFullAnonymous()
- * @method void setFullAnonymous(integer $value)
- */
-class Event extends Entity {
- public $type;
- public $title;
- public $description;
- public $owner;
- public $created;
- public $access;
- public $expire;
- public $hash;
- public $isAnonymous;
- public $fullAnonymous;
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method integer getType()
+ * @method void setType(integer $value)
+ * @method string getTitle()
+ * @method void setTitle(string $value)
+ * @method string getDescription()
+ * @method void setDescription(string $value)
+ * @method string getOwner()
+ * @method void setOwner(string $value)
+ * @method timestamp getCreated()
+ * @method void setCreated(timestamp $value)
+ * @method string getAccess()
+ * @method void setAccess(string $value)
+ * @method timestamp getExpire()
+ * @method void setExpire(timestamp $value)
+ * @method string getHash()
+ * @method void setHash(string $value)
+ * @method integer getIsAnonymous()
+ * @method void setIsAnonymous(integer $value)
+ * @method integer getFullAnonymous()
+ * @method void setFullAnonymous(integer $value)
+ */
+class Event extends Entity {
+ public $type;
+ public $title;
+ public $description;
+ public $owner;
+ public $created;
+ public $access;
+ public $expire;
+ public $hash;
+ public $isAnonymous;
+ public $fullAnonymous;
+}
diff --git a/db/eventmapper.php b/lib/Db/EventMapper.php
index 21be7598..862bc475 100644
--- a/db/eventmapper.php
+++ b/lib/Db/EventMapper.php
@@ -1,103 +1,125 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class EventMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_events', '\OCA\Polls\Db\Event');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Event
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_events` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return Event[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_events` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Event[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_events`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Event
- */
- public function findByHash($hash, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_events` WHERE `hash`=?';
- return $this->findEntity($sql, [$hash], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Event[]
- */
- public function findAllForUser($userId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_events` WHERE `owner`=?';
- return $this->findEntities($sql, [$userId], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Event[]
- */
- public function findAllForUserWithInfo($userId, $limit=null, $offset=null) {
- $sql = 'SELECT DISTINCT *PREFIX*polls_events.id,
- *PREFIX*polls_events.hash,
- *PREFIX*polls_events.type,
- *PREFIX*polls_events.title,
- *PREFIX*polls_events.description,
- *PREFIX*polls_events.owner,
- *PREFIX*polls_events.created,
- *PREFIX*polls_events.access,
- *PREFIX*polls_events.expire,
- *PREFIX*polls_events.is_anonymous,
- *PREFIX*polls_events.full_anonymous
- FROM *PREFIX*polls_events
- LEFT JOIN *PREFIX*polls_particip
- ON *PREFIX*polls_events.id = *PREFIX*polls_particip.id
- LEFT JOIN *PREFIX*polls_comments
- ON *PREFIX*polls_events.id = *PREFIX*polls_comments.id
- WHERE
- (*PREFIX*polls_events.access =? and *PREFIX*polls_events.owner =?)
- OR
- *PREFIX*polls_events.access !=?
- OR
- *PREFIX*polls_particip.user_id =?
- OR
- *PREFIX*polls_comments.user_id =?
- ORDER BY created';
- return $this->findEntities($sql, ['hidden', $userId, 'hidden', $userId, $userId], $limit, $offset);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class EventMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_events', '\OCA\Polls\Db\Event');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Event
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_events` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return Event[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_events` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Event[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_events`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Event
+ */
+ public function findByHash($hash, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_events` WHERE `hash`=?';
+ return $this->findEntity($sql, [$hash], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Event[]
+ */
+ public function findAllForUser($userId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_events` WHERE `owner`=?';
+ return $this->findEntities($sql, [$userId], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Event[]
+ */
+ public function findAllForUserWithInfo($userId, $limit=null, $offset=null) {
+ $sql = 'SELECT DISTINCT *PREFIX*polls_events.id,
+ *PREFIX*polls_events.hash,
+ *PREFIX*polls_events.type,
+ *PREFIX*polls_events.title,
+ *PREFIX*polls_events.description,
+ *PREFIX*polls_events.owner,
+ *PREFIX*polls_events.created,
+ *PREFIX*polls_events.access,
+ *PREFIX*polls_events.expire,
+ *PREFIX*polls_events.is_anonymous,
+ *PREFIX*polls_events.full_anonymous
+ FROM *PREFIX*polls_events
+ LEFT JOIN *PREFIX*polls_particip
+ ON *PREFIX*polls_events.id = *PREFIX*polls_particip.id
+ LEFT JOIN *PREFIX*polls_comments
+ ON *PREFIX*polls_events.id = *PREFIX*polls_comments.id
+ WHERE
+ (*PREFIX*polls_events.access =? and *PREFIX*polls_events.owner =?)
+ OR
+ *PREFIX*polls_events.access !=?
+ OR
+ *PREFIX*polls_particip.user_id =?
+ OR
+ *PREFIX*polls_comments.user_id =?
+ ORDER BY created';
+ return $this->findEntities($sql, ['hidden', $userId, 'hidden', $userId, $userId], $limit, $offset);
+ }
+}
diff --git a/lib/Db/Notification.php b/lib/Db/Notification.php
new file mode 100644
index 00000000..6b2d4408
--- /dev/null
+++ b/lib/Db/Notification.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method string getUserId()
+ * @method void setUserId(string $value)
+ * @method string getPollId()
+ * @method void setPollId(string $value)
+ */
+class Notification extends Entity {
+ public $userId;
+ public $pollId;
+}
diff --git a/db/notificationmapper.php b/lib/Db/NotificationMapper.php
index fe96380c..95978f0f 100644
--- a/db/notificationmapper.php
+++ b/lib/Db/NotificationMapper.php
@@ -1,68 +1,90 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class NotificationMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Notification
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_notif` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return Notification[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_notif` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Notification[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_notif`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Notification[]
- */
- public function findAllByPoll($pollId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_notif` WHERE `poll_id`=?';
- return $this->findEntities($sql, [$pollId], $limit, $offset);
- }
-
- /**
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @return Notification
- */
- public function findByUserAndPoll($pollId, $userId) {
- $sql = 'SELECT * FROM `*PREFIX*polls_notif` WHERE `poll_id`=? AND `user_id`=?';
- return $this->findEntity($sql, [$pollId, $userId]);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class NotificationMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Notification
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_notif` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return Notification[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_notif` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Notification[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_notif`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Notification[]
+ */
+ public function findAllByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_notif` WHERE `poll_id`=?';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @return Notification
+ */
+ public function findByUserAndPoll($pollId, $userId) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_notif` WHERE `poll_id`=? AND `user_id`=?';
+ return $this->findEntity($sql, [$pollId, $userId]);
+ }
+}
diff --git a/lib/Db/Participation.php b/lib/Db/Participation.php
new file mode 100644
index 00000000..8e343e18
--- /dev/null
+++ b/lib/Db/Participation.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method timestamp getDt()
+ * @method void setDt(timestamp $value)
+ * @method string getUserId()
+ * @method void setUserId(string $value)
+ * @method integer getPollId()
+ * @method void setPollId(integer $value)
+ * @method integer getType()
+ * @method void setType(integer $value)
+ */
+class Participation extends Entity {
+ public $dt;
+ public $userId;
+ public $pollId;
+ public $type;
+}
diff --git a/db/participationmapper.php b/lib/Db/ParticipationMapper.php
index e7dc1485..054e1d90 100644
--- a/db/participationmapper.php
+++ b/lib/Db/ParticipationMapper.php
@@ -1,84 +1,106 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class ParticipationMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_particip', '\OCA\Polls\Db\Participation');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Participation
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- public function deleteByPollAndUser($pollId, $userId) {
- $sql = 'DELETE FROM `*PREFIX*polls_particip` WHERE poll_id=? AND user_id=?';
- $this->execute($sql, [$pollId, $userId]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return Participation[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Participation[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param string $userId
- * @param int $limit
- * @param int $offset
- * @return Participation[]
- */
- public function findDistinctByUser($userId, $limit=null, $offset=null) {
- $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_particip` WHERE user_id=?';
- return $this->findEntities($sql, [$userId], $limit, $offset);
- }
-
- /**
- * @param string $userId
- * @param int $limit
- * @param int $offset
- * @return Participation[]
- */
- public function findByPoll($pollId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip` WHERE poll_id=?';
- return $this->findEntities($sql, [$pollId], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- */
- public function deleteByPoll($pollId) {
- $sql = 'DELETE FROM `*PREFIX*polls_particip` WHERE poll_id=?';
- $this->execute($sql, [$pollId]);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class ParticipationMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_particip', '\OCA\Polls\Db\Participation');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Participation
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ public function deleteByPollAndUser($pollId, $userId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_particip` WHERE poll_id=? AND user_id=?';
+ $this->execute($sql, [$pollId, $userId]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return Participation[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Participation[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return Participation[]
+ */
+ public function findDistinctByUser($userId, $limit=null, $offset=null) {
+ $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_particip` WHERE user_id=?';
+ return $this->findEntities($sql, [$userId], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return Participation[]
+ */
+ public function findByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip` WHERE poll_id=?';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ */
+ public function deleteByPoll($pollId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_particip` WHERE poll_id=?';
+ $this->execute($sql, [$pollId]);
+ }
+}
diff --git a/lib/Db/ParticipationText.php b/lib/Db/ParticipationText.php
new file mode 100644
index 00000000..56ac2415
--- /dev/null
+++ b/lib/Db/ParticipationText.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method text getText()
+ * @method void setText(text $value)
+ * @method string getUserId()
+ * @method void setUserId(string $value)
+ * @method integer getPollId()
+ * @method void setPollId(integer $value)
+ * @method integer getType()
+ * @method void setType(integer $value)
+ */
+class ParticipationText extends Entity {
+ public $text;
+ public $userId;
+ public $pollId;
+ public $type;
+}
diff --git a/db/participationtextmapper.php b/lib/Db/ParticipationTextMapper.php
index 0f30ca94..efa30820 100644
--- a/db/participationtextmapper.php
+++ b/lib/Db/ParticipationTextMapper.php
@@ -1,84 +1,106 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class ParticipationTextMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_particip_text', '\OCA\Polls\Db\ParticipationText');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return ParticipationText
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- public function deleteByPollAndUser($pollId, $userId) {
- $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=? AND user_id=?';
- $this->execute($sql, [$pollId, $userId]);
- }
-
- /**
- * @param string $userId
- * @param string $from
- * @param string $until
- * @param int $limit
- * @param int $offset
- * @return ParticipationText[]
- */
- public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` '.
- 'WHERE `userId` = ?'.
- 'AND `timestamp` BETWEEN ? and ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return ParticipationText[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip_text`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param string $userId
- * @param int $limit
- * @param int $offset
- * @return ParticipationText[]
- */
- public function findDistinctByUser($userId, $limit=null, $offset=null) {
- $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_particip_text` WHERE user_id=?';
- return $this->findEntities($sql, [$userId], $limit, $offset);
- }
-
- /**
- * @param string $userId
- * @param int $limit
- * @param int $offset
- * @return ParticipationText[]
- */
- public function findByPoll($pollId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
- return $this->findEntities($sql, [$pollId], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- */
- public function deleteByPoll($pollId) {
- $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
- $this->execute($sql, [$pollId]);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class ParticipationTextMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_particip_text', '\OCA\Polls\Db\ParticipationText');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return ParticipationText
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ public function deleteByPollAndUser($pollId, $userId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=? AND user_id=?';
+ $this->execute($sql, [$pollId, $userId]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findDistinctByUser($userId, $limit=null, $offset=null) {
+ $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_particip_text` WHERE user_id=?';
+ return $this->findEntities($sql, [$userId], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ */
+ public function deleteByPoll($pollId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
+ $this->execute($sql, [$pollId]);
+ }
+}
diff --git a/lib/Db/Text.php b/lib/Db/Text.php
new file mode 100644
index 00000000..e98c168b
--- /dev/null
+++ b/lib/Db/Text.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method string getText()
+ * @method void setText(string $value)
+ * @method integer getPollId()
+ * @method void setPollId(integer $value)
+ */
+class Text extends Entity {
+ public $text;
+ public $pollId;
+}
diff --git a/db/textmapper.php b/lib/Db/TextMapper.php
index 22f6072a..dde08890 100644
--- a/db/textmapper.php
+++ b/lib/Db/TextMapper.php
@@ -1,53 +1,75 @@
-<?php
-namespace OCA\Polls\Db;
-
-use OCP\AppFramework\Db\Mapper;
-use OCP\IDBConnection;
-
-class TextMapper extends Mapper {
-
- public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text');
- }
-
- /**
- * @param int $id
- * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
- * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
- * @return Text
- */
- public function find($id) {
- $sql = 'SELECT * FROM `*PREFIX*polls_txts` '.
- 'WHERE `id` = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Text[]
- */
- public function findAll($limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_txts`';
- return $this->findEntities($sql, [], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- * @param int $limit
- * @param int $offset
- * @return Text[]
- */
- public function findByPoll($pollId, $limit=null, $offset=null) {
- $sql = 'SELECT * FROM `*PREFIX*polls_txts` WHERE poll_id=?';
- return $this->findEntities($sql, [$pollId], $limit, $offset);
- }
-
- /**
- * @param string $pollId
- */
- public function deleteByPoll($pollId) {
- $sql = 'DELETE FROM `*PREFIX*polls_txts` WHERE poll_id=?';
- $this->execute($sql, [$pollId]);
- }
-}
+<?php
+/**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDBConnection;
+
+class TextMapper extends Mapper {
+
+ public function __construct(IDBConnection $db) {
+ parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return Text
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_txts` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return Text[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_txts`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ * @param int $limit
+ * @param int $offset
+ * @return Text[]
+ */
+ public function findByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_txts` WHERE poll_id=?';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ */
+ public function deleteByPoll($pollId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_txts` WHERE poll_id=?';
+ $this->execute($sql, [$pollId]);
+ }
+}
diff --git a/templates/create.tmpl.php b/templates/create.tmpl.php
index f7a9160b..6939b30e 100644
--- a/templates/create.tmpl.php
+++ b/templates/create.tmpl.php
@@ -1,4 +1,26 @@
<?php
+ /**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
use \OCP\User;
\OCP\Util::addStyle('polls', 'main');
@@ -12,28 +34,33 @@
$isUpdate = isset($_['poll']) && $_['poll'] !== null;
$isAnonymous = false;
$hideNames = false;
- if($isUpdate) {
+ if ($isUpdate) {
$poll = $_['poll'];
$isAnonymous = $poll->getIsAnonymous();
$hideNames = $isAnonymous && $poll->getFullAnonymous();
$dates = $_['dates'];
$chosen = '[';
- foreach($dates as $d) {
- if($poll->getType() == '0') $chosen .= strtotime($d->getDt());
- else $chosen .= '"' . $d->getText() . '"';
+ foreach ($dates as $d) {
+ if ($poll->getType() == '0') {
+ $chosen .= strtotime($d->getDt());
+ } else {
+ $chosen .= '"' . $d->getText() . '"';
+ }
$chosen .= ',';
}
$chosen = trim($chosen, ',');
$chosen .= ']';
$title = $poll->getTitle();
$desc = $poll->getDescription();
- if($poll->getExpire() !== null) {
+ if ($poll->getExpire() !== null) {
$expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day
$expireStr = date('d.m.Y', $expireTs);
}
$access = $poll->getAccess();
$accessTypes = $access;
- if($access !== 'registered' && $access !== 'hidden' && $access !== 'public') $access = 'select';
+ if ($access !== 'registered' && $access !== 'hidden' && $access !== 'public') {
+ $access = 'select';
+ }
}
?>
@@ -49,7 +76,7 @@
</div>
<div class="crumb svg last">
<span>
- <?php if($isUpdate): ?>
+ <?php if ($isUpdate): ?>
<?php p($l->t('Edit poll') . ' ' . $poll->getTitle()); ?>
<?php else: ?>
<?php p($l->t('Create new poll')); ?>
@@ -59,14 +86,14 @@
</div>
</div>
-<?php if($isUpdate): ?>
+<?php if ($isUpdate): ?>
<form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.update_poll')); ?>" method="POST">
<input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" />
<?php else: ?>
<form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_poll')); ?>" method="POST">
<?php endif; ?>
- <input type="hidden" name="chosenDates" id="chosenDates" value="<?php if(isset($chosen)) p($chosen); ?>" />
- <input type="hidden" name="expireTs" id="expireTs" value="<?php if(isset($expireTs)) p($expireTs); ?>" />
+ <input type="hidden" name="chosenDates" id="chosenDates" value="<?php if (isset($chosen)) p($chosen); ?>" />
+ <input type="hidden" name="expireTs" id="expireTs" value="<?php if (isset($expireTs)) p($expireTs); ?>" />
<input type="hidden" name="userId" id="userId" value="<?php p($userId); ?>" />
<header class="row">
@@ -75,22 +102,22 @@
<div class="new_poll row">
<div class="col-50">
<label for="pollTitle" class="input_title"><?php p($l->t('Title')); ?></label>
- <input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if(isset($title)) p($title); ?>" />
+ <input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if (isset($title)) p($title); ?>" />
<label for="pollDesc" class="input_title"><?php p($l->t('Description')); ?></label>
- <textarea class="input_field" id="pollDesc" name="pollDesc"><?php if(isset($desc)) p($desc); ?></textarea>
+ <textarea class="input_field" id="pollDesc" name="pollDesc"><?php if (isset($desc)) p($desc); ?></textarea>
<label class="input_title"><?php p($l->t('Access')); ?></label>
- <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if(!$isUpdate || $access === 'registered') print_unescaped('checked'); ?> />
+ <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access === 'registered') print_unescaped('checked'); ?> />
<label for="private"><?php p($l->t('Registered users only')); ?></label>
- <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if($isUpdate && $access === 'hidden') print_unescaped('checked'); ?> />
+ <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access === 'hidden') print_unescaped('checked'); ?> />
<label for="hidden"><?php p($l->t('hidden')); ?></label>
- <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if($isUpdate && $access === 'public') print_unescaped('checked'); ?> />
+ <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access === 'public') print_unescaped('checked'); ?> />
<label for="public"><?php p($l->t('Public access')); ?></label>
- <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if($isUpdate && $access === 'select') print_unescaped('checked'); ?>>
+ <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access === 'select') print_unescaped('checked'); ?>>
<label for="select"><?php p($l->t('Select')); ?></label>
<span id="id_label_select">...</span>
@@ -106,7 +133,7 @@
</div>
</div>
- <input type="hidden" name="accessValues" id="accessValues" value="<?php if($isUpdate && $access === 'select') p($accessTypes) ?>" />
+ <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access === 'select') p($accessTypes) ?>" />
<input id="isAnonymous" name="isAnonymous" type="checkbox" class="checkbox" <?php $isAnonymous ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> />
<label for="isAnonymous" class="input_title"><?php p($l->t('Anonymous')) ?></label>
@@ -124,14 +151,14 @@
</div>
<div class="col-50">
- <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if(!$isUpdate || $poll->getType() == '0') print_unescaped('checked'); ?> />
+ <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() == '0') print_unescaped('checked'); ?> />
<label for="event"><?php p($l->t('Event schedule')); ?></label>
<!-- TODO texts to db -->
- <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if($isUpdate && $poll->getType() == '1') print_unescaped('checked'); ?>>
+ <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() == '1') print_unescaped('checked'); ?>>
<label for="text"><?php p($l->t('Text based')); ?></label>
- <div id="date-select-container" <?php if($isUpdate && $poll->getType() == '1') print_unescaped('style="display:none;"'); ?> >
+ <div id="date-select-container" <?php if ($isUpdate && $poll->getType() == '1') print_unescaped('style="display:none;"'); ?> >
<label for="datetimepicker" class="input_title"><?php p($l->t('Dates')); ?></label>
<input id="datetimepicker" type="text" />
<table id="selected-dates-table" class="choices">
@@ -151,7 +178,7 @@
</div>
</div>
<div class="form-actions">
- <?php if($isUpdate): ?>
+ <?php if ($isUpdate): ?>
<input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Update poll')); ?>" />
<?php else: ?>
<input type="submit" id="submit_finish_poll" class="button btn primary" value="<?php p($l->t('Create poll')); ?>" />
diff --git a/templates/goto.tmpl.php b/templates/goto.tmpl.php
index 569e019f..0957b66e 100644
--- a/templates/goto.tmpl.php
+++ b/templates/goto.tmpl.php
@@ -1,4 +1,25 @@
<?php
+ /**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
use \OCP\User;
@@ -58,7 +79,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<div id="app-content-wrapper" class="<?php p($layout); ?>">
<div id="controls">
<div id="breadcrump">
- <?php if(User::isLoggedIn()) : ?>
+ <?php if (User::isLoggedIn()) : ?>
<div class="crumb svg" data-dir="/">
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>">
<img class="svg" src="<?php print_unescaped(OCP\image_path("core", "places/home.svg")); ?>"" alt="Home">
@@ -69,7 +90,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
</div>
<?php endif; ?>
- <?php if(!User::isLoggedIn()) : ?>
+ <?php if (!User::isLoggedIn()) : ?>
<div class="col-100">
<h2><?php p($poll->getTitle()); ?></h2>
</div>
@@ -120,13 +141,13 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
}
print_unescaped('<tr>');
print_unescaped('<td class="avatar-cell">');
- if($userMgr->get($usr) != null && !$isAnonymous && !$hideNames) {
+ if ($userMgr->get($usr) != null && !$isAnonymous && !$hideNames) {
print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>');
print_unescaped('</td>');
print_unescaped('<td colspan="2" class="name">');
p($userMgr->get($usr)->getDisplayName());
} else {
- if($isAnonymous || $hideNames) {
+ if ($isAnonymous || $hideNames) {
print_unescaped('<div class="poll avatardiv" title="'.($userCnt).'"></div>');
print_unescaped('</td>');
print_unescaped('<td colspan="2" class="name">');
@@ -141,7 +162,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
// loop over dts
$i_tot = 0;
- foreach($dates as $dt) {
+ foreach ($dates as $dt) {
if ($poll->getType() == '0') {
$date_id = strtotime($dt->getDt());
$poll_id = "pollid_" . $dt->getId();
@@ -153,7 +174,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
$found = false;
foreach ($others[$usr] as $vote) {
$voteVal = null;
- if($poll->getType() == '0') {
+ if ($poll->getType() == '0') {
$voteVal = strtotime($vote->getDt());
} else {
$voteVal = $vote->getText();
@@ -174,7 +195,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
break;
}
}
- if(!$found) {
+ if (!$found) {
$cl = 'poll-cell unvoted';
}
// Make the td clickable
@@ -298,9 +319,9 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<input type="hidden" name="changed" />
<input type="button" id="submit_finish_vote" class="button btn" value="<?php p($l->t('Vote!')); ?>" />
</form>
- <?php if(User::isLoggedIn()) : ?>
+ <?php if (User::isLoggedIn()) : ?>
<span class="notification">
- <input type="checkbox" id="check_notif" class="checkbox" <?php if($notification !== null) print_unescaped(' checked'); ?> />
+ <input type="checkbox" id="check_notif" class="checkbox" <?php if ($notification !== null) print_unescaped(' checked'); ?> />
<label for="check_notif"><?php p($l->t('Receive notification email on activity')); ?></label>
</span>
<?php endif; ?>
@@ -316,7 +337,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
- <?php if($expired) : ?>
+ <?php if ($expired) : ?>
<div id="expired_info">
<h2><?php p($l->t('Poll expired')); ?></h2>
<p>
@@ -331,7 +352,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" />
<input type="hidden" name="userId" value="<?php p($userId); ?>" />
<div class="comment-content">
- <?php if(!User::isLoggedIn()) : ?>
+ <?php if (!User::isLoggedIn()) : ?>
<!--<?php
p($l->t('You must be logged in to post a comment.'));
?>-->
@@ -349,16 +370,16 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
</div>
</form>
</div>
- <?php if($comments !== null) : ?>
+ <?php if ($comments !== null) : ?>
<?php foreach ($comments as $comment) : ?>
<div class="comment">
<div class="comment-header">
<?php
print_unescaped('<span class="comment-date">' . date('d.m.Y H:i:s', strtotime($comment->getDt())) . '</span>');
- if($isAnonymous || $hideNames) {
+ if ($isAnonymous || $hideNames) {
p('Anonymous');
} else {
- if($userMgr->get($comment->getUserId()) != null) {
+ if ($userMgr->get($comment->getUserId()) != null) {
p($userMgr->get($comment->getUserId())->getDisplayName());
} else {
print_unescaped('<i>');
@@ -388,7 +409,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
//adapted from jsxc.chat
function getHsl($str) {
$hash = 0;
- for($i=0; $i<strlen($str); $i++) {
+ for ($i=0; $i<strlen($str); $i++) {
$utf16_char = mb_convert_encoding($str[$i], "utf-16", "utf-8");
$char = hexdec(bin2hex($utf16_char));
$hash = (($hash << 5) - $hash) + $char;
diff --git a/templates/main.tmpl.php b/templates/main.tmpl.php
index b159219f..1680b9f8 100644
--- a/templates/main.tmpl.php
+++ b/templates/main.tmpl.php
@@ -1,4 +1,25 @@
<?php
+ /**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
use OCP\User;
@@ -10,7 +31,6 @@
$userMgr = $_['userMgr'];
$urlGenerator = $_['urlGenerator'];
?>
-
<div id="app-content">
<div id="app-content-wrapper">
<div id="controls">
@@ -28,7 +48,7 @@
<input class="stop icon-close" style="display:none" value="" type="button">
</div>
</div>
- <?php if(count($_['polls']) === 0) : ?>
+ <?php if (count($_['polls']) === 0) : ?>
<div id="emptycontent" class="">
<div class="icon-polls"></div>
<h2><?php p($l->t('No existing polls.')); ?></h2>
@@ -69,7 +89,7 @@
// direct url to poll
$pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash()));
$desc_str = $poll->getDescription();
- if (strlen($desc_str) > 100){
+ if (strlen($desc_str) > 100) {
$desc_str = substr($desc_str, 0, 80) . '...';
}
?>
@@ -86,8 +106,11 @@
<td class="pollitem created"><?php p(date('d.m.Y H:i', strtotime($poll->getCreated()))); ?></td>
<td class="pollitem principal">
<?php
- if($poll->getOwner() === $userId) p($l->t('Yourself'));
- else p($userMgr->get($poll->getOwner()));
+ if ($poll->getOwner() === $userId) {
+ p($l->t('Yourself'));
+ } else {
+ p($userMgr->get($poll->getOwner()));
+ }
?>
</td>
<?php
@@ -97,8 +120,7 @@
$style = 'expired';
}
print_unescaped('<td class="pollitem expiry ' . $style . '">' . date('d.m.Y', strtotime($poll->getExpire())) . '</td>');
- }
- else {
+ } else {
print_unescaped('<td class="pollitem expiry">' . $l->t('Never') . '</td>');
}
?>
@@ -106,8 +128,8 @@
<?php
$partic_class = 'partic_no';
$partic_polls = $_['participations'];
- for($i = 0; $i < count($partic_polls); $i++){
- if($poll->getId() == intval($partic_polls[$i]->getPollId())){
+ for ($i = 0; $i < count($partic_polls); $i++){
+ if ($poll->getId() == intval($partic_polls[$i]->getPollId())){
$partic_class = 'partic_yes';
array_splice($partic_polls, $i, 1);
break;
@@ -120,8 +142,8 @@
<?php
$partic_class = 'partic_no';
$partic_comm = $_['comments'];
- for($i = 0; $i < count($partic_comm); $i++){
- if($poll->getId() === intval($partic_comm[$i]->getPollId())){
+ for ($i = 0; $i < count($partic_comm); $i++){
+ if ($poll->getId() === intval($partic_comm[$i]->getPollId())){
$partic_class = 'partic_yes';
array_splice($partic_comm, $i, 1);
break;
@@ -156,28 +178,40 @@
<?php
// ---- helper functions ----
// from spreed.me
- function getGroups($userId) {
- // $this->requireLogin();
- if (class_exists('\OC_Group', true)) {
- // Nextcloud <= 11, ownCloud
- return \OC_Group::getUserGroups($userId);
- }
- // Nextcloud >= 12
- $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
- return array_map(function ($group) {
- return $group->getGID();
- }, $groups);
+function getGroups($userId) {
+ // $this->requireLogin();
+ if (class_exists('\OC_Group', true)) {
+ // Nextcloud <= 11, ownCloud
+ return \OC_Group::getUserGroups($userId);
}
+ // Nextcloud >= 12
+ $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
+ return array_map(function ($group) {
+ return $group->getGID();
+ }, $groups);
+}
function userHasAccess($poll, $userId) {
- if($poll === null) return false;
+ if($poll === null) {
+ return false;
+ }
$access = $poll->getAccess();
$owner = $poll->getOwner();
- if (!User::isLoggedIn()) return false;
- if ($access === 'public') return true;
- if ($access === 'hidden') return true;
- if ($access === 'registered') return true;
- if ($owner === $userId) return true;
+ if (!User::isLoggedIn()) {
+ return false;
+ }
+ if ($access === 'public') {
+ return true;
+ }
+ if ($access === 'hidden') {
+ return true;
+ }
+ if ($access === 'registered') {
+ return true;
+ }
+ if ($owner === $userId) {
+ return true;
+ }
$user_groups = getGroups($userId);
$arr = explode(';', $access);
diff --git a/templates/no.acc.tmpl.php b/templates/no.acc.tmpl.php
index 46a5f06d..f95a7049 100644
--- a/templates/no.acc.tmpl.php
+++ b/templates/no.acc.tmpl.php
@@ -1,5 +1,27 @@
<?php
-\OCP\Util::addStyle('polls', 'main');
+ /**
+ * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+ \OCP\Util::addStyle('polls', 'main');
?>
<div id="app">
<div id="app-content">