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
path: root/lib
diff options
context:
space:
mode:
authorsplitt3r <splitt3r@users.noreply.github.com>2017-10-08 20:28:36 +0300
committersplitt3r <splitt3r@users.noreply.github.com>2017-10-08 20:28:36 +0300
commitd48fa88a96eed012b4b98f25e1e9c6c56653b716 (patch)
tree41c54412c874df152be64a1adfdf151cb2ee3301 /lib
parenta5aad195d7359bd4ef7aac0295a44f19f7a94ea5 (diff)
Removed unused code
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php10
-rw-r--r--lib/Controller/PageController.php109
-rw-r--r--lib/Db/Access.php38
-rw-r--r--lib/Db/AccessMapper.php73
-rw-r--r--lib/Db/CommentMapper.php41
-rw-r--r--lib/Db/DateMapper.php41
-rw-r--r--lib/Db/EventMapper.php41
-rw-r--r--lib/Db/ParticipationMapper.php57
-rw-r--r--lib/Db/ParticipationTextMapper.php73
-rw-r--r--lib/Db/TextMapper.php27
10 files changed, 137 insertions, 373 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 7adf7558..b3cce114 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -25,7 +25,6 @@ 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;
@@ -40,7 +39,6 @@ class Application extends App
/**
* Application constructor.
- *
* @param array $urlParams
*/
public function __construct(array $urlParams = array())
@@ -65,7 +63,6 @@ class Application extends App
$c->query('L10N'),
$c->query('ServerContainer')->getURLGenerator(),
$c->query('UserId'),
- $c->query('AccessMapper'),
$c->query('CommentMapper'),
$c->query('DateMapper'),
$c->query('EventMapper'),
@@ -100,13 +97,6 @@ class Application extends App
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(
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 76e468bd..68669600 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -31,7 +31,6 @@ use \OCA\Polls\Db\Participation;
use \OCA\Polls\Db\ParticipationText;
use \OCA\Polls\Db\Text;
-use \OCA\Polls\Db\AccessMapper;
use \OCA\Polls\Db\CommentMapper;
use \OCA\Polls\Db\DateMapper;
use \OCA\Polls\Db\EventMapper;
@@ -56,7 +55,6 @@ class PageController extends Controller
{
private $userId;
- private $accessMapper;
private $commentMapper;
private $dateMapper;
private $eventMapper;
@@ -72,6 +70,25 @@ class PageController extends Controller
private $userMgr;
private $groupManager;
+ /**
+ * PageController constructor.
+ * @param $appName
+ * @param IRequest $request
+ * @param IUserManager $manager
+ * @param IGroupManager $groupManager
+ * @param IAvatarManager $avatarManager
+ * @param ILogger $logger
+ * @param IL10N $trans
+ * @param IURLGenerator $urlGenerator
+ * @param $userId
+ * @param CommentMapper $commentMapper
+ * @param DateMapper $dateMapper
+ * @param EventMapper $eventMapper
+ * @param NotificationMapper $notificationMapper
+ * @param ParticipationMapper $ParticipationMapper
+ * @param ParticipationTextMapper $ParticipationTextMapper
+ * @param TextMapper $textMapper
+ */
public function __construct(
$appName,
IRequest $request,
@@ -82,7 +99,6 @@ class PageController extends Controller
IL10N $trans,
IURLGenerator $urlGenerator,
$userId,
- AccessMapper $accessMapper,
CommentMapper $commentMapper,
DateMapper $dateMapper,
EventMapper $eventMapper,
@@ -99,7 +115,6 @@ class PageController extends Controller
$this->trans = $trans;
$this->urlGenerator = $urlGenerator;
$this->userId = $userId;
- $this->accessMapper = $accessMapper;
$this->commentMapper = $commentMapper;
$this->dateMapper = $dateMapper;
$this->eventMapper = $eventMapper;
@@ -134,6 +149,10 @@ class PageController extends Controller
return $response;
}
+ /**
+ * @param string $pollId
+ * @param string $from
+ */
private function sendNotifications($pollId, $from)
{
$poll = $this->eventMapper->find($pollId);
@@ -194,6 +213,8 @@ class PageController extends Controller
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
+ * @param string $hash
+ * @return TemplateResponse
*/
public function gotoPoll($hash)
{
@@ -232,6 +253,8 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param string $pollId
+ * @return RedirectResponse
*/
public function deletePoll($pollId)
{
@@ -250,6 +273,8 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param string $hash
+ * @return TemplateResponse
*/
public function editPoll($hash)
{
@@ -274,6 +299,16 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param $pollId
+ * @param $pollType
+ * @param $pollTitle
+ * @param $pollDesc
+ * @param $userId
+ * @param $chosenDates
+ * @param $expireTs
+ * @param $accessType
+ * @param $accessValues
+ * @return RedirectResponse
*/
public function updatePoll(
$pollId,
@@ -361,6 +396,17 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param $pollType
+ * @param $pollTitle
+ * @param $pollDesc
+ * @param $userId
+ * @param $chosenDates
+ * @param $expireTs
+ * @param $accessType
+ * @param $accessValues
+ * @param $isAnonymous
+ * @param $hideNames
+ * @return RedirectResponse
*/
public function insertPoll(
$pollType,
@@ -450,11 +496,18 @@ class PageController extends Controller
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
+ * @param $pollId
+ * @param $userId
+ * @param $types
+ * @param $dates
+ * @param $notIf
+ * @param $changed
+ * @return RedirectResponse
*/
- public function insertVote($pollId, $userId, $types, $dates, $notif, $changed)
+ public function insertVote($pollId, $userId, $types, $dates, $notIf, $changed)
{
if ($this->userId !== null) {
- if ($notif === 'true') {
+ if ($notIf === 'true') {
try {
//check if user already set notification for this poll
$this->notificationMapper->findByUserAndPoll($pollId, $userId);
@@ -474,9 +527,6 @@ class PageController extends Controller
//doesn't exist in db, nothing to do
}
}
- } else {
- // TODO: Needs investigation!
- $userId = $userId;
}
$poll = $this->eventMapper->find($pollId);
if ($changed === 'true') {
@@ -516,10 +566,13 @@ class PageController extends Controller
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
+ * @param $pollId
+ * @param $userId
+ * @param $commentBox
+ * @return JSONResponse
*/
public function insertComment($pollId, $userId, $commentBox)
{
- $poll = $this->eventMapper->find($pollId);
$comment = new Comment();
$comment->setPollId($pollId);
$comment->setUserId($userId);
@@ -527,8 +580,6 @@ class PageController extends Controller
$comment->setDt(date('Y-m-d H:i:s'));
$this->commentMapper->insert($comment);
$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) {
$newUserId = $this->manager->get($userId)->getDisplayName();
} else {
@@ -544,6 +595,10 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param $searchTerm
+ * @param $groups
+ * @param $users
+ * @return array
*/
public function search($searchTerm, $groups, $users)
{
@@ -553,6 +608,9 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param $searchTerm
+ * @param $groups
+ * @return array
*/
public function searchForGroups($searchTerm, $groups)
{
@@ -577,6 +635,9 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param $searchTerm
+ * @param $users
+ * @return array
*/
public function searchForUsers($searchTerm, $users)
{
@@ -584,13 +645,13 @@ class PageController extends Controller
\OCP\Util::writeLog("polls", print_r($selectedUsers, true), \OCP\Util::ERROR);
$userNames = $this->userMgr->searchDisplayName($searchTerm);
$users = array();
- $susers = array();
+ $sUsers = array();
foreach ($selectedUsers as $su) {
- $susers[] = str_replace('user_', '', $su);
+ $sUsers[] = str_replace('user_', '', $su);
}
foreach ($userNames as $u) {
$alreadyAdded = false;
- foreach ($susers as &$su) {
+ foreach ($sUsers as &$su) {
if ($su === $u->getUID()) {
unset($su);
$alreadyAdded = true;
@@ -609,17 +670,26 @@ class PageController extends Controller
/**
* @NoAdminRequired
* @NoCSRFRequired
+ * @param $username
+ * @return
*/
public function getDisplayName($username)
{
return $this->manager->get($username)->getDisplayName();
}
+ /**
+ * @return Event[]
+ */
public function getPollsForUser()
{
return $this->eventMapper->findAllForUser($this->userId);
}
+ /**
+ * @param null $user
+ * @return Event[]
+ */
public function getPollsForUserWithInfo($user = null)
{
if ($user === null) {
@@ -629,12 +699,15 @@ class PageController extends Controller
}
}
+ /**
+ * @return array
+ */
public function getGroups()
{
// $this->requireLogin();
if (class_exists('\OC_Group', true)) {
// Nextcloud <= 11, ownCloud
- return \OC_Group::getUserGroups($this->$userId);
+ return \OC_Group::getUserGroups($this->userId);
}
// Nextcloud >= 12
$groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
@@ -643,6 +716,10 @@ class PageController extends Controller
}, $groups);
}
+ /**
+ * @param $poll
+ * @return bool
+ */
private function hasUserAccess($poll)
{
$access = $poll->getAccess();
diff --git a/lib/Db/Access.php b/lib/Db/Access.php
deleted file mode 100644
index 7eac1ead..00000000
--- a/lib/Db/Access.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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/lib/Db/AccessMapper.php b/lib/Db/AccessMapper.php
deleted file mode 100644
index 0085a322..00000000
--- a/lib/Db/AccessMapper.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?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 ' . $this->getTableName() . ' 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 ' . $this->getTableName() . ' 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 ' . $this->getTableName();
- return $this->findEntities($sql, [], $limit, $offset);
- }
-}
diff --git a/lib/Db/CommentMapper.php b/lib/Db/CommentMapper.php
index 7ba389b4..99a233cc 100644
--- a/lib/Db/CommentMapper.php
+++ b/lib/Db/CommentMapper.php
@@ -29,46 +29,13 @@ 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 ' . $this->getTableName() . ' 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 ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
/**
- * @param int $limit
- * @param int $offset
- * @return Comment[]
+ * CommentMapper constructor.
+ * @param IDBConnection $db
*/
- public function findAll($limit = null, $offset = null)
+ public function __construct(IDBConnection $db)
{
- $sql = 'SELECT * FROM ' . $this->getTableName();
- return $this->findEntities($sql, [], $limit, $offset);
+ parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
}
/**
diff --git a/lib/Db/DateMapper.php b/lib/Db/DateMapper.php
index df1f340c..9dee3499 100644
--- a/lib/Db/DateMapper.php
+++ b/lib/Db/DateMapper.php
@@ -29,46 +29,13 @@ 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
+ * DateMapper constructor.
+ * @param IDBConnection $db
*/
- public function find($id)
- {
- $sql = 'SELECT * FROM ' . $this->getTableName() . ' 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 ' . $this->getTableName() . ' 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)
+ public function __construct(IDBConnection $db)
{
- $sql = 'SELECT * FROM ' . $this->getTableName();
- return $this->findEntities($sql, [], $limit, $offset);
+ parent::__construct($db, 'polls_dts', '\OCA\Polls\Db\Date');
}
/**
diff --git a/lib/Db/EventMapper.php b/lib/Db/EventMapper.php
index a00182a6..f0156e67 100644
--- a/lib/Db/EventMapper.php
+++ b/lib/Db/EventMapper.php
@@ -29,46 +29,13 @@ 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
+ * EventMapper constructor.
+ * @param IDBConnection $db
*/
- public function find($id)
- {
- $sql = 'SELECT * FROM ' . $this->getTableName() . ' 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 ' . $this->getTableName() . ' 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)
+ public function __construct(IDBConnection $db)
{
- $sql = 'SELECT * FROM ' . $this->getTableName();
- return $this->findEntities($sql, [], $limit, $offset);
+ parent::__construct($db, 'polls_events', '\OCA\Polls\Db\Event');
}
/**
diff --git a/lib/Db/ParticipationMapper.php b/lib/Db/ParticipationMapper.php
index 69bc10a5..e5182ab3 100644
--- a/lib/Db/ParticipationMapper.php
+++ b/lib/Db/ParticipationMapper.php
@@ -29,52 +29,13 @@ 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 ' . $this->getTableName() . ' WHERE id = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- public function deleteByPollAndUser($pollId, $userId)
- {
- $sql = 'DELETE FROM ' . $this->getTableName() . ' 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 ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?';
- return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
- }
-
/**
- * @param int $limit
- * @param int $offset
- * @return Participation[]
+ * ParticipationMapper constructor.
+ * @param IDBConnection $db
*/
- public function findAll($limit = null, $offset = null)
+ public function __construct(IDBConnection $db)
{
- $sql = 'SELECT * FROM ' . $this->getTableName();
- return $this->findEntities($sql, [], $limit, $offset);
+ parent::__construct($db, 'polls_particip', '\OCA\Polls\Db\Participation');
}
/**
@@ -109,4 +70,14 @@ class ParticipationMapper extends Mapper
$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
$this->execute($sql, [$pollId]);
}
+
+ /**
+ * @param string $pollId
+ * @param string $userId
+ */
+ public function deleteByPollAndUser($pollId, $userId)
+ {
+ $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?';
+ $this->execute($sql, [$pollId, $userId]);
+ }
}
diff --git a/lib/Db/ParticipationTextMapper.php b/lib/Db/ParticipationTextMapper.php
index fdf59ece..1de41277 100644
--- a/lib/Db/ParticipationTextMapper.php
+++ b/lib/Db/ParticipationTextMapper.php
@@ -29,68 +29,13 @@ 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 ' . $this->getTableName() . ' WHERE id = ?';
- return $this->findEntity($sql, [$id]);
- }
-
/**
- * @param string $pollId
- * @param string $userId
+ * ParticipationTextMapper constructor.
+ * @param IDBConnection $db
*/
- public function deleteByPollAndUser($pollId, $userId)
- {
- $sql = 'DELETE FROM ' . $this->getTableName() . ' 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 ' . $this->getTableName() . ' 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 ' . $this->getTableName();
- 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)
+ public function __construct(IDBConnection $db)
{
- $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?';
- return $this->findEntities($sql, [$userId], $limit, $offset);
+ parent::__construct($db, 'polls_particip_text', '\OCA\Polls\Db\ParticipationText');
}
/**
@@ -113,4 +58,14 @@ class ParticipationTextMapper extends Mapper
$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?';
$this->execute($sql, [$pollId]);
}
+
+ /**
+ * @param string $pollId
+ * @param string $userId
+ */
+ public function deleteByPollAndUser($pollId, $userId)
+ {
+ $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?';
+ $this->execute($sql, [$pollId, $userId]);
+ }
}
diff --git a/lib/Db/TextMapper.php b/lib/Db/TextMapper.php
index 8fb64158..97e3dae2 100644
--- a/lib/Db/TextMapper.php
+++ b/lib/Db/TextMapper.php
@@ -29,32 +29,13 @@ 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
+ * TextMapper constructor.
+ * @param IDBConnection $db
*/
- public function find($id)
- {
- $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?';
- return $this->findEntity($sql, [$id]);
- }
-
- /**
- * @param int $limit
- * @param int $offset
- * @return Text[]
- */
- public function findAll($limit = null, $offset = null)
+ public function __construct(IDBConnection $db)
{
- $sql = 'SELECT * FROM ' . $this->getTableName();
- return $this->findEntities($sql, [], $limit, $offset);
+ parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text');
}
/**