From e6436444db9e1bcc13c02c132f327e80d6584df0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 10 Apr 2013 20:55:12 +0200 Subject: Fix bug #49 : les flux sans auteur sont traités normalement désormais MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/Category.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/models/Category.php') diff --git a/app/models/Category.php b/app/models/Category.php index d7db8ee65..a153b8838 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -77,6 +77,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -94,6 +96,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -107,6 +111,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -124,6 +130,8 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -140,6 +148,8 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } -- cgit v1.2.3 From 61943f1661383bf8017b4c2a76fd11618e4adae0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 11 Apr 2013 20:32:10 +0200 Subject: Plus possible d'ajouter un flux déjà existant + meilleure gestion actualisation / import OPML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 60 +++++++++++++++++++++++--------------- app/models/Category.php | 4 --- app/models/Entry.php | 2 -- app/models/Feed.php | 18 ++++++++++-- 4 files changed, 52 insertions(+), 32 deletions(-) (limited to 'app/models/Category.php') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 3fbb20835..d2a2f29f5 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -34,7 +34,13 @@ class feedController extends ActionController { 'lastUpdate' => time () ); - if ($feedDAO->addFeed ($values)) { + if ($feedDAO->searchByUrl ($values['url'])) { + $notif = array ( + 'type' => 'bad', + 'content' => 'Vous êtes déjà abonné à ' . $feed->name () . '' + ); + Session::_param ('notification', $notif); + } elseif ($feedDAO->addFeed ($values)) { $entryDAO = new EntryDAO (); $entries = $feed->entries (); @@ -101,19 +107,19 @@ class feedController extends ActionController { foreach ($feeds as $feed) { try { $feed->load (); - } catch (FeedException $e) { - Log::record ($e->getMessage (), Log::ERROR); - } - $entries = $feed->entries (); + $entries = $feed->entries (); - foreach ($entries as $entry) { - if ($entry->date (true) >= $date_min) { - $values = $entry->toArray (); - $entryDAO->addEntry ($values); + foreach ($entries as $entry) { + if ($entry->date (true) >= $date_min) { + $values = $entry->toArray (); + $entryDAO->addEntry ($values); + } } - } - $feedDAO->updateLastUpdate ($feed->id ()); + $feedDAO->updateLastUpdate ($feed->id ()); + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + } $i++; if ($i >= 10) { @@ -153,20 +159,26 @@ class feedController extends ActionController { $i = 0; foreach ($feeds as $feed) { - $feed->load (); + try { + $feed->load (); - // Enregistrement du flux - $values = array ( - 'id' => $feed->id (), - 'url' => $feed->url (), - 'category' => $feed->category (), - 'name' => $feed->name (), - 'website' => $feed->website (), - 'description' => $feed->description (), - 'lastUpdate' => 0 - ); + // Enregistrement du flux + $values = array ( + 'id' => $feed->id (), + 'url' => $feed->url (), + 'category' => $feed->category (), + 'name' => $feed->name (), + 'website' => $feed->website (), + 'description' => $feed->description (), + 'lastUpdate' => 0 + ); - $feedDAO->addFeed ($values); + if (!$feedDAO->searchByUrl ($values['url'])) { + $feedDAO->addFeed ($values); + } + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + } } Request::forward (array ( @@ -203,7 +215,7 @@ class feedController extends ActionController { $catDAO = new CategoryDAO (); foreach ($categories as $cat) { - if (!$catDAO->searchByName ()) { + if (!$catDAO->searchByName ($cat->name ())) { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), diff --git a/app/models/Category.php b/app/models/Category.php index a153b8838..ae803591f 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -130,8 +130,6 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -148,8 +146,6 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } diff --git a/app/models/Entry.php b/app/models/Entry.php index 4c672bcf3..c8d05c5eb 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -372,8 +372,6 @@ class EntryDAO extends Model_pdo { if (isset ($entry[0])) { return $entry[0]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } diff --git a/app/models/Feed.php b/app/models/Feed.php index 056cbf626..2e6782921 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -287,8 +287,22 @@ class FeedDAO extends Model_pdo { if (isset ($feed[$id])) { return $feed[$id]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function searchByUrl ($url) { + $sql = 'SELECT * FROM feed WHERE url=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($url); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $feed = current (HelperFeed::daoToFeed ($res)); + + if (isset ($feed)) { + return $feed; + } else { return false; } } -- cgit v1.2.3 From 392672ab2771c6d22f55017c4ed64a0e00945b23 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 17 Apr 2013 19:05:53 +0200 Subject: Fix issue #58 : possibilité de vider une catégorie MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 1 + app/controllers/feedController.php | 38 +++++++++++++++++++++++++++------ app/models/Category.php | 14 ++++++++++++ app/models/Feed.php | 14 ++++++++++++ app/views/configure/categorize.phtml | 11 +++++++--- 5 files changed, 68 insertions(+), 10 deletions(-) (limited to 'app/models/Category.php') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 428768b9b..9f4a8b24a 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -56,6 +56,7 @@ class configureController extends ActionController { } $this->view->categories = $catDAO->listCategories (); + $this->view->defaultCategory = $catDAO->getDefault (); View::prependTitle ('Gestion des catégories - '); } diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index fb0f790fd..7a34430ea 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -228,19 +228,43 @@ class feedController extends ActionController { array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) ); } else { + $type = Request::param ('type', 'feed'); $id = Request::param ('id'); $feedDAO = new FeedDAO (); - $feedDAO->deleteFeed ($id); + if ($type == 'category') { + if ($feedDAO->deleteFeedByCategory ($id)) { + $notif = array ( + 'type' => 'good', + 'content' => 'La catégorie a été vidée' + ); + } else { + $notif = array ( + 'type' => 'bad', + 'content' => 'Un problème est survenu' + ); + } + } else { + if ($feedDAO->deleteFeed ($id)) { + $notif = array ( + 'type' => 'good', + 'content' => 'Le flux a été supprimé' + ); + } else { + $notif = array ( + 'type' => 'bad', + 'content' => 'Un problème est survenu' + ); + } + } - // notif - $notif = array ( - 'type' => 'good', - 'content' => 'Le flux a été supprimé' - ); Session::_param ('notification', $notif); - Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + if ($type == 'category') { + Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); + } else { + Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + } } } diff --git a/app/models/Category.php b/app/models/Category.php index ae803591f..7ce572e71 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -158,6 +158,20 @@ class CategoryDAO extends Model_pdo { return HelperCategory::daoToCategory ($stm->fetchAll (PDO::FETCH_ASSOC)); } + public function getDefault () { + $sql = 'SELECT * FROM category WHERE id="000000"'; + $stm = $this->bd->prepare ($sql); + + $stm->execute (); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $cat = HelperCategory::daoToCategory ($res); + + if (isset ($cat[0])) { + return $cat[0]; + } else { + return false; + } + } public function checkDefault () { $def_cat = $this->searchById ('000000'); diff --git a/app/models/Feed.php b/app/models/Feed.php index 070f044a9..222e22256 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -283,6 +283,20 @@ class FeedDAO extends Model_pdo { return false; } } + public function deleteFeedByCategory ($id) { + $sql = 'DELETE FROM feed WHERE category=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($id); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } public function searchById ($id) { $sql = 'SELECT * FROM feed WHERE id=?'; diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 943dd489e..660ddef20 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -6,13 +6,18 @@
Gestion des catégories - gestion des flux +

Lors de la suppression d'une catégorie, ses flux seront automatiquement classés dans defaultCategory->name (); ?>.

+ categories as $cat) { $i++; ?>
- +
- id () == '000000') { ?> - ne peut pas être supprimé + Vider ? (nbFeed (); ?> flux) + id () == $this->defaultCategory->id ()) { ?> + ne peut pas être supprimée
-- cgit v1.2.3