From b1bd14bc565b3227c3259d04e592552ece429ed3 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Fri, 18 Feb 2022 22:09:26 +0100 Subject: [PATCH] Add functions for checking if places or actor names are blacklisted Close #6, close #7 --- src/NodaBlacklistedTerms.php | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/NodaBlacklistedTerms.php b/src/NodaBlacklistedTerms.php index e70c775..39e4456 100644 --- a/src/NodaBlacklistedTerms.php +++ b/src/NodaBlacklistedTerms.php @@ -62,4 +62,58 @@ final class NodaBlacklistedTerms { return false; } + + /** + * Checks if a place name is blacklisted in the DB. + * + * @param MDMysqli $mysqli DB connection. + * @param string $lang The user's currently used language. + * @param string $name The name entered by the user. + * + * @return boolean + */ + public static function checkPlaceBlacklistedInDb(MDMysqli $mysqli, string $lang, string $name):bool { + + $result = $mysqli->query_by_stmt("SELECT 1 + FROM `" . DATABASENAME_NODA . "`.`orte_blacklist` + WHERE `language` = ? + AND `ort_name` = ? + LIMIT 1", "ss", $lang, $name); + + if ($result->num_rows === 0) { + $result->close(); + return false; + } + + $result->close(); + return true; + + } + + /** + * Checks if an actor name is blacklisted in the DB. + * + * @param MDMysqli $mysqli DB connection. + * @param string $lang The user's currently used language. + * @param string $name The name entered by the user. + * + * @return boolean + */ + public static function checkPersinstBlacklistedInDb(MDMysqli $mysqli, string $lang, string $name):bool { + + $result = $mysqli->query_by_stmt("SELECT 1 + FROM `" . DATABASENAME_NODA . "`.`persinst_blacklist` + WHERE `language` = ? + AND `persinst_name` = ? + LIMIT 1", "ss", $lang, $name); + + if ($result->num_rows === 0) { + $result->close(); + return false; + } + + $result->close(); + return true; + + } }