From: garvinhicking Date: Sat, 10 Dec 2005 20:49:14 +0000 (+0000) Subject: allow to hide categories X-Git-Tag: 1.0~241 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=415e6f70b0cb32812196d73bbac72f6baaa7adad;p=s9y.git allow to hide categories --- diff --git a/docs/NEWS b/docs/NEWS index 71f9462..ee72e38 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.0 () ------------------------------------------------------------------------ + * Allow to restrict not showing entries from special category via + $serendipity['GET']['hide_category']. (garvinhicking) + * Allow to edit a HTML nugget with a frontend link (garvinhicking) * Added sidebar plugin to show statistical data (garvinhicking) diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 314e816..96ebeca 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -45,9 +45,10 @@ function serendipity_fetchCategoryRange($categoryid) { * * @access public * @param string A listing of category ids to check, separated by ";" + * @param boolean Toggle whether to include or exclude entries of this category * @return string Returns the SQL code for selecting entries of the calculated categories */ -function serendipity_getMultiCategoriesSQL($cats) { +function serendipity_getMultiCategoriesSQL($cats, $invert = false) { global $serendipity; $mcategories = explode(';', $cats); @@ -56,7 +57,7 @@ function serendipity_getMultiCategoriesSQL($cats) { $categoryid = (int)$categoryid; if ($categoryid != 0) { - $cat_sql_array[] = " c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid)); + $cat_sql_array[] = " c.category_left " . ($invert ? : " NOT " : "") . " BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid)); } } @@ -149,7 +150,8 @@ function serendipity_fetchEntryCategories($entryid) { * Other "external" variables that affect this function are: * $serendipity['short_archives'] - Indicates if the short archive listing is wanted, without the full entry text * $serendipity['range'] - If $range is not used, the time restriction is fetched from this array, which holds a start timestamp and end timestamp. - * $serendipity['GET']['category'] - The category ID to restrict fetching entries from + * $serendipity['GET']['category'] - The category ID to restrict fetching entries from (can be seperated by ";") + * $serendipity['GET']['hide_category']- The category ID to NOT fetch entries from (can be seperated by ";") * $serendipity['GET']['viewAuthor'] - Only fetch entries by this author * $serendipity['GET']['page'] - The page number to show entries, for pagination * @@ -257,8 +259,14 @@ function serendipity_fetchEntries($range = null, $full = true, $limit = '', $fet } + $cat_sql = ''; if (isset($serendipity['GET']['category'])) { $cat_sql = serendipity_getMultiCategoriesSQL($serendipity['GET']['category']); + } elseif (isset($serendipity['GET']['hide_category'])) { + $cat_sql = serendipity_getMultiCategoriesSQL($serendipity['GET']['hide_category'], true); + } + + if (!empty($cat_sql)) { if (!empty($cond['and'])) { $cond['and'] .= " AND ($cat_sql)"; } else {