Schedule releases by release_date and block unreleased store purchases
This commit is contained in:
@@ -46,6 +46,7 @@ class ReleasesController
|
||||
}
|
||||
if ($db instanceof PDO) {
|
||||
try {
|
||||
$today = date('Y-m-d');
|
||||
$stmt = $db->prepare("SELECT title, content_html FROM ac_pages WHERE slug = 'releases' AND is_published = 1 LIMIT 1");
|
||||
$stmt->execute();
|
||||
$page = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
|
||||
@@ -58,7 +59,8 @@ class ReleasesController
|
||||
}
|
||||
|
||||
$params = [];
|
||||
$where = ["r.is_published = 1"];
|
||||
$where = ["r.is_published = 1", "(r.release_date IS NULL OR r.release_date <= :today)"];
|
||||
$params[':today'] = $today;
|
||||
if ($artistFilter !== '') {
|
||||
if ($artistJoinReady) {
|
||||
$where[] = "(r.artist_name = :artist OR a.name = :artist)";
|
||||
@@ -109,6 +111,7 @@ class ReleasesController
|
||||
FROM ac_releases r
|
||||
LEFT JOIN ac_artists a ON a.id = r.artist_id
|
||||
WHERE r.is_published = 1
|
||||
AND (r.release_date IS NULL OR r.release_date <= CURDATE())
|
||||
ORDER BY artist_name ASC
|
||||
");
|
||||
} else {
|
||||
@@ -144,6 +147,7 @@ class ReleasesController
|
||||
SELECT DISTINCT TRIM(artist_name) AS artist_name
|
||||
FROM ac_releases
|
||||
WHERE is_published = 1
|
||||
AND (release_date IS NULL OR release_date <= CURDATE())
|
||||
ORDER BY artist_name ASC
|
||||
");
|
||||
}
|
||||
@@ -188,8 +192,18 @@ class ReleasesController
|
||||
$db = Database::get();
|
||||
if ($db instanceof PDO) {
|
||||
try {
|
||||
$stmt = $db->prepare("SELECT * FROM ac_releases WHERE slug = :slug AND is_published = 1 LIMIT 1");
|
||||
$stmt->execute([':slug' => $slug]);
|
||||
$stmt = $db->prepare("
|
||||
SELECT *
|
||||
FROM ac_releases
|
||||
WHERE slug = :slug
|
||||
AND is_published = 1
|
||||
AND (release_date IS NULL OR release_date <= :today)
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->execute([
|
||||
':slug' => $slug,
|
||||
':today' => date('Y-m-d'),
|
||||
]);
|
||||
$release = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
|
||||
if ($release) {
|
||||
if ($storePluginEnabled) {
|
||||
|
||||
@@ -30,6 +30,7 @@ Shortcodes::register('releases', static function (array $attrs = []): string {
|
||||
FROM ac_releases r
|
||||
LEFT JOIN ac_artists a ON a.id = r.artist_id
|
||||
WHERE r.is_published = 1
|
||||
AND (r.release_date IS NULL OR r.release_date <= CURDATE())
|
||||
ORDER BY r.release_date DESC, r.created_at DESC
|
||||
LIMIT :limit
|
||||
");
|
||||
@@ -38,6 +39,7 @@ Shortcodes::register('releases', static function (array $attrs = []): string {
|
||||
SELECT title, slug, release_date, cover_url, artist_name
|
||||
FROM ac_releases
|
||||
WHERE is_published = 1
|
||||
AND (release_date IS NULL OR release_date <= CURDATE())
|
||||
ORDER BY release_date DESC, created_at DESC
|
||||
LIMIT :limit
|
||||
");
|
||||
|
||||
Reference in New Issue
Block a user