diff --git a/.gitignore b/.gitignore index d2ae2edc..ed7fbffa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .idea -.sass-cache \ No newline at end of file +.sass-cache +npm-debug.log diff --git a/lib/Db/SharingACL.php b/lib/Db/SharingACL.php new file mode 100644 index 00000000..6e19675c --- /dev/null +++ b/lib/Db/SharingACL.php @@ -0,0 +1,62 @@ +addType('itemId', 'integer'); + $this->addType('created', 'integer'); + $this->addType('expire', 'integer'); + $this->addType('permissions', 'integer'); + } + + /** + * Specify data which should be serialized to JSON + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + * @return mixed data which can be serialized by json_encode, + * which is a value of any type other than a resource. + * @since 5.4.0 + */ + function jsonSerialize() + { + return [ + 'acl_id' => $this->getId(), + 'item_id' => $this->getItemId(), + 'item_guid' => $this->getItemGuid(), + 'user_id' => $this->getUserid(), + 'group_id' => $this->getGroupId(), + 'created' => $this->getCreated(), + 'expire' => $this->getExpire(), + 'permissions' => $this->getPermissions(), + ]; + } +} \ No newline at end of file diff --git a/lib/Db/SharingACLMapper.php b/lib/Db/SharingACLMapper.php new file mode 100644 index 00000000..db48937e --- /dev/null +++ b/lib/Db/SharingACLMapper.php @@ -0,0 +1,37 @@ +utils = $utils; + } + + /** + * Gets all the credential data for the given user + * @param $userId + * @param $item_guid + * @return SharingACL[] + */ + public function getCredentialPermissions(IUser $userId, $item_guid){ + $sql = "SELECT * FROM {{self::TABLE_NAME}} WHERE user_id = ? AND item_guid = ?"; + + return $this->findEntities($sql, [$userId, $item_guid]); + } +} \ No newline at end of file