FIx database
This commit is contained in:
parent
79788c98b9
commit
495dd51834
@ -26,8 +26,8 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
'fileId' => $this->getFileId(),
|
'fileId' => $this->getFileId(),
|
||||||
'type' => $this->getType(),
|
'type' => $this->getType(),
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'value' => static::conditional_json_decode($this->getValue()),
|
'value' => $this->conditional_json_decode($this->getValue()),
|
||||||
'content' => static::conditional_json_decode($this->getContent()),
|
'content' => $this->conditional_json_decode($this->getContent()),
|
||||||
'lastModified' => $this->getLastModified()
|
'lastModified' => $this->getLastModified()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -48,6 +48,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setUserId(string $userId): void {
|
public function setUserId(string $userId): void {
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
|
$this->markFieldUpdated('userId');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFileId(): int {
|
public function getFileId(): int {
|
||||||
@ -56,6 +57,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setFileId(int $fileId): void {
|
public function setFileId(int $fileId): void {
|
||||||
$this->fileId = $fileId;
|
$this->fileId = $fileId;
|
||||||
|
$this->markFieldUpdated('fileId');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType(): string {
|
public function getType(): string {
|
||||||
@ -64,6 +66,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setType(string $type): void {
|
public function setType(string $type): void {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
$this->markFieldUpdated('type');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
@ -72,6 +75,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setName(string $name): void {
|
public function setName(string $name): void {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
$this->markFieldUpdated('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValue(): string {
|
public function getValue(): string {
|
||||||
@ -80,6 +84,7 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setValue(string $value): void {
|
public function setValue(string $value): void {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
$this->markFieldUpdated('value');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContent(): string {
|
public function getContent(): string {
|
||||||
@ -88,5 +93,6 @@ class Bookmark extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setContent(string $content): void {
|
public function setContent(string $content): void {
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
|
$this->markFieldUpdated('content');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ class Preference extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setUserId(string $userId): void {
|
public function setUserId(string $userId): void {
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
|
$this->markFieldUpdated('userId');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getScope(): string {
|
public function getScope(): string {
|
||||||
@ -50,6 +51,7 @@ class Preference extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setScope(string $scope): void {
|
public function setScope(string $scope): void {
|
||||||
$this->scope = $scope;
|
$this->scope = $scope;
|
||||||
|
$this->markFieldUpdated('scope');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFileId(): int {
|
public function getFileId(): int {
|
||||||
@ -58,6 +60,7 @@ class Preference extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setFileId(int $fileId): void {
|
public function setFileId(int $fileId): void {
|
||||||
$this->fileId = $fileId;
|
$this->fileId = $fileId;
|
||||||
|
$this->markFieldUpdated('fileId');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
@ -66,6 +69,7 @@ class Preference extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setName(string $name): void {
|
public function setName(string $name): void {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
$this->markFieldUpdated('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValue(): string {
|
public function getValue(): string {
|
||||||
@ -74,5 +78,6 @@ class Preference extends ReaderEntity implements \JsonSerializable {
|
|||||||
|
|
||||||
public function setValue(string $value): void {
|
public function setValue(string $value): void {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
$this->markFieldUpdated('value');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ abstract class ReaderEntity extends Entity {
|
|||||||
*
|
*
|
||||||
* @return string|array
|
* @return string|array
|
||||||
*/
|
*/
|
||||||
public static function conditional_json_decode(string $el): mixed {
|
public function conditional_json_decode(string $el): mixed {
|
||||||
/** @var array $result */
|
/** @var array $result */
|
||||||
$result = json_decode($el);
|
$result = json_decode($el);
|
||||||
if (json_last_error() === JSON_ERROR_NONE) {
|
if (json_last_error() === JSON_ERROR_NONE) {
|
||||||
@ -40,6 +40,7 @@ abstract class ReaderEntity extends Entity {
|
|||||||
|
|
||||||
public function setLastModified(int $lastModified): void {
|
public function setLastModified(int $lastModified): void {
|
||||||
$this->lastModified = $lastModified;
|
$this->lastModified = $lastModified;
|
||||||
|
$this->markFieldUpdated('lastModified');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ use OCP\Server;
|
|||||||
|
|
||||||
class Hooks {
|
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)
|
// 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
|
// 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();
|
$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 = $connection->getQueryBuilder();
|
||||||
$queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
$queryBuilder->delete('reader_bookmarks')->where('file_id = file_id')->setParameter('file_id', $fileId);
|
||||||
$queryBuilder->executeStatement();
|
$queryBuilder->executeStatement();
|
||||||
@ -49,7 +49,7 @@ class Hooks {
|
|||||||
$queryBuilder->executeStatement();
|
$queryBuilder->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function deleteUser(IDBConnection $connection, string $userId): void {
|
protected function deleteUser(IDBConnection $connection, string $userId): void {
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
$queryBuilder = $connection->getQueryBuilder();
|
||||||
$queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId);
|
$queryBuilder->delete('reader_bookmarks')->where('user_id = user_id')->setParameter('user_id', $userId);
|
||||||
$queryBuilder->executeStatement();
|
$queryBuilder->executeStatement();
|
||||||
@ -59,7 +59,7 @@ class Hooks {
|
|||||||
$queryBuilder->executeStatement();
|
$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;
|
return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user