From 7f969260c1845d76b223197fd4392dd1576d548e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Dec 2009 15:36:02 +0300 Subject: [PATCH] add toggle_collapse_cat() --- backend.php | 29 +---------------------------- functions.php | 30 ++++++++++++++++++++++++++++++ mobile/classic/index.php | 29 +---------------------------- 3 files changed, 32 insertions(+), 56 deletions(-) diff --git a/backend.php b/backend.php index a25a0b5b..b4b58a78 100644 --- a/backend.php +++ b/backend.php @@ -173,34 +173,7 @@ 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; diff --git a/functions.php b/functions.php index d7ef40cf..378242cb 100644 --- a/functions.php +++ b/functions.php @@ -6266,4 +6266,34 @@ 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'); + } + } + } + } ?> diff --git a/mobile/classic/index.php b/mobile/classic/index.php index 4b158395..260095b2 100644 --- a/mobile/classic/index.php +++ b/mobile/classic/index.php @@ -26,34 +26,7 @@ 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; -- 2.39.5