diff --git a/theme/functions.php b/theme/functions.php index b298b50..9e6b9ab 100644 --- a/theme/functions.php +++ b/theme/functions.php @@ -4,6 +4,7 @@ use WoWPress\Database\CreateCacheTable; use WoWPress\Database\CreateCharacterTable; use WoWPress\Database\CreateComplaintTable; use WoWPress\Database\CreateLogTable; +use WoWPress\Database\CreateNotificationTable; use WoWPress\Database\CreateRaidTable; use WoWPress\Database\CreateSignupTable; use WoWPress\Database\CreateSKSTable; @@ -161,7 +162,7 @@ if (!function_exists('wowpress_database')) : CreateSKSTable::sql(), CreateLogTable::sql(), CreateComplaintTable::sql(), - + CreateNotificationTable::sql(), ]); } @@ -479,12 +480,13 @@ function wowpress_add_category_meta($taxonomy) /** Avatar Filters */ add_filter('get_avatar_url', '\WoWPress\Models\User::getAvatar', 10, 3); - add_filter('asgarosforum_filter_username', '\WoWPress\Models\User::getUsername', 10, 2); + add_filter('asgarosforum_filter_username', '\WoWPress\Models\User::getUsername', 10, 2); /** Login redirect */ - add_filter('login_redirect', fn() => "/"); + add_filter('login_redirect', fn () => "/"); - function sanitize($word){ - $char = new Character(); - return $char->sanitize($word); - } \ No newline at end of file + function sanitize($word) + { + $char = new Character(); + return $char->sanitize($word); + } diff --git a/theme/pages/complaints.php b/theme/pages/complaints.php index 46e50c6..d58e91c 100644 --- a/theme/pages/complaints.php +++ b/theme/pages/complaints.php @@ -27,7 +27,7 @@ $complaints = Complaint::getAll();

Willkommen in unserem Kummerkasten

- Du hast etwas auf dem Herzen, möchtest deinem Ärger Luft machen oder uns einfach nur so etwas mitteilen?
+ Du hast etwas auf dem Herzen oder uns einfach nur so etwas mitteilen?
Dann ist hier der richtige Ort dafür!

@@ -35,7 +35,6 @@ $complaints = Complaint::getAll();

Wenn du "unerkannt" bleiben möchtest kannst du das Formular auch "anonym" absenden. Allerdings kann man in der Datenbank trotzdem sehen wer das Formular abgeschickt hat, um Missbrauch zu vermeiden.
- Hier musst du darauf vertrauen, dass der Webseiten-Gott nicht so gemein ist und in der Datenbank auf die Suche geht. Normalsterbliche Offis können allerdings nicht sehen wer das Formular abgeschickt hat.

@@ -47,7 +46,7 @@ $complaints = Complaint::getAll();

Neue Einsendung

- +
@@ -65,8 +64,8 @@ $complaints = Complaint::getAll(); -
"> - deleted_at) : ?> +
0 ? "border border-dashed border-white bg-green-800 bg-opacity-60 backdrop-blur-md" : "bg-black bg-opacity-60 backdrop-blur-md" ?>"> + deleted_at."") > 0) : ?>
Eintrag gelöscht
@@ -97,7 +96,7 @@ $complaints = Complaint::getAll();
complaint ?>
- deleted_at) : ?> + deleted_at."") > 0)) : ?> diff --git a/theme/request.php b/theme/request.php index d0f062a..fbade3f 100644 --- a/theme/request.php +++ b/theme/request.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Redirect; use WoWPress\Models\Character; use WoWPress\Models\Complaint; use WoWPress\Models\Log; +use WoWPress\Models\Notification; use WoWPress\Models\Raid; use WoWPress\Models\Signup; use WoWPress\Models\SKS; @@ -255,6 +256,7 @@ switch ($_POST['action']) { if ($c) { $c->user_comment = $_POST['user_comment']; $c->save(); + Notification::addNotification($c->user_id, "Neuer Kommentar im Kummerkasten!"); } } } @@ -317,6 +319,18 @@ switch ($_POST['action']) { } } break; + case 'notificationSeen': + if (is_user_logged_in()) { + if (isset($_POST['notificationSeen_nonce']) && wp_verify_nonce($_POST['notificationSeen_nonce'], 'notificationSeen')) { + if (isset($_POST['notification_id'])) { + $note = Notification::find($_POST['notification_id']); + if(!empty($note->ID && $note->user_id == get_current_user_id())){ + $note->delete(); + } + } + } + } + break; } header('Location: ' . $_SERVER['HTTP_REFERER']); diff --git a/theme/template-parts/layout/header-content.php b/theme/template-parts/layout/header-content.php index bff6f78..a978d73 100644 --- a/theme/template-parts/layout/header-content.php +++ b/theme/template-parts/layout/header-content.php @@ -10,6 +10,13 @@ use WoWPress\Frontend\Icon; use WoWPress\Frontend\NavWalker; +use WoWPress\Models\Notification; + +if (is_user_logged_in()) { + $notifications = Notification::getAll(); +} else { + $notifications = []; +} ?> @@ -45,7 +52,7 @@ use WoWPress\Frontend\NavWalker;
-
+
+ first())) : ?> +
+
+ +
+ +
note ?>
+ +
+ +
+
+ - +
diff --git a/theme/wowpress/Database/CreateNotificationTable.php b/theme/wowpress/Database/CreateNotificationTable.php new file mode 100644 index 0000000..98dccce --- /dev/null +++ b/theme/wowpress/Database/CreateNotificationTable.php @@ -0,0 +1,17 @@ + 'mediumint', + 'note' => 'text NOT NULL', + 'created_at' => 'timestamp NOT NULL', + 'updated_at' => 'timestamp NOT NULL', + ]; + +} diff --git a/theme/wowpress/Models/Complaint.php b/theme/wowpress/Models/Complaint.php index 78831af..74d2dcf 100644 --- a/theme/wowpress/Models/Complaint.php +++ b/theme/wowpress/Models/Complaint.php @@ -41,7 +41,7 @@ class Complaint extends Model{ } public function canEdit(){ - return current_user_can('wowpress_edit_complaints') && (get_current_user_id() != $this->user_id); + return current_user_can('wowpress_edit_complaints');# && (get_current_user_id() != $this->user_id); } diff --git a/theme/wowpress/Models/Notification.php b/theme/wowpress/Models/Notification.php new file mode 100644 index 0000000..a7ec384 --- /dev/null +++ b/theme/wowpress/Models/Notification.php @@ -0,0 +1,26 @@ +user_id = $user_id; + $note->note = $note_text; + $note->save(); + } + + public static function getAll(){ + return Notification::where('user_id',get_current_user_id())->get(); + } + +} \ No newline at end of file diff --git a/wowpress_2.zip b/wowpress_2.zip new file mode 100644 index 0000000..0684fd6 Binary files /dev/null and b/wowpress_2.zip differ