From a16c956a53dc37b7629aa94ec927c98249868368 Mon Sep 17 00:00:00 2001 From: SenorSmartyPants Date: Wed, 9 Dec 2020 14:30:28 -0600 Subject: [PATCH] cops_ignored_formats list array of formats never to return from the database. ORIGINAL_EPUB as an example --- config_default.php | 5 +++++ lib/Data.php | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/config_default.php b/config_default.php index 84397db17..3f4ea3d6a 100644 --- a/config_default.php +++ b/config_default.php @@ -109,6 +109,11 @@ */ $config['cops_prefered_format'] = array('EPUB', 'PDF', 'AZW3', 'AZW', 'MOBI', 'CBR', 'CBZ'); + /* + * Specify the ignored formats that will never display in COPS + */ + $config['cops_ignored_formats'] = array(); + /* * use URL rewriting for downloading of ebook in HTML catalog * See Github wiki for more information diff --git a/lib/Data.php b/lib/Data.php index 3a4ab254d..cae9dc4d3 100644 --- a/lib/Data.php +++ b/lib/Data.php @@ -153,9 +153,20 @@ public function getHtmlLinkWithRewriting ($title = NULL, $view = false) { } public static function getDataByBook ($book) { + global $config; + $out = array (); - $result = parent::getDb ()->prepare('select id, format, name - from data where book = ?'); + + $sql = 'select id, format, name from data where book = ?'; + + $ignored_formats = $config['cops_ignored_formats']; + if (count($ignored_formats) > 0) { + $sql .= " and format not in ('" + . implode("','", $ignored_formats) + . "')"; + } + + $result = parent::getDb ()->prepare($sql); $result->execute (array ($book->id)); while ($post = $result->fetchObject ())