diff options
| author | 2013-04-28 14:18:34 +0200 | |
|---|---|---|
| committer | 2013-04-28 14:18:34 +0200 | |
| commit | 1bee8ad9a7c02c0f53d1f334467cb6d1e5044511 (patch) | |
| tree | 2d983bea4e2a0f654ede6b74251cf9e83ec0fd39 /app | |
| parent | 57f657c04b89c54e6a6b3995a715acfc84a664a7 (diff) | |
Flux déplacés de catégories lors de la suppression de la leur (issue #28)
Diffstat (limited to 'app')
| -rwxr-xr-x | app/controllers/configureController.php | 6 | ||||
| -rw-r--r-- | app/models/Feed.php | 24 | ||||
| -rw-r--r-- | app/views/configure/feed.phtml | 2 |
3 files changed, 30 insertions, 2 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index f4d1a38e7..d6d210099 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -11,8 +11,11 @@ class configureController extends ActionController { } public function categorizeAction () { + $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); $catDAO->checkDefault (); + $defaultCategory = $catDAO->getDefault (); + $defaultId = $defaultCategory->id (); if (Request::isPost ()) { $cats = Request::param ('categories', array ()); @@ -27,7 +30,8 @@ class configureController extends ActionController { 'color' => $cat->color () ); $catDAO->updateCategory ($ids[$key], $values); - } elseif ($ids[$key] != '000000') { + } elseif ($ids[$key] != $defaultId) { + $feedDAO->changeCategory ($ids[$key], $defaultId); $catDAO->deleteCategory ($ids[$key]); } } diff --git a/app/models/Feed.php b/app/models/Feed.php index 97cbe55d1..e519a91cb 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -296,6 +296,30 @@ class FeedDAO extends Model_pdo { } } + public function changeCategory ($idOldCat, $idNewCat) { + $catDAO = new CategoryDAO (); + $newCat = $catDAO->searchById ($idNewCat); + if (!$newCat) { + $newCat = $catDAO->getDefault (); + } + + $sql = 'UPDATE feed SET category=? WHERE category=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $newCat->id (), + $idOldCat + ); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function deleteFeed ($id) { $sql = 'DELETE FROM feed WHERE id=?'; $stm = $this->bd->prepare ($sql); diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 0d9c5cae6..33483f72d 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -2,7 +2,7 @@ <?php if ($this->flux) { ?> <div class="post"> - <a href="<?php echo _url ('index', 'index'); ?>"><?php echo Translate::t ('back_to_rss_feeds'); ?></a> + <a href="<?php echo _url ('index', 'index'); ?>"><?php echo Translate::t ('back_to_rss_feeds'); ?></a> <?php echo Translate::t ('or'); ?> <a href="<?php echo _url ('index', 'index', 'get', 'f_' . $this->flux->id ()); ?>"><?php echo Translate::t ('filter'); ?></a> <h1><?php echo $this->flux->name (); ?></h1> <?php echo $this->flux->description (); ?> |
