summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-17 19:24:21 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-17 19:24:21 +0200
commit244026874aba991e7feb37f74a61b192f1bda5ac (patch)
tree9537a1e167a596ad63cf3f3899325c22263ce6a0
parent392672ab2771c6d22f55017c4ed64a0e00945b23 (diff)
Fix issue #61 : amélioration import OPML
-rwxr-xr-xapp/controllers/feedController.php23
-rw-r--r--lib/lib_rss.php6
2 files changed, 24 insertions, 5 deletions
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 7a34430ea..c67609d57 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -190,6 +190,7 @@ class feedController extends ActionController {
$nb_month_old = $this->view->conf->oldEntries ();
$date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+ $error = false;
$i = 0;
foreach ($feeds as $feed) {
try {
@@ -207,17 +208,31 @@ class feedController extends ActionController {
);
if (!$feedDAO->searchByUrl ($values['url'])) {
- $feedDAO->addFeed ($values);
+ if (!$feedDAO->addFeed ($values)) {
+ $error = true;
+ }
}
} catch (FeedException $e) {
+ $error = true;
Log::record ($e->getMessage (), Log::ERROR);
}
}
+ if ($error) {
+ $res = 'Les flux ont été importés mais des erreurs sont survenus';
+ } else {
+ $res = 'Les flux ont été importés';
+ }
+ $notif = array (
+ 'type' => 'good',
+ 'content' => $res
+ );
+ Session::_param ('notification', $notif);
+
Request::forward (array (
- 'c' => 'feed',
- 'a' => 'actualize'
- ));
+ 'c' => 'configure',
+ 'a' => 'importExport'
+ ), true);
}
}
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index b9202755b..81a98590e 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -124,7 +124,11 @@ function opml_import ($xml) {
}
if ($title) {
- $cat = new Category ($title);
+ $catDAO = new CategoryDAO ();
+ $cat = $catDAO->searchByName ($title);
+ if ($cat === false) {
+ $cat = new Category ($title);
+ }
$categories[] = $cat;
$feeds = array_merge ($feeds, getFeedsOutline ($outline, $cat->id ()));