1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Add option to hide categories with negative order in getAllCategories method

This commit is contained in:
Daniel Neto 2025-07-02 16:25:28 -03:00
parent 2bde902595
commit fe8348b1f4
2 changed files with 6 additions and 3 deletions

View file

@ -365,14 +365,17 @@ class Category
//_error_log("deleteCategoryCache: {$cacheDir} = " . json_encode($rrmdir));
}
public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false, $onlySuggested = false, $sameUserGroupAsMe = false)
public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false, $onlySuggested = false, $sameUserGroupAsMe = false, $hideNegativeOrder = false)
{
global $global, $config;
if ($config->currentVersionLowerThen('8.4')) {
return false;
}
$sql = "SELECT * FROM categories c WHERE 1=1 ";
$sql = " AND (c.order IS NULL OR c.order >= 0) "; // this is a tricky to not display some categories
if($hideNegativeOrder){
$sql = " AND (c.order IS NULL OR c.order >= 0) "; // this is a tricky to not display some categories, for example will not show on sidebar
}
if (!empty($_GET['parentsOnly'])) {
$sql .= "AND parentId = 0 ";
}

View file

@ -582,7 +582,7 @@ $tToleranceSide = 0.2;
}
TimeLogEnd($tnameSide, __LINE__, $tToleranceSide);
$categories = Category::getAllCategories(false, true, $advancedCustom->CategoryShowOnlySuggested, $sameUserGroupAsMe);
$categories = Category::getAllCategories(false, true, $advancedCustom->CategoryShowOnlySuggested, $sameUserGroupAsMe, true);
TimeLogEnd($tnameSide, __LINE__, $tToleranceSide);
echo "<!-- categories found " . count($categories) . " -->";
foreach ($categories as $value) {