feat: ability to blank paste contents

This commit is contained in:
Floorb 2023-07-05 02:55:52 -04:00
parent 776a0ba636
commit 36abc1725e
2 changed files with 30 additions and 5 deletions

View file

@ -118,7 +118,24 @@ if (isset($_POST['hide'])) {
$paste->save();
$redis->del('ajax_pastes'); /* Expire from Redis so it doesn't show up anymore */
flashSuccess('Paste ' . ($is_hidden ? 'hidden' : 'unhidden') . '.');
header('Location: /');
header('Location: ' . urlForPaste($paste));
die();
}
if (isset($_POST['blank'])) {
if (!can('blank', $paste)) {
$error = 'You do not have permission to blank this paste.';
goto Not_Valid_Paste;
}
$paste->content = '';
$paste->title = 'Removed by moderator';
$paste->tags()->detach();
$paste->save();
$redis->del('ajax_pastes'); /* Expire from Redis so it doesn't show up anymore */
flashSuccess('Paste contents blanked.');
header('Location: ' . urlForPaste($paste));
die();
}

View file

@ -153,11 +153,19 @@
<?php if (isset($csrf_token)): ?>
<input type="hidden" name="csrf_token" value="<?= $csrf_token ?>"/>
<?php endif; ?>
<div class="field">
<input class="button is-small <?= $paste->is_hidden ? 'is-success' : 'is-danger' ?>"
type="submit" name="hide" id="hide"
value="<?= $paste->is_hidden ? 'Unhide' : 'Hide' ?> Paste"/>
<div class="field is-grouped">
<div class="control">
<input class="button is-small <?= $paste->is_hidden ? 'is-success' : 'is-danger' ?>"
type="submit" name="hide" id="hide"
value="<?= $paste->is_hidden ? 'Unhide' : 'Hide' ?> Paste" />
</div>
<?php if (can('blank', $paste)): ?>
<div class="control">
<input class="button is-small is-danger" type="submit" name="blank" id="blank" value="Blank Paste Contents (No Undo)" />
</div>
<?php endif; ?>
</div>
</form>
</div>
<?php endif; ?>