diff options
author | dartcafe <github@dartcafe.de> | 2019-12-21 23:01:06 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2019-12-21 23:01:06 +0300 |
commit | 923fe1897f3f6962d95a94577b2d03ae5bc512ad (patch) | |
tree | 5c9031d3dfdf4969d98c2377767045e2294a9c35 /lib/Db | |
parent | 9d015be1fa920e002a2f9cbacdfdafacbe807357 (diff) |
Prepare mail notification and update tests
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/Notice.php | 68 | ||||
-rw-r--r-- | lib/Db/NoticeMapper.php | 60 |
2 files changed, 128 insertions, 0 deletions
diff --git a/lib/Db/Notice.php b/lib/Db/Notice.php new file mode 100644 index 00000000..2ddbac13 --- /dev/null +++ b/lib/Db/Notice.php @@ -0,0 +1,68 @@ +<?php +/** + * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> + * + * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> + * @author Kai Schröer <git@schroeer.co> + * + * @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 JsonSerializable; + +use OCP\AppFramework\Db\Entity; + +/** + * @method integer getPollId() + * @method void setPollId(integer $value) + * @method integer getChannel() + * @method void setChannel(integer $value) + * @method integer getUserId() + * @method void setUserId(integer $value) + * @method integer getUserEmail() + * @method void setUserEmail(integer $value) + * @method integer getDisplayName() + * @method void setDisplayName(integer $value) + * @method integer getMessageId() + * @method void setMessageId(integer $value) + * @method string getMessage() + * @method void setMessage(string $value) + */ +class Notice extends Entity implements JsonSerializable { + protected $pollId; + protected $channel; + protected $userId; + protected $userEmail; + protected $displayName; + protected $messageId; + protected $message; + + public function jsonSerialize() { + return [ + 'id' => $this->id, + 'pollId' => $this->pollId, + 'channel' => $this->channel, + 'userId' => $this->userId, + 'userEmail' => $this->userEmail, + 'displayName' => $this->displayName, + 'message_id' => $this->messageId, + 'message' => $this->message + ]; + } +} diff --git a/lib/Db/NoticeMapper.php b/lib/Db/NoticeMapper.php new file mode 100644 index 00000000..0b75edb1 --- /dev/null +++ b/lib/Db/NoticeMapper.php @@ -0,0 +1,60 @@ +<?php +/** + * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> + * + * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> + * @author René Gieling <github@dartcafe.de> +* + * @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\DB\QueryBuilder\IQueryBuilder; +use OCP\IDBConnection; +use OCP\AppFramework\Db\QBMapper; + +class NoticeMapper extends QBMapper { + + /** + * NotificationMapper constructor. + * @param IDBConnection $db + */ + public function __construct(IDBConnection $db) { + parent::__construct($db, 'polls_notice', '\OCA\Polls\Db\Notice'); + } + + /** + * @param int $pollId + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result + * @return array + */ + + public function findAllByPoll($pollId) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where( + $qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT)) + ); + + return $this->findEntities($qb); + } + +} |