]> git.mjollnir.org Git - s9y.git/commitdiff
allow to hide categories
authorgarvinhicking <garvinhicking>
Sat, 10 Dec 2005 20:49:14 +0000 (20:49 +0000)
committergarvinhicking <garvinhicking>
Sat, 10 Dec 2005 20:49:14 +0000 (20:49 +0000)
docs/NEWS
include/functions_entries.inc.php

index 71f946258fcf4155293f955854a72b90be73e5a7..ee72e380be6c0b7eca8ac0f7ec0cba477f5e896b 100644 (file)
--- 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)
index 314e816fc272755f1bff91fa95c59e7c22da6d3d..96ebeca15391246de6e93e4195a261efb746f1f4 100644 (file)
@@ -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 {