From c6b3f7770af30eb262614d550e994d50128c6f5a Mon Sep 17 00:00:00 2001
From: Floorb <132411956+Neetpone@users.noreply.github.com>
Date: Wed, 30 Oct 2024 00:22:35 -0400
Subject: [PATCH] feat: better transparency page
---
includes/Models/Paste.php | 9 +++++++--
public/admin/paste_action.php | 5 +++++
public/transparency.php | 18 ++++++++++++++++++
theme/bulma/common.php | 2 +-
theme/bulma/transparency.php | 31 +++++++++++++++++++++++++++++++
5 files changed, 62 insertions(+), 3 deletions(-)
create mode 100644 public/transparency.php
create mode 100644 theme/bulma/transparency.php
diff --git a/includes/Models/Paste.php b/includes/Models/Paste.php
index 550aba6..f3c2321 100644
--- a/includes/Models/Paste.php
+++ b/includes/Models/Paste.php
@@ -14,8 +14,9 @@ class Paste extends Model {
protected $guarded = [];
protected $casts = [
- 'visible' => 'integer',
- 'encrypt' => 'boolean'
+ 'visible' => 'integer',
+ 'encrypt' => 'boolean',
+ 'deleted_at' => 'datetime',
];
public $timestamps = false;
@@ -23,6 +24,10 @@ class Paste extends Model {
return $this->belongsTo(User::class);
}
+ public function deletedBy() {
+ return $this->belongsTo(User::class, 'deleted_by_id');
+ }
+
public function tags() {
return $this->belongsToMany(Tag::class, 'paste_taggings');
}
diff --git a/public/admin/paste_action.php b/public/admin/paste_action.php
index 019b4b2..334b5a8 100644
--- a/public/admin/paste_action.php
+++ b/public/admin/paste_action.php
@@ -31,6 +31,11 @@ if (isset($_POST['hide'])) {
if ($is_hidden) {
$paste->reports()->update(['open' => false]);
+ $paste->deleted_at = date_create();
+ $paste->deleted_by_id = $current_user->id;
+ } else {
+ $paste->deleted_at = null;
+ $paste->deleted_by_id = null;
}
$paste->is_hidden = $is_hidden;
diff --git a/public/transparency.php b/public/transparency.php
new file mode 100644
index 0000000..24b526d
--- /dev/null
+++ b/public/transparency.php
@@ -0,0 +1,18 @@
+with(['user' => function($q) { $q->select('id', 'username'); }])
+ ->where('is_hidden', true)
+ ->orderBy('deleted_at', 'desc')
+ ->limit(20)
+ ->get();
+
+$page_template = 'transparency';
+$page_title = 'Transparency';
+
+require_once(__DIR__ . '/../theme/' . $default_theme . '/common.php');
diff --git a/theme/bulma/common.php b/theme/bulma/common.php
index 5a77389..8f9c738 100644
--- a/theme/bulma/common.php
+++ b/theme/bulma/common.php
@@ -295,7 +295,7 @@ $flashes = getFlashes();
diff --git a/theme/bulma/transparency.php b/theme/bulma/transparency.php
new file mode 100644
index 0000000..c10f183
--- /dev/null
+++ b/theme/bulma/transparency.php
@@ -0,0 +1,31 @@
+
+
+
+
+
Transparency
+
These are the most recently deleted pastes on the site.
+
For pastes deleted on or before October 30, 2024, pastes will show as deleted on October 30, 2024.
+
+
+
+ ID |
+ Author |
+ Title |
+ Deleted At |
+
+
+
+
+
+ = $paste->id ?> |
+ = pp_html_escape($paste->user->username) ?> |
+ = pp_html_escape($paste->title) ?> |
+ = pp_html_escape($paste->deleted_at ?: 'Unknown') ?> |
+
+
+
+
+
+
+
+
\ No newline at end of file