From a5819bb35d94e318d3d221dd7bbc4bea36c24ef0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 13 Jan 2010 12:48:49 +0300 Subject: code cleanup; remove unnecessary callbacks; rework subscribtion dialog --- modules/pref-feeds.php | 116 ++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 63 deletions(-) (limited to 'modules/pref-feeds.php') diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index c1190b549..9d33461af 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -819,67 +819,71 @@ } if ($subop == "add") { - - if (!WEB_DEMO_MODE) { - $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); - $cat_id = db_escape_string($_REQUEST["cat_id"]); - $p_from = db_escape_string($_REQUEST["from"]); - - /* only read authentication information from POST */ - - $auth_login = db_escape_string(trim($_POST["auth_login"])); - $auth_pass = db_escape_string(trim($_POST["auth_pass"])); - - if ($p_from != 'tt-rss') { - print " - - Tiny Tiny RSS - - - - \"Tiny -

Subscribe to feed...

"; - } + $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); + $cat_id = db_escape_string($_REQUEST["cat_id"]); + $p_from = db_escape_string($_REQUEST["from"]); - if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) { - print_notice(T_sprintf("Subscribed to %s.", $feed_url)); - } else { - print_warning(T_sprintf("Already subscribed to %s.", $feed_url)); - } + /* only read authentication information from POST */ - if ($p_from != 'tt-rss') { - $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); + $auth_login = db_escape_string(trim($_POST["auth_login"])); + $auth_pass = db_escape_string(trim($_POST["auth_pass"])); + if ($p_from != 'tt-rss') { + print " + + Tiny Tiny RSS + + + + \"Tiny +

Subscribe to feed...

"; + } - $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); + $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass); + + switch ($rc) { + case 1: + print_notice(T_sprintf("Subscribed to %s.", $feed_url)); + break; + case 2: + print_error(T_sprintf("Could not subscribe to %s.", $feed_url)); + break; + case 0: + print_warning(T_sprintf("Already subscribed to %s.", $feed_url)); + break; + } - $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE - feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); + if ($p_from != 'tt-rss') { + $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); - $feed_id = db_fetch_result($result, 0, "id"); - print "

"; + $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); - if ($feed_id) { - print "

- - - - -
"; - } + $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE + feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); - print "
- -

"; + $feed_id = db_fetch_result($result, 0, "id"); - print ""; - return; + print "

"; + + if ($feed_id) { + print "

+ + + + +
"; } + print "
+ +

"; + + print ""; + return; } } @@ -1358,21 +1362,6 @@ print "

"; -/* print "

"; - - if (get_pref($link, 'ENABLE_FEED_CATS')) { - - print __('Selection:') . " "; - - print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); - - print " "; - } - - print "
"; */ - } else { print "

"; @@ -1538,4 +1527,5 @@ return $feedctr; } + ?> -- cgit v1.2.3