コード例 #1
0
 /**
  * item still in database?
  *
  * @return boolean true if item is already in database
  * @param mixed the current item
  */
 protected function itemExists($item)
 {
     $itemsModel = new application_models_items();
     $res = $itemsModel->fetchAll($itemsModel->select()->from($itemsModel, array('amount' => 'Count(*)'))->where('uid="' . $item->getId() . '"'));
     if ($res[0]['amount'] > 0) {
         Zend_Registry::get('logger')->log('item "' . $item->getTitle() . '" already fetched', Zend_Log::DEBUG);
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * validates given item id and returns item row object
  *
  * @return Zend_Db_Table_Row|bool false on error or item row object
  */
 protected function getItem()
 {
     // get id
     $id = $this->getRequest()->getParam('id');
     // search and validate given id
     $itemModel = new application_models_items();
     $item = $itemModel->find($id);
     if ($item->count() == 0) {
         $this->_helper->json(array('error' => $this->view->translate('invalid item id')));
     } else {
         return $item->current();
     }
 }
コード例 #3
0
 /**
  * removes a feed
  *
  * @return array|bool true or error messages
  * @param int id of the feed
  */
 public function remove($id)
 {
     // get feed and category
     $feed = $this->find($id);
     if ($feed->count() == 0) {
         return Zend_Registry::get('language')->translate("feed doesn't exists");
     }
     $feed = $feed->current();
     $category = $feed->category;
     // delete all items
     $itemsModel = new application_models_items();
     $itemsModel->delete('feed=' . $feed->id);
     // delete icon
     $this->deleteIcon($feed);
     // delete messages
     $messagesModel = new application_models_messages();
     $messagesModel->delete('feed=' . $feed->id);
     // delete feed
     $this->delete('id=' . $feed->id);
     // reorder feeds in parent category
     if ($category != 0) {
         $categoryModel = new application_models_categories();
         $categoryModel->fixPositions($categoryModel->find($category)->current());
     }
     // success
     return true;
 }
コード例 #4
0
 /**
  * test remove a feed
  */
 public function testRemove()
 {
     $this->model->remove(3);
     // feed really deleted
     $this->assertEquals(0, $this->model->find(3)->count());
     // all items deleted
     $itemModel = new application_models_items();
     $result = $itemModel->fetchAll($itemModel->select()->where('feed=?', 3));
     $this->assertEquals(0, $result->count());
     // no icon file
     $this->assertFalse(file_exists(Zend_Registry::get('config')->favicons->path . "4711.ico"));
     // no messages
     $messagesModel = new application_models_messages();
     $result = $messagesModel->fetchAll($messagesModel->select()->where('feed=?', 3));
     $this->assertEquals(0, $result->count());
     // check reorder
     $this->assertEquals('0', $this->model->find('1')->current()->position);
     // correct position
     $this->assertEquals('1', $this->model->find('2')->current()->position);
     // correct position
     // validation
     $this->assertTrue($this->model->remove(222) !== true);
 }
コード例 #5
0
 /**
  * returns starred items
  *
  * @return int starred items
  * @param array $settings (optional) current settings
  */
 public function starredItems($settings = null)
 {
     $itemsModel = new application_models_items();
     return $itemsModel->countStarred($this->prepareSettings($settings));
 }