v1.0.0.9
Publisium
- <?php
-
- declare(strict_types=1);
-
- if (!Auth::canModerate()) {
- exit;
- }
-
- $articleId = (int) ($_POST['article_id'] ?? 0);
- $decision = $_POST['decision'] ?? '';
- $reason = trim((string) ($_POST['rejection_reason'] ?? ''));
-
- if ($articleId <= 0) {
- exit;
- }
-
- $db = Database::site();
-
- if ($decision === 'approve') {
- $statement = $db->prepare(
- "UPDATE articles SET status = 'published', published_at = COALESCE(published_at, NOW()), rejection_reason = NULL WHERE id = :id AND deleted_at IS NULL"
- );
- $statement->execute(['id' => $articleId]);
- }
-
- if ($decision === 'reject') {
- $statement = $db->prepare(
- "UPDATE articles SET status = 'rejected', rejection_reason = :reason WHERE id = :id AND deleted_at IS NULL"
- );
- $statement->execute(['id' => $articleId, 'reason' => $reason]);
- }
-
- if ($decision === 'mark_paid' || $decision === 'mark_free') {
- $accessType = $decision === 'mark_paid' ? 'paid' : 'free';
- $statement = $db->prepare('UPDATE articles SET access_type = :access_type WHERE id = :id AND deleted_at IS NULL');
- $statement->execute(['access_type' => $accessType, 'id' => $articleId]);
- }
-