summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-08-15 09:51:12 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-08-15 09:51:12 -0400
commit04497e9e68516537244c359a06f29aa6b2afce08 (patch)
treeca50fbcf31f672fbe21848ddb43e733fe9c83bb6 /lib
parent51bf7344a712d0ce140020e75099b11a8d007639 (diff)
shows counter when adding feed; fixes bug when removing folder
Diffstat (limited to 'lib')
-rw-r--r--lib/item.php22
-rw-r--r--lib/itemmapper.php17
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('