Add functions for checking if places or actor names are blacklisted

Close #6, close #7
This commit is contained in:
Joshua Ramon Enslin 2022-02-18 22:09:26 +01:00
parent e877e4edf1
commit b1bd14bc56
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -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;
}
}