diff options
author | Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> | 2016-02-20 19:15:07 +0300 |
---|---|---|
committer | Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com> | 2016-02-20 19:15:07 +0300 |
commit | c3f94802f28f8b44335eb9d3067c6dc0de9f51e0 (patch) | |
tree | 95d52bcb317ad3ad1a673ae77719d8d4ad1984d4 /db | |
parent | 28fa26961991fa01736fcb8d226c3203f6b5a6a5 (diff) |
initial commit0.6.0
Diffstat (limited to 'db')
-rw-r--r-- | db/access.php | 15 | ||||
-rw-r--r-- | db/accessmapper.php | 49 | ||||
-rw-r--r-- | db/comment.php | 21 | ||||
-rw-r--r-- | db/commentmapper.php | 79 | ||||
-rw-r--r-- | db/date.php | 15 | ||||
-rw-r--r-- | db/datemapper.php | 68 | ||||
-rw-r--r-- | db/event.php | 33 | ||||
-rw-r--r-- | db/eventmapper.php | 101 | ||||
-rw-r--r-- | db/notification.php | 15 | ||||
-rw-r--r-- | db/notificationmapper.php | 68 | ||||
-rw-r--r-- | db/participation.php | 21 | ||||
-rw-r--r-- | db/participationmapper.php | 84 | ||||
-rw-r--r-- | db/text.php | 15 | ||||
-rw-r--r-- | db/textmapper.php | 53 |
14 files changed, 637 insertions, 0 deletions
diff --git a/db/access.php b/db/access.php new file mode 100644 index 00000000..e5af9bbd --- /dev/null +++ b/db/access.php @@ -0,0 +1,15 @@ +<?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/accessmapper.php b/db/accessmapper.php new file mode 100644 index 00000000..be863359 --- /dev/null +++ b/db/accessmapper.php @@ -0,0 +1,49 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class AccessMapper extends Mapper {
+
+ public function __construct(IDB $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/db/comment.php b/db/comment.php new file mode 100644 index 00000000..c6fca666 --- /dev/null +++ b/db/comment.php @@ -0,0 +1,21 @@ +<?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/commentmapper.php b/db/commentmapper.php new file mode 100644 index 00000000..00f56e20 --- /dev/null +++ b/db/commentmapper.php @@ -0,0 +1,79 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class CommentMapper extends Mapper {
+
+ public function __construct(IDB $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=?';
+ 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], $limit, $offset);
+ }
+}
diff --git a/db/date.php b/db/date.php new file mode 100644 index 00000000..c5bad99b --- /dev/null +++ b/db/date.php @@ -0,0 +1,15 @@ +<?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/datemapper.php b/db/datemapper.php new file mode 100644 index 00000000..82f1a4b7 --- /dev/null +++ b/db/datemapper.php @@ -0,0 +1,68 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class DateMapper extends Mapper {
+
+ public function __construct(IDB $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/db/event.php new file mode 100644 index 00000000..b16a61d8 --- /dev/null +++ b/db/event.php @@ -0,0 +1,33 @@ +<?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)
+ */
+class Event extends Entity {
+ public $type;
+ public $title;
+ public $description;
+ public $owner;
+ public $created;
+ public $access;
+ public $expire;
+ public $hash;
+}
diff --git a/db/eventmapper.php b/db/eventmapper.php new file mode 100644 index 00000000..5a172617 --- /dev/null +++ b/db/eventmapper.php @@ -0,0 +1,101 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class EventMapper extends Mapper {
+
+ public function __construct(IDB $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
+ 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/db/notification.php b/db/notification.php new file mode 100644 index 00000000..2144fec9 --- /dev/null +++ b/db/notification.php @@ -0,0 +1,15 @@ +<?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/notificationmapper.php b/db/notificationmapper.php new file mode 100644 index 00000000..6abd4d77 --- /dev/null +++ b/db/notificationmapper.php @@ -0,0 +1,68 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class NotificationMapper extends Mapper {
+
+ public function __construct(IDB $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/db/participation.php b/db/participation.php new file mode 100644 index 00000000..c744f8f8 --- /dev/null +++ b/db/participation.php @@ -0,0 +1,21 @@ +<?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/participationmapper.php b/db/participationmapper.php new file mode 100644 index 00000000..59e3b9d1 --- /dev/null +++ b/db/participationmapper.php @@ -0,0 +1,84 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class ParticipationMapper extends Mapper {
+
+ public function __construct(IDB $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], $limit, $offset);
+ }
+}
diff --git a/db/text.php b/db/text.php new file mode 100644 index 00000000..dd2deb9e --- /dev/null +++ b/db/text.php @@ -0,0 +1,15 @@ +<?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/db/textmapper.php b/db/textmapper.php new file mode 100644 index 00000000..2ceff879 --- /dev/null +++ b/db/textmapper.php @@ -0,0 +1,53 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class TextMapper extends Mapper {
+
+ public function __construct(IDB $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]);
+ }
+}
|