mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
feat: better transparency page
This commit is contained in:
parent
6c0f26f20f
commit
c6b3f7770a
5 changed files with 62 additions and 3 deletions
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
18
public/transparency.php
Normal file
18
public/transparency.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/** @noinspection PhpDefineCanBeReplacedWithConstInspection */
|
||||
define('IN_PONEPASTE', 1);
|
||||
require_once(__DIR__ . '/../includes/common.php');
|
||||
|
||||
use PonePaste\Models\Paste;
|
||||
|
||||
$deleted_pastes = Paste::select('id', 'updated_at', 'title', 'user_id')
|
||||
->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');
|
|
@ -295,7 +295,7 @@ $flashes = getFlashes();
|
|||
<div class="column">
|
||||
<ul>
|
||||
<li><a href="/page/tags" target="_blank">Tag Guide</a></li>
|
||||
<li><a href="/page/transparency " target="_blank">Transparency</a></li>
|
||||
<li><a href="/transparency " target="_blank">Transparency</a></li>
|
||||
<li><a href="https://ko-fi.com/floorbored" target="_blank">Donate</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
31
theme/bulma/transparency.php
Normal file
31
theme/bulma/transparency.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<main class="bd-main">
|
||||
<div class="container">
|
||||
<div class="bd-duo">
|
||||
<div class="bd-lead">
|
||||
<h1 class="title is-4">Transparency</h1>
|
||||
<p>These are the most recently deleted pastes on the site.</p>
|
||||
<p>For pastes deleted on or before October 30, 2024, pastes will show as deleted on October 30, 2024.</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Author</th>
|
||||
<th>Title</th>
|
||||
<th>Deleted At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($deleted_pastes as $paste): ?>
|
||||
<tr>
|
||||
<td><?= $paste->id ?></td>
|
||||
<td><?= pp_html_escape($paste->user->username) ?></td>
|
||||
<td><?= pp_html_escape($paste->title) ?></td>
|
||||
<td><?= pp_html_escape($paste->deleted_at ?: 'Unknown') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
Loading…
Add table
Reference in a new issue