summaryrefslogtreecommitdiff
path: root/src/application/mystic
diff options
context:
space:
mode:
Diffstat (limited to 'src/application/mystic')
-rw-r--r--src/application/mystic/forum/Database.php4
-rw-r--r--src/application/mystic/forum/orm/PendingEmail.php19
-rw-r--r--src/application/mystic/forum/orm/Subscription.php14
-rw-r--r--src/application/mystic/forum/utils/StringUtils.php2
4 files changed, 37 insertions, 2 deletions
diff --git a/src/application/mystic/forum/Database.php b/src/application/mystic/forum/Database.php
index 1c2d710..bca4ac9 100644
--- a/src/application/mystic/forum/Database.php
+++ b/src/application/mystic/forum/Database.php
@@ -46,12 +46,12 @@ class Database {
protected function queryParams(string $query, array $params): Result|false {
++$this->queryCount;
- return \pg_query_params ($this->connection, $query, $params);
+ return \pg_query_params($this->connection, $query, $params);
}
protected function query(string $query): Result|false {
++$this->queryCount;
- return \pg_query ($this->connection, $query);
+ return \pg_query($this->connection, $query);
}
public static function generateId(int $length = 64): string {
diff --git a/src/application/mystic/forum/orm/PendingEmail.php b/src/application/mystic/forum/orm/PendingEmail.php
new file mode 100644
index 0000000..70622b3
--- /dev/null
+++ b/src/application/mystic/forum/orm/PendingEmail.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace mystic\forum\orm;
+
+use mystic\forum\attributes\PrimaryKey;
+use mystic\forum\attributes\Table;
+use mystic\forum\orm\Entity;
+
+#[Table("public.emails")]
+class PendingEmail extends Entity {
+ #[PrimaryKey] public string $id;
+ public string $sender;
+ public string $recipient;
+ public string $subject;
+ public ?string $htmlBody;
+ public ?string $plaintextBody;
+
+ // TODO Attachments
+}
diff --git a/src/application/mystic/forum/orm/Subscription.php b/src/application/mystic/forum/orm/Subscription.php
new file mode 100644
index 0000000..6934685
--- /dev/null
+++ b/src/application/mystic/forum/orm/Subscription.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace mystic\forum\orm;
+
+use mystic\forum\attributes\PrimaryKey;
+use mystic\forum\attributes\References;
+use mystic\forum\attributes\Table;
+
+#[Table("public.subscriptions")]
+class Subscription extends Entity {
+ #[PrimaryKey] public string $id;
+ #[References("public.topics", onDelete: References::CASCADE)] public string $topicId;
+ #[References("public.users", onDelete: References::CASCADE)] public string $userId;
+}
diff --git a/src/application/mystic/forum/utils/StringUtils.php b/src/application/mystic/forum/utils/StringUtils.php
index fd38915..94221fb 100644
--- a/src/application/mystic/forum/utils/StringUtils.php
+++ b/src/application/mystic/forum/utils/StringUtils.php
@@ -23,6 +23,8 @@ final class StringUtils {
}
public static function truncate(string $str, int $maxLength, string $ellipsis = "…"): string {
+ if ($maxLength < 0)
+ return $str;
return mb_strimwidth($str, 0, $maxLength, $ellipsis);
}
}