Exemplo n.º 1
0
 public function categorizeAction()
 {
     $feedDAO = new FreshRSS_FeedDAO();
     $catDAO = new FreshRSS_CategoryDAO();
     $defaultCategory = $catDAO->getDefault();
     $defaultId = $defaultCategory->id();
     if (Minz_Request::isPost()) {
         $cats = Minz_Request::param('categories', array());
         $ids = Minz_Request::param('ids', array());
         $newCat = trim(Minz_Request::param('new_category', ''));
         foreach ($cats as $key => $name) {
             if (strlen($name) > 0) {
                 $cat = new FreshRSS_Category($name);
                 $values = array('name' => $cat->name());
                 $catDAO->updateCategory($ids[$key], $values);
             } elseif ($ids[$key] != $defaultId) {
                 $feedDAO->changeCategory($ids[$key], $defaultId);
                 $catDAO->deleteCategory($ids[$key]);
             }
         }
         if ($newCat != '') {
             $cat = new FreshRSS_Category($newCat);
             $values = array('id' => $cat->id(), 'name' => $cat->name());
             if ($catDAO->searchByName($newCat) == false) {
                 $catDAO->addCategory($values);
             }
         }
         invalidateHttpCache();
         $notif = array('type' => 'good', 'content' => Minz_Translate::t('categories_updated'));
         Minz_Session::_param('notification', $notif);
         Minz_Request::forward(array('c' => 'configure', 'a' => 'categorize'), true);
     }
     $this->view->categories = $catDAO->listCategories(false);
     $this->view->defaultCategory = $catDAO->getDefault();
     $this->view->feeds = $feedDAO->listFeeds();
     $this->view->flux = false;
     Minz_View::prependTitle(Minz_Translate::t('categories_management') . ' · ');
 }
Exemplo n.º 2
0
 /**
  * This action updates the given category.
  *
  * Request parameters are:
  *   - id
  *   - name
  */
 public function updateAction()
 {
     $catDAO = new FreshRSS_CategoryDAO();
     $url_redirect = array('c' => 'subscription', 'a' => 'index');
     if (Minz_Request::isPost()) {
         invalidateHttpCache();
         $id = Minz_Request::param('id');
         $name = Minz_Request::param('name', '');
         if (strlen($name) <= 0) {
             Minz_Request::bad(_t('feedback.sub.category.no_name'), $url_redirect);
         }
         if ($catDAO->searchById($id) == null) {
             Minz_Request::bad(_t('feedback.sub.category.not_exist'), $url_redirect);
         }
         $cat = new FreshRSS_Category($name);
         $values = array('name' => $cat->name());
         if ($catDAO->updateCategory($id, $values)) {
             Minz_Request::good(_t('feedback.sub.category.updated'), $url_redirect);
         } else {
             Minz_Request::bad(_t('feedback.sub.category.error'), $url_redirect);
         }
     }
     Minz_Request::forward($url_redirect, true);
 }