summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-08-16 20:26:06 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-08-16 20:26:06 +0200
commitf61df85fe634c7f5662965bb46124af2ecd50419 (patch)
tree2e18a4dfe55b5f4e873edf453e10ee08b5f4cd71 /lib
parented32ef2d967a8379cb1b350dcae5abb4039ec416 (diff)
made starred items and all items work!
Diffstat (limited to 'lib')
-rw-r--r--lib/itemmapper.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/itemmapper.php b/lib/itemmapper.php
index dcce2a640..03dc1c764 100644
--- a/lib/itemmapper.php
+++ b/lib/itemmapper.php
@@ -64,6 +64,7 @@ class ItemMapper {
return $items;
}
+
/**
* @brief Retrieve all the items corresponding to a feed from the database with a particular status
* @param feedid The id of the feed in the database table.
@@ -72,7 +73,8 @@ class ItemMapper {
public function findAllStatus($feedid, $status){
$stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . '
WHERE feed_id = ?
- AND (status & ?)');
+ AND (status & ?)
+ ORDER BY pub_date DESC');
$result = $stmt->execute(array($feedid, $status));
$items = array();
@@ -84,6 +86,29 @@ class ItemMapper {
return $items;
}
+ /*
+ * @brief Retrieve all the items corresponding to a feed from the database with a particular status
+ * @param feedid The id of the feed in the database table.
+ * @param status one of the constants defined in OCA\News\StatusFlag
+ */
+ public function findEveryItemByStatus($status){
+ $stmt = \OCP\DB::prepare('SELECT ' . self::tableName . '.* FROM ' . self::tableName . '
+ JOIN '. FeedMapper::tableName .' ON
+ '. FeedMapper::tableName .'.id = ' . self::tableName . '.feed_id
+ WHERE '. FeedMapper::tableName .'.user_id = ?
+ AND (' . self::tableName . '.status & ?)
+ ORDER BY ' . self::tableName . '.pub_date DESC');
+ $result = $stmt->execute(array($this->userid, $status));
+
+ $items = array();
+ while ($row = $result->fetchRow()) {
+ $item = $this->fromRow($row);
+ $items[] = $item;
+ }
+
+ return $items;
+ }
+
public function countAllStatus($feedid, $status){
$stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . '
WHERE feed_id = ?
@@ -92,6 +117,16 @@ class ItemMapper {
return $result['size'];
}
+ public function countEveryItemByStatus($status){
+ $stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . '
+ JOIN '. FeedMapper::tableName .' ON
+ '. FeedMapper::tableName .'.id = ' . self::tableName . '.feed_id
+ WHERE '. FeedMapper::tableName .'.user_id = ?
+ AND (' . self::tableName . '.status & ?)');
+ $result = $stmt->execute(array($this->userid, $status))->fetchRow();;
+
+ return $result['size'];
+ }
public function findIdFromGuid($guid_hash, $guid, $feedid){
$stmt = \OCP\DB::prepare('