From 948cead0f11d33adbcf0d08773c716e1b6ebb101 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Fri, 13 Sep 2024 23:10:34 +0200 Subject: More changes --- src/.htaccess | 3 + .../mystic/forum/orm/UserPermissions.php | 5 +- src/application/views/form_addpost.php | 2 +- .../views/form_delete_topic_confirm.php | 22 +++ src/application/views/nav_guest.php | 4 +- src/application/views/nav_logged_in.php | 2 +- src/application/views/view_topic_start.php | 39 +++++- src/index.php | 151 +++++++++++++++++++-- 8 files changed, 205 insertions(+), 23 deletions(-) create mode 100644 src/.htaccess create mode 100644 src/application/views/form_delete_topic_confirm.php diff --git a/src/.htaccess b/src/.htaccess new file mode 100644 index 0000000..f4a5e0d --- /dev/null +++ b/src/.htaccess @@ -0,0 +1,3 @@ +RewriteEngine On + +RewriteRule ^/?@([a-z0-9]([._](?![._])|[a-z0-9]){2,30}[a-z0-9])$ /index.php?_action=lookupuser&handle=$1 [L] diff --git a/src/application/mystic/forum/orm/UserPermissions.php b/src/application/mystic/forum/orm/UserPermissions.php index cd2fdf4..47af076 100644 --- a/src/application/mystic/forum/orm/UserPermissions.php +++ b/src/application/mystic/forum/orm/UserPermissions.php @@ -33,6 +33,7 @@ final class UserPermissions { public const DELETE_OTHER_USER = 0x8000; public const DELETE_OTHER_TOPIC = 0x10000; + public const EDIT_OTHER_TOPIC = 0x20000; //////// @@ -40,6 +41,7 @@ final class UserPermissions { | self::EDIT_OWN_POST | self::DELETE_OWN_POST | self::CREATE_OWN_TOPIC + | self::EDIT_OWN_TOPIC | self::DELETE_OWN_TOPIC | self::CREATE_OWN_ATTACHMENT | self::EDIT_OWN_ATTACHMENT @@ -50,7 +52,8 @@ final class UserPermissions { public const GROUP_MOD = self::GROUP_USER | self::EDIT_OTHER_POST | self::DELETE_OTHER_USER - | self::DELETE_OTHER_TOPIC; + | self::DELETE_OTHER_TOPIC + | self::EDIT_OTHER_TOPIC; public const GROUP_ADMIN = self::GROUP_MOD | self::CREATE_OTHER_USER diff --git a/src/application/views/form_addpost.php b/src/application/views/form_addpost.php index 88eda27..88648b4 100644 --- a/src/application/views/form_addpost.php +++ b/src/application/views/form_addpost.php @@ -20,7 +20,7 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
- +
diff --git a/src/application/views/form_delete_topic_confirm.php b/src/application/views/form_delete_topic_confirm.php new file mode 100644 index 0000000..d38ffaa --- /dev/null +++ b/src/application/views/form_delete_topic_confirm.php @@ -0,0 +1,22 @@ +
+
+

Do you want to delete this topic?

+
+
+ Are you sure you want to delete the topic title) ?> including all posts and attachments?
+
+ +
diff --git a/src/application/views/nav_guest.php b/src/application/views/nav_guest.php index 433c487..f897763 100644 --- a/src/application/views/nav_guest.php +++ b/src/application/views/nav_guest.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/src/application/views/nav_logged_in.php b/src/application/views/nav_logged_in.php index fd46d6e..f899ad8 100644 --- a/src/application/views/nav_logged_in.php +++ b/src/application/views/nav_logged_in.php @@ -10,5 +10,5 @@ use mystic\forum\orm\User;

  • -
  • +
  • ">
  • diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php index 84a29de..4006982 100644 --- a/src/application/views/view_topic_start.php +++ b/src/application/views/view_topic_start.php @@ -3,13 +3,19 @@ use mystic\forum\orm\UserPermissions; $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false; +$canEdit = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::EDIT_OWN_TOPIC)) + || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_TOPIC)); + $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::DELETE_OWN_TOPIC)) || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_TOPIC)); ?> -