add another status code to subscribe_to_feed to prevent the frontend to do double work (refs #276)

This commit is contained in:
Christian Weiske 2010-11-09 08:09:10 +01:00 committed by Andrew Dolgov
parent f6d8345b01
commit 9a8ce9561d
2 changed files with 8 additions and 2 deletions

View File

@ -1322,6 +1322,7 @@ function subscribeToFeed() {
break; break;
case 2: case 2:
case 3: case 3:
case 4:
alert(__("Can't subscribe to the specified URL.")); alert(__("Can't subscribe to the specified URL."));
break; break;
case 0: case 0:

View File

@ -2990,7 +2990,10 @@
* 0 - OK, Feed already exists * 0 - OK, Feed already exists
* 1 - OK, Feed added * 1 - OK, Feed added
* 2 - Invalid URL * 2 - Invalid URL
* 3 - URL content is HTML, not a feed * 3 - URL content is HTML, no feeds available
* 4 - URL content is HTML which contains multiple feeds.
* Here you should call extractfeedurls in rpc-backend
* to get all possible feeds.
*/ */
function subscribe_to_feed($link, $url, $cat_id = 0, function subscribe_to_feed($link, $url, $cat_id = 0,
$auth_login = '', $auth_pass = '') { $auth_login = '', $auth_pass = '') {
@ -3000,8 +3003,10 @@
if (url_is_html($url)) { if (url_is_html($url)) {
$feedUrls = get_feeds_from_html($url); $feedUrls = get_feeds_from_html($url);
if (count($feedUrls) != 1) { if (count($feedUrls) == 0) {
return 3; return 3;
} else if (count($feedUrls) > 1) {
return 4;
} }
//use feed url as new URL //use feed url as new URL
$url = key($feedUrls); $url = key($feedUrls);