]> git.wh0rd.org Git - tt-rss.git/commitdiff
add toggle_collapse_cat()
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 24 Dec 2009 12:36:02 +0000 (15:36 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 24 Dec 2009 12:36:02 +0000 (15:36 +0300)
backend.php
functions.php
mobile/classic/index.php

index a25a0b5be177c9322aaeda052f4d0a9c49b1ca0c..b4b58a78764323c7872cd8fd1b87e1877b42eaee 100644 (file)
 
                                case "collapse":
                                        $cat_id = db_escape_string($_GET["cid"]);
-
-                                       if ($cat_id > 0) {
-                                               db_query($link, "UPDATE ttrss_feed_categories SET
-                                                       collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . 
-                                                       $_SESSION["uid"]);
-                                       } else {
-                                               $pref_name = '';
-
-                                               switch ($cat_id) {
-                                               case -1:
-                                                       $pref_name = '_COLLAPSED_SPECIAL';
-                                                       break;
-                                               case -2:
-                                                       $pref_name = '_COLLAPSED_LABELS';
-                                                       break;
-                                               case 0:
-                                                       $pref_name = '_COLLAPSED_UNCAT';
-                                                       break;
-                                               }
-
-                                               if ($pref_name) {
-                                                       if (get_pref($link, $pref_name)) {
-                                                               set_pref($link, $pref_name, 'false');
-                                                       } else {
-                                                               set_pref($link, $pref_name, 'true');
-                                                       }
-                                               }
-                                       }
+                                       toggle_collapse_cat($link, $cat_id);
                                        return;
                                break;
 
index d7ef40cf6745c6d770e1bdb23e4f56b46b0e4dfa..378242cb27c7bc5fbed0955650331d228228a3db 100644 (file)
 
                return $str;
        }
+
+       function toggle_collapse_cat($link, $cat_id) {
+               if ($cat_id > 0) {
+                       db_query($link, "UPDATE ttrss_feed_categories SET
+                               collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . 
+                               $_SESSION["uid"]);
+               } else {
+                       $pref_name = '';
+
+                       switch ($cat_id) {
+                       case -1:
+                               $pref_name = '_COLLAPSED_SPECIAL';
+                               break;
+                       case -2:
+                               $pref_name = '_COLLAPSED_LABELS';
+                               break;
+                       case 0:
+                               $pref_name = '_COLLAPSED_UNCAT';
+                               break;
+                       }
+
+                       if ($pref_name) {
+                               if (get_pref($link, $pref_name)) {
+                                       set_pref($link, $pref_name, 'false');
+                               } else {
+                                       set_pref($link, $pref_name, 'true');
+                               }
+                       }
+               }
+       }
 ?>
index 4b158395bf6da340c448f2316c73f1c3393066f4..260095b2608abea6da091d2e954a35726e02cb5e 100644 (file)
        if ($subop == "tc" && !$go) {
                
                $cat_id = db_escape_string($_GET["id"]);
-
-               if ($cat_id > 0) {
-                       db_query($link, "UPDATE ttrss_feed_categories SET
-                               collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . 
-                               $_SESSION["uid"]);
-               } else {
-                       $pref_name = '';
-
-                       switch ($cat_id) {
-                       case -1:
-                               $pref_name = '_COLLAPSED_SPECIAL';
-                               break;
-                       case -2:
-                               $pref_name = '_COLLAPSED_LABELS';
-                               break;
-                       case 0:
-                               $pref_name = '_COLLAPSED_UNCAT';
-                               break;
-                       }
-
-                       if ($pref_name) {
-                               if (get_pref($link, $pref_name)) {
-                                       set_pref($link, $pref_name, 'false');
-                               } else {
-                                       set_pref($link, $pref_name, 'true');
-                               }
-                       }
-               }
+               toggle_collapse_cat($link, $cat_id);
 
                header("Location: index.php");
                return;