diff --git a/lib/Db/Bookmark.php b/lib/Db/Bookmark.php index 0c85f34..76ac1d0 100644 --- a/lib/Db/Bookmark.php +++ b/lib/Db/Bookmark.php @@ -26,8 +26,8 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { 'fileId' => $this->getFileId(), 'type' => $this->getType(), 'name' => $this->getName(), - 'value' => static::conditional_json_decode($this->getValue()), - 'content' => static::conditional_json_decode($this->getContent()), + 'value' => $this->conditional_json_decode($this->getValue()), + 'content' => $this->conditional_json_decode($this->getContent()), 'lastModified' => $this->getLastModified() ]; } @@ -48,6 +48,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { public function setUserId(string $userId): void { $this->userId = $userId; + $this->markFieldUpdated('userId'); } public function getFileId(): int { @@ -56,6 +57,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { public function setFileId(int $fileId): void { $this->fileId = $fileId; + $this->markFieldUpdated('fileId'); } public function getType(): string { @@ -64,6 +66,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { public function setType(string $type): void { $this->type = $type; + $this->markFieldUpdated('type'); } public function getName(): string { @@ -72,6 +75,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { public function setName(string $name): void { $this->name = $name; + $this->markFieldUpdated('name'); } public function getValue(): string { @@ -80,6 +84,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { public function setValue(string $value): void { $this->value = $value; + $this->markFieldUpdated('value'); } public function getContent(): string { @@ -88,5 +93,6 @@ class Bookmark extends ReaderEntity implements \JsonSerializable { public function setContent(string $content): void { $this->content = $content; + $this->markFieldUpdated('content'); } } diff --git a/lib/Db/Preference.php b/lib/Db/Preference.php index d19520c..0f11de3 100644 --- a/lib/Db/Preference.php +++ b/lib/Db/Preference.php @@ -42,6 +42,7 @@ class Preference extends ReaderEntity implements \JsonSerializable { public function setUserId(string $userId): void { $this->userId = $userId; + $this->markFieldUpdated('userId'); } public function getScope(): string { @@ -50,6 +51,7 @@ class Preference extends ReaderEntity implements \JsonSerializable { public function setScope(string $scope): void { $this->scope = $scope; + $this->markFieldUpdated('scope'); } public function getFileId(): int { @@ -58,6 +60,7 @@ class Preference extends ReaderEntity implements \JsonSerializable { public function setFileId(int $fileId): void { $this->fileId = $fileId; + $this->markFieldUpdated('fileId'); } public function getName(): string { @@ -66,6 +69,7 @@ class Preference extends ReaderEntity implements \JsonSerializable { public function setName(string $name): void { $this->name = $name; + $this->markFieldUpdated('name'); } public function getValue(): string { @@ -74,5 +78,6 @@ class Preference extends ReaderEntity implements \JsonSerializable { public function setValue(string $value): void { $this->value = $value; + $this->markFieldUpdated('value'); } } diff --git a/lib/Db/ReaderEntity.php b/lib/Db/ReaderEntity.php index f9bbbc8..66eb48a 100644 --- a/lib/Db/ReaderEntity.php +++ b/lib/Db/ReaderEntity.php @@ -24,7 +24,7 @@ abstract class ReaderEntity extends Entity { * * @return string|array */ - public static function conditional_json_decode(string $el): mixed { + public function conditional_json_decode(string $el): mixed { /** @var array $result */ $result = json_decode($el); if (json_last_error() === JSON_ERROR_NONE) { @@ -40,6 +40,7 @@ abstract class ReaderEntity extends Entity { public function setLastModified(int $lastModified): void { $this->lastModified = $lastModified; + $this->markFieldUpdated('lastModified'); } /** diff --git a/lib/Hooks.php b/lib/Hooks.php index 3864fb3..aa41432 100644 --- a/lib/Hooks.php +++ b/lib/Hooks.php @@ -18,7 +18,7 @@ use OCP\Server; class Hooks { - public static function announce_settings(array $settings): void { + public function announce_settings(array $settings): void { // Nextcloud encodes this as JSON, Owncloud does not (yet) (#75) // TODO: remove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties $user = Server::get(IUserSession::class)->getUser(); @@ -39,7 +39,7 @@ class Hooks { } } - protected static function deleteFile(IDBConnection $connection, int $fileId): void { + protected function deleteFile(IDBConnection $connection, int $fileId): void { $queryBuilder = $connection->getQueryBuilder(); $queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId); $queryBuilder->executeStatement(); @@ -49,7 +49,7 @@ class Hooks { $queryBuilder->executeStatement(); } - protected static function deleteUser(IDBConnection $connection, string $userId): void { + protected function deleteUser(IDBConnection $connection, string $userId): void { $queryBuilder = $connection->getQueryBuilder(); $queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId); $queryBuilder->executeStatement(); @@ -59,7 +59,7 @@ class Hooks { $queryBuilder->executeStatement(); } - private static function isJson(mixed $string): bool { + private function isJson(mixed $string): bool { return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false; } }