diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/item.php | 22 | ||||
-rw-r--r-- | lib/itemmapper.php | 17 |
2 files changed, 28 insertions, 11 deletions
diff --git a/lib/item.php b/lib/item.php index 3e9b3f5b7..acef41c92 100644 --- a/lib/item.php +++ b/lib/item.php @@ -13,10 +13,10 @@ namespace OCA\News; class StatusFlag{ - const Unread = 0x02; - const Important = 0x04; - const Deleted = 0x08; - const Updated = 0x16; + const UNREAD = 0x02; + const IMPORTANT = 0x04; + const DELETED = 0x08; + const UPDATED = 0x16; } /** @@ -40,7 +40,7 @@ class Item { $this->guid = $guid; $this->body = $body; if ($id == null) { - $this->status |= StatusFlag::Unread; + $this->status |= StatusFlag::UNREAD; } else { $this->id = $id; @@ -64,27 +64,27 @@ class Item { } public function setRead(){ - $this->status &= ~StatusFlag::Unread; + $this->status &= ~StatusFlag::UNREAD; } public function setUnread(){ - $this->status |= StatusFlag::Unread; + $this->status |= StatusFlag::UNREAD; } public function isRead(){ - return !($this->status & StatusFlag::Unread); + return !($this->status & StatusFlag::UNREAD); } public function setImportant(){ - $this->status |= StatusFlag::Important; + $this->status |= StatusFlag::IMPORTANT; } public function setUnimportant(){ - $this->status &= ~StatusFlag::Important; + $this->status &= ~StatusFlag::IMPORTANT; } public function isImportant(){ - return ($this->status & StatusFlag::Important); + return ($this->status & StatusFlag::IMPORTANT); } /** diff --git a/lib/itemmapper.php b/lib/itemmapper.php index 35060f0a4..95488b14f 100644 --- a/lib/itemmapper.php +++ b/lib/itemmapper.php @@ -19,6 +19,14 @@ namespace OCA\News; class ItemMapper { const tableName = '*PREFIX*news_items'; + private $userid; + + public function __construct($userid = null){ + if ($userid !== null) { + $this->userid = $userid; + } + $this->userid = \OCP\USER::getUser(); + } /** * @brief @@ -77,6 +85,15 @@ class ItemMapper { return $items; } + + public function countAllStatus($feedid, $status){ + $stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . ' + WHERE feed_id = ? + AND (status & ?)'); + $result=$stmt->execute(array($feedid, $status))->fetchRow(); + return $result['size']; + } + public function findIdFromGuid($guid_hash, $guid, $feedid){ $stmt = \OCP\DB::prepare(' |