/**
  * Delete a folder
  * // TODO move all feads and folders within to the parent folder
  * @param $id int
  */
 public function delete($id)
 {
     $folder = $this->getFolder($id);
     $this->_db->delete($this->_table, [$this->_db->quoteInto('id=?', $id), $this->_db->quoteInto('userId=?', $this->_userId)]);
     $this->move($id, $folder->getFolder());
     Application_Model_UserFeadRepository::getInstance()->move($id, $folder->getFolder());
 }
示例#2
0
 public function showAction()
 {
     $articleId = $this->getParam('id');
     $feadId = $this->getParam('fead');
     if (is_null($articleId) || is_null($feadId)) {
         $this->redirect('home/notprivileged');
     }
     $this->view->article = Application_Model_ArticleRepository::getInstance()->getArticle($articleId, $feadId);
     if (!is_null($this->view->article)) {
         $this->view->fead = Application_Model_FeadRepository::getInstance()->getFeadsForUser($this->isLoggedin()->getId(), $feadId)[0];
         $meta = Application_Model_UserArticleRepository::getInstance()->getArticleMeta($this->view->article->getId());
         $article = new Application_Model_Entity_UserArticle(['articleId' => $this->view->article->getId(), 'feadId' => $this->view->article->getFeadId(), 'unread' => 0, 'favorite' => 0]);
         $this->view->article->setUnread(0);
         if (is_null($meta)) {
             Application_Model_UserArticleRepository::getInstance()->add($article);
             Application_Model_UserFeadRepository::getInstance()->clickIncrease($feadId);
         } else {
             $this->view->article->setFavorite($meta->isFavorite());
             $article->setFavorite($meta->isFavorite());
             if ($meta->isUnread()) {
                 Application_Model_UserFeadRepository::getInstance()->clickIncrease($feadId);
             }
             Application_Model_UserArticleRepository::getInstance()->update($article);
         }
     } else {
         $this->redirect('home/notprivileged');
     }
 }
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
         self::$_instance->_table = 'user_fead';
     }
     return self::$_instance;
 }
示例#4
0
 public function addFead(Application_Model_Entity_Fead $fead)
 {
     $id = $this->urlExists($fead->getUrl());
     if (!$id) {
         $this->_db->insert($this->_table, ['title' => $fead->getTitle(), 'url' => $fead->getUrl()]);
         $id = $this->_db->lastInsertId($this->_table);
         Application_Service_Fead::getInstance()->updateFead($fead->getUrl(), $id);
     }
     Application_Model_UserFeadRepository::getInstance()->add($id);
     return $id;
 }
示例#5
0
 public function updateAction()
 {
     $this->_helper->layout()->disableLayout();
     $struct = json_decode($this->getParam('struct'));
     Application_Model_UserFeadRepository::getInstance()->reorder($struct);
 }