summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/foldermapper.php1
-rw-r--r--lib/itemmapper.php40
2 files changed, 40 insertions, 1 deletions
diff --git a/lib/foldermapper.php b/lib/foldermapper.php
index 54ed1e8aa..abc89b5af 100644
--- a/lib/foldermapper.php
+++ b/lib/foldermapper.php
@@ -28,6 +28,7 @@ class FolderMapper {
$this->userid = \OCP\USER::getUser();
}
+
/**
* @brief Returns the forest (list of trees) of folders children of $parentid
* @param
diff --git a/lib/itemmapper.php b/lib/itemmapper.php
index dcce2a640..661e3cf7a 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,28 @@ class ItemMapper {
return $items;
}
+ /*
+ * @brief Retrieve all the items from the database with a particular status
+ * @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 +116,20 @@ class ItemMapper {
return $result['size'];
}
+ /**
+ * @brief Count all the items from the database with a particular status
+ * @param status one of the constants defined in OCA\News\StatusFlag
+ */
+ 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('