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)
*
* @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);
$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));
}
}
* 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
*
}
+ $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 {