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/Db
diff options
context:
space:
mode:
authorRené Gieling <github@dartcafe.de>2019-12-02 00:12:37 +0300
committerGitHub <noreply@github.com>2019-12-02 00:12:37 +0300
commit5b7165b7aae6948c499cb70935c4d9caf4f41e19 (patch)
tree175791231096a1f7b055a576dd84035d304e36ff /lib/Db
parentaf237c8ba29f6cf1480e8754304c34436916cdce (diff)
Public page (#664)
* adding acl * changing share db and migration (hash becomes token) * View public vote * Refactoring anonymizer * some more refactoring * nearly finished public voting * updated dependencies * linter autofixes
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/CommentMapper.php14
-rw-r--r--lib/Db/Share.php12
-rw-r--r--lib/Db/ShareMapper.php6
-rw-r--r--lib/Db/VoteMapper.php2
4 files changed, 25 insertions, 9 deletions
diff --git a/lib/Db/CommentMapper.php b/lib/Db/CommentMapper.php
index e5080d7d..c6ac77d2 100644
--- a/lib/Db/CommentMapper.php
+++ b/lib/Db/CommentMapper.php
@@ -69,4 +69,18 @@ class CommentMapper extends QBMapper {
$qb->execute();
}
+
+ /**
+ * @param int $id
+ */
+ public function deleteComment($id) {
+ $qb = $this->db->getQueryBuilder();
+
+ $qb->delete($this->getTableName())
+ ->where(
+ $qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
+ );
+
+ $qb->execute();
+ }
}
diff --git a/lib/Db/Share.php b/lib/Db/Share.php
index 5f5a9821..c988bf98 100644
--- a/lib/Db/Share.php
+++ b/lib/Db/Share.php
@@ -28,19 +28,21 @@ use JsonSerializable;
use OCP\AppFramework\Db\Entity;
/**
- * @method string gethash()
- * @method void setHash(string $value)
+ * @method string getId()
+ * @method void setId(int $value)
+ * @method string getToken()
+ * @method void setToken(string $value)
* @method string getType()
* @method void setType(string $value)
* @method integer getPollId()
- * @method void setPollId(integer $value)
+ * @method void setPollId(int $value)
* @method string getUserId()
* @method void setUserId(string $value)
* @method string getUserEmail()
* @method void setUserEmail(string $value)
*/
class Share extends Entity implements JsonSerializable {
- protected $hash;
+ protected $token;
protected $type;
protected $pollId;
protected $userId;
@@ -50,7 +52,7 @@ class Share extends Entity implements JsonSerializable {
return [
'id' => $this->id,
- 'hash' => $this->hash,
+ 'token' => $this->token,
'type' => $this->type,
'pollId' => $this->pollId,
'userId' => $this->userId,
diff --git a/lib/Db/ShareMapper.php b/lib/Db/ShareMapper.php
index 32825a55..5318c5a4 100644
--- a/lib/Db/ShareMapper.php
+++ b/lib/Db/ShareMapper.php
@@ -57,18 +57,18 @@ class ShareMapper extends QBMapper {
}
/**
- * @param string $hash
+ * @param string $token
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return array
*/
- public function findByHash($hash) {
+ public function findByToken($token) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
- $qb->expr()->eq('hash', $qb->createNamedParameter($hash, IQueryBuilder::PARAM_INT))
+ $qb->expr()->eq('token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR))
);
return $this->findEntity($qb);
diff --git a/lib/Db/VoteMapper.php b/lib/Db/VoteMapper.php
index f95d158f..2e759d8c 100644
--- a/lib/Db/VoteMapper.php
+++ b/lib/Db/VoteMapper.php
@@ -87,7 +87,7 @@ class VoteMapper extends QBMapper {
public function findParticipantsByPoll($pollId) {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id')
+ $qb->selectDistinct('user_id')
->from($this->getTableName())
->where(
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))