summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bl/feedbl.php1
-rw-r--r--controller/itemcontroller.php2
-rw-r--r--db/feed.php7
-rw-r--r--db/feedmapper.php37
-rw-r--r--db/folder.php5
-rw-r--r--db/item.php9
-rw-r--r--db/itemmapper.php6
-rw-r--r--js/app/controllers/feedcontroller.coffee39
-rw-r--r--js/app/directives/addfolderselect.coffee42
-rw-r--r--js/app/services/models/feedmodel.coffee5
-rw-r--r--js/public/app.js100
-rw-r--r--js/tests/controllers/feedcontrollerSpec.coffee28
-rw-r--r--js/tests/services/models/feedmodelSpec.coffee2
-rw-r--r--templates/part.addnew.php15
-rw-r--r--templates/part.items.php8
-rw-r--r--templates/part.listfeed.php7
-rw-r--r--templates/part.listfolder.php4
-rw-r--r--templates/part.showall.php4
-rw-r--r--tests/db/FeedMapperTest.php100
-rw-r--r--tests/db/ItemMapperTest.php6
-rw-r--r--utility/feedfetcher.php43
21 files changed, 308 insertions, 162 deletions
diff --git a/bl/feedbl.php b/bl/feedbl.php
index 5ab4d8953..9af4d6198 100644
--- a/bl/feedbl.php
+++ b/bl/feedbl.php
@@ -79,6 +79,7 @@ class FeedBl extends Bl {
return $feed;
} catch(FetcherException $ex){
+ $this->api->log($ex->getMessage());
throw new BLException('Can not add feed: Not found or bad source');
}
}
diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php
index 44b7f9684..47061a14c 100644
--- a/controller/itemcontroller.php
+++ b/controller/itemcontroller.php
@@ -86,7 +86,7 @@ class ItemController extends Controller {
$starredCount = $this->itemBl->starredCount($userId);
$params = array(
- 'starred' => $starredCount
+ 'starred' => (int) $starredCount
);
return $this->renderJSON($params);
diff --git a/db/feed.php b/db/feed.php
index da2a2d904..f337448a4 100644
--- a/db/feed.php
+++ b/db/feed.php
@@ -39,4 +39,11 @@ class Feed extends Entity {
public $folderId;
public $unreadCount;
+ public function __construct(){
+ $this->addType('parentId', 'int');
+ $this->addType('added', 'int');
+ $this->addType('folderId', 'int');
+ $this->addType('unreadCount', 'int');
+ }
+
} \ No newline at end of file
diff --git a/db/feedmapper.php b/db/feedmapper.php
index 05fa729b4..d84cebad1 100644
--- a/db/feedmapper.php
+++ b/db/feedmapper.php
@@ -39,11 +39,17 @@ class FeedMapper extends Mapper implements IMapper {
public function find($id, $userId){
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `id` = ? ' .
- 'AND `user_id` = ?';
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`id` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $params = array(StatusFlag::UNREAD, $id, $userId);
- $row = $this->findOneQuery($sql, array($id, $userId));
+ $row = $this->findOneQuery($sql, $params);
$feed = new Feed();
$feed->fromRow($row);
@@ -68,12 +74,12 @@ class FeedMapper extends Mapper implements IMapper {
public function findAllFromUser($userId){
$sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
'FROM `*PREFIX*news_feeds` `feeds` ' .
- 'LEFT OUTER JOIN `*PREFIX*news_items` `items` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'WHERE (`items`.`status` & ?) > 0 ' .
- 'AND `feeds`.`user_id` = ? ' .
- 'GROUP BY `items`.`feed_id`';
- $params = array($userId);
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $params = array(StatusFlag::UNREAD, $userId);
return $this->findAllRows($sql, $params);
}
@@ -87,10 +93,15 @@ class FeedMapper extends Mapper implements IMapper {
public function findByUrlHash($hash, $userId){
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `url_hash` = ? ' .
- 'AND `user_id` = ?';
- $params = array($hash, $userId);
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`url_hash` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $params = array(StatusFlag::UNREAD, $hash, $userId);
$row = $this->findOneQuery($sql, $params);
$feed = new Feed();
diff --git a/db/folder.php b/db/folder.php
index aa5cf66a9..adc4a8572 100644
--- a/db/folder.php
+++ b/db/folder.php
@@ -35,4 +35,9 @@ class Folder extends Entity {
public $userId;
public $opened;
+ public function __construct(){
+ $this->addType('parentId', 'int');
+ $this->addType('opened', 'bool');
+ }
+
} \ No newline at end of file
diff --git a/db/item.php b/db/item.php
index 6050d0e9b..4a3bd9733 100644
--- a/db/item.php
+++ b/db/item.php
@@ -44,6 +44,15 @@ class Item extends Entity {
public $feedTitle;
public $lastModified;
+
+ public function __construct(){
+ $this->addType('pubDate', 'int');
+ $this->addType('feedId', 'int');
+ $this->addType('status', 'int');
+ $this->addType('lastModified', 'int');
+ }
+
+
public function setRead() {
$this->markFieldUpdated('status');
$this->status &= ~StatusFlag::UNREAD;
diff --git a/db/itemmapper.php b/db/itemmapper.php
index d54bbade1..0208472b3 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -107,7 +107,7 @@ class ItemMapper extends Mapper implements IMapper {
public function findAllNewFeed($id, $updatedSince, $status, $userId){
$sql = 'AND `items`.`feed_id` = ? ' .
- 'AND `items`.`lastmodified` >= ?';
+ 'AND `items`.`last_modified` >= ?';
$sql = $this->makeSelectQueryStatus($sql);
$params = array($userId, $status, $id, $updatedSince);
return $this->findAllRows($sql, $params);
@@ -116,7 +116,7 @@ class ItemMapper extends Mapper implements IMapper {
public function findAllNewFolder($id, $updatedSince, $status, $userId){
$sql = 'AND `feeds`.`folder_id` = ? ' .
- 'AND `items`.`lastmodified` >= ?';
+ 'AND `items`.`last_modified` >= ?';
$sql = $this->makeSelectQueryStatus($sql);
$params = array($userId, $status, $id, $updatedSince);
return $this->findAllRows($sql, $params);
@@ -124,7 +124,7 @@ class ItemMapper extends Mapper implements IMapper {
public function findAllNew($updatedSince, $status, $userId){
- $sql = $this->makeSelectQueryStatus('AND `items`.`lastmodified` >= ?');
+ $sql = $this->makeSelectQueryStatus('AND `items`.`last_modified` >= ?');
$params = array($userId, $status, $updatedSince);
return $this->findAllRows($sql, $params);
}
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
index 7a61f4ab1..a8be616d9 100644
--- a/js/app/controllers/feedcontroller.coffee
+++ b/js/app/controllers/feedcontroller.coffee
@@ -78,29 +78,27 @@ angular.module('News').factory '_FeedController', ->
@$scope.addFeed = (feedUrl, parentFolderId=0) =>
@$scope.feedEmptyError = false
- @$scope.feedExistsError = false
@$scope.feedError = false
if angular.isUndefined(feedUrl) or feedUrl.trim() == ''
@$scope.feedEmptyError = true
- else
- feedUrl = feedUrl.trim()
- for feed in @_feedModel.getAll()
- if feedUrl == feed.url
- @$scope.feedExistsError = true
-
- if not (@$scope.feedEmptyError or @$scope.feedExistsError)
+ if not @$scope.feedEmptyError
@_isAddingFeed = true
- onSuccess = =>
- @$scope.feedUrl = ''
- @_isAddingFeed = false
onError = =>
@$scope.feedError = true
@_isAddingFeed = false
- @_persistence.createFeed(feedUrl, parentFolderId, onSuccess,
- onError)
+
+ onSuccess = (data) =>
+ if data.status == 'error'
+ onError()
+ else
+ @$scope.feedUrl = ''
+ @_isAddingFeed = false
+
+ @_persistence.createFeed(feedUrl.trim(), parentFolderId,
+ onSuccess, onError)
@$scope.addFolder = (folderName) =>
@$scope.folderEmptyError = false
@@ -137,11 +135,20 @@ angular.module('News').factory '_FeedController', ->
isShown: (type, id) ->
- if @isShowAll()
+ hasUnread = @getUnreadCount(type, id) > 0
+ if hasUnread
return true
else
- return @getUnreadCount(type, id) > 0
-
+ if @isShowAll()
+ switch type
+ when @_feedType.Subscriptions
+ return @_feedModel.size() > 0
+ when @_feedType.Folder
+ return @_folderModel.size() > 0
+ when @_feedType.Feed
+ return @_feedModel.size() > 0
+ return false
+
isShowAll: ->
return @_showAll.getShowAll()
diff --git a/js/app/directives/addfolderselect.coffee b/js/app/directives/addfolderselect.coffee
new file mode 100644
index 000000000..1c3f39f04
--- /dev/null
+++ b/js/app/directives/addfolderselect.coffee
@@ -0,0 +1,42 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+###
+
+
+###
+Turns a normal select into a folder select with the ability to create new
+folders
+###
+angular.module('News').directive 'addFolderSelect', ['$rootScope', ->
+
+ return (scope, elm, attr) ->
+
+ options =
+ singleSelect: true
+ selectedFirst: true
+ createText: $(elm).data('create')
+ createdCallback: (selected, value) ->
+ console.log selected
+ console.log value
+
+ $(elm).multiSelect(options)
+
+] \ No newline at end of file
diff --git a/js/app/services/models/feedmodel.coffee b/js/app/services/models/feedmodel.coffee
index def720edf..046ac7ec2 100644
--- a/js/app/services/models/feedmodel.coffee
+++ b/js/app/services/models/feedmodel.coffee
@@ -32,8 +32,9 @@ angular.module('News').factory '_FeedModel',
add: (item) ->
- if item.icon == 'url()'
- item.icon = 'url(' + @_utils.imagePath('news', 'rss.svg') + ')'
+ if item.faviconLink == null
+ item.faviconLink = 'url(' +
+ @_utils.imagePath('news', 'rss.svg') + ')'
super(item)
diff --git a/js/public/app.js b/js/public/app.js
index e720ed428..505eb558c 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -88,6 +88,58 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+/*
+Turns a normal select into a folder select with the ability to create new
+folders
+*/
+
+
+(function() {
+
+ angular.module('News').directive('addFolderSelect', [
+ '$rootScope', function() {
+ return function(scope, elm, attr) {
+ var options;
+ options = {
+ singleSelect: true,
+ selectedFirst: true,
+ createText: $(elm).data('create'),
+ createdCallback: function(selected, value) {
+ console.log(selected);
+ return console.log(value);
+ }
+ };
+ return $(elm).multiSelect(options);
+ };
+ }
+ ]);
+
+}).call(this);
+
+// Generated by CoffeeScript 1.4.0
+
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
(function() {
angular.module('News').controller('SettingsController', [
@@ -196,36 +248,30 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return _this.toggleFolder(folderId);
};
this.$scope.addFeed = function(feedUrl, parentFolderId) {
- var feed, onError, onSuccess, _i, _len, _ref;
+ var onError, onSuccess;
if (parentFolderId == null) {
parentFolderId = 0;
}
_this.$scope.feedEmptyError = false;
- _this.$scope.feedExistsError = false;
_this.$scope.feedError = false;
if (angular.isUndefined(feedUrl) || feedUrl.trim() === '') {
_this.$scope.feedEmptyError = true;
- } else {
- feedUrl = feedUrl.trim();
- _ref = _this._feedModel.getAll();
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- feed = _ref[_i];
- if (feedUrl === feed.url) {
- _this.$scope.feedExistsError = true;
- }
- }
}
- if (!(_this.$scope.feedEmptyError || _this.$scope.feedExistsError)) {
+ if (!_this.$scope.feedEmptyError) {
_this._isAddingFeed = true;
- onSuccess = function() {
- _this.$scope.feedUrl = '';
- return _this._isAddingFeed = false;
- };
onError = function() {
_this.$scope.feedError = true;
return _this._isAddingFeed = false;
};
- return _this._persistence.createFeed(feedUrl, parentFolderId, onSuccess, onError);
+ onSuccess = function(data) {
+ if (data.status === 'error') {
+ return onError();
+ } else {
+ _this.$scope.feedUrl = '';
+ return _this._isAddingFeed = false;
+ }
+ };
+ return _this._persistence.createFeed(feedUrl.trim(), parentFolderId, onSuccess, onError);
}
};
this.$scope.addFolder = function(folderName) {
@@ -272,11 +318,23 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
};
FeedController.prototype.isShown = function(type, id) {
- if (this.isShowAll()) {
+ var hasUnread;
+ hasUnread = this.getUnreadCount(type, id) > 0;
+ if (hasUnread) {
return true;
} else {
- return this.getUnreadCount(type, id) > 0;
+ if (this.isShowAll()) {
+ switch (type) {
+ case this._feedType.Subscriptions:
+ return this._feedModel.size() > 0;
+ case this._feedType.Folder:
+ return this._folderModel.size() > 0;
+ case this._feedType.Feed:
+ return this._feedModel.size() > 0;
+ }
+ }
}
+ return false;
};
FeedController.prototype.isShowAll = function() {
@@ -616,8 +674,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}
FeedModel.prototype.add = function(item) {
- if (item.icon === 'url()') {
- item.icon = 'url(' + this._utils.imagePath('news', 'rss.svg') + ')';
+ if (item.faviconLink === null) {
+ item.faviconLink = 'url(' + this._utils.imagePath('news', 'rss.svg') + ')';
}
return FeedModel.__super__.add.call(this, item);
};
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee
index af4c8f9a7..8ef621030 100644
--- a/js/tests/controllers/feedcontrollerSpec.coffee
+++ b/js/tests/controllers/feedcontrollerSpec.coffee
@@ -171,7 +171,8 @@ describe '_FeedController', ->
expect(@ActiveFeed.getType()).toBe(4)
- it 'should return true when calling isShown and ShowAll is set to true', =>
+ it 'should return true when calling isShown and there are feeds', =>
+ @FeedModel.add({id: 3})
@ShowAll.setShowAll(true)
expect(@scope.isShown(3, 4)).toBeTruthy()
@@ -340,15 +341,6 @@ describe '_FeedController', ->
expect(@persistence.createFeed).not.toHaveBeenCalled()
- it 'should not add feeds that already exist client side', =>
- @FeedModel.add({id: 3, url: 'ola'})
- @persistence.createFeed = jasmine.createSpy('create')
- @scope.addFeed('ola')
-
- expect(@scope.feedExistsError).toBeTruthy()
- expect(@persistence.createFeed).not.toHaveBeenCalled()
-
-
it 'should set isAddingFeed to true if there were no problems', =>
@persistence.createFeed = jasmine.createSpy('create')
@scope.addFeed('ola')
@@ -358,7 +350,9 @@ describe '_FeedController', ->
it 'should should reset the feedurl and set isAddingFeed to false on succ',=>
@persistence.createFeed =
jasmine.createSpy('create').andCallFake (arg1, arg2, func) =>
- func()
+ data =
+ status: 'success'
+ func(data)
@scope.addFeed(' Ola')
expect(@scope.feedUrl).toBe('')
@@ -375,6 +369,18 @@ describe '_FeedController', ->
expect(@scope.feedError).toBeTruthy()
+ it 'should should set isAddingFeed to false on serverside error',=>
+ @persistence.createFeed =
+ jasmine.createSpy('create').andCallFake (arg1, arg2, func) =>
+ data =
+ status: 'error'
+ func(data)
+ @scope.addFeed('Ola')
+
+ expect(@scope.isAddingFeed()).toBeFalsy()
+ expect(@scope.feedError).toBeTruthy()
+
+
it 'should create a create new feed request if everything was ok', =>
@persistence.createFeed = jasmine.createSpy('create')
@scope.addFeed('Ola')
diff --git a/js/tests/services/models/feedmodelSpec.coffee b/js/tests/services/models/feedmodelSpec.coffee
index 9732d0e82..caddb35c0 100644
--- a/js/tests/services/models/feedmodelSpec.coffee
+++ b/js/tests/services/models/feedmodelSpec.coffee
@@ -36,7 +36,7 @@ describe '_FeedModel', ->
it 'should bind an imagepath to the item if the url is empty', =>
item =
id: 3
- icon: 'url()'
+ faviconLink: null
utils =
imagePath: jasmine.createSpy('utils')
diff --git a/templates/part.addnew.php b/templates/part.addnew.php
index d7d549ad0..9a625e2f3 100644
--- a/templates/part.addnew.php
+++ b/templates/part.addnew.php
@@ -1,5 +1,5 @@
<li class="add-new">
- <a class="list-title list-title-with-icon" ng-click="showAdd=!showAdd"
+ <a class="list-title list-title-with-icon"
oc-click-slide-toggle="{
selector: '.add-new-popup',
hideOnFocusLost: true
@@ -7,29 +7,30 @@
<?php p($l->t('New'))?>
</a>
- <div class="add-new-popup" ng-class="{open:showAdd==true}">
+ <div class="add-new-popup">
<fieldset class="personalblock">
<legend><strong><?php p($l->t('Add Subscription')); ?></strong></legend>
<p class="error">
<span ng-show="feedEmptyError"><?php p($l->t('Address must not be empty!')); ?></span>
- <span ng-show="feedExistsError"><?php p($l->t('Feed exists already!')); ?></span>
- <span ng-show="feedError"><?php p($l->t('Could not add feed! Check if feed contains valid RSS!')); ?></span>
+ <span ng-show="feedError">
+ <?php p($l->t('Could not add feed! Check if feed contains valid RSS or exists already!')); ?>
+ </span>
<span ng-show="folderExistsError"><?php p($l->t('Folder exists already')); ?></span>
</p>
<form>
<input type="text"
ng-model="feedUrl"
placeholder="<?php p($l->t('Address')); ?>"
- ng-disabled="isAddingFeed()">
+ ng-disabled="isAddingFeed() || isAddingFolder()">
<button title="<?php p($l->t('Add')); ?>"
- ng-class="{loading: adding}"
+ ng-class="{loading: isAddingFeed()}"
ng-disabled="adding"
ng-click="addFeed(feedUrl, folderId)"><?php p($l->t('Add')); ?></button>
<select name="folder"
data-create="<?php p($l->t('New folder')); ?>"
title="<?php p($l->t('Folder')); ?>"
ng-model="folderId"
- ng-disabled="adding"
+ ng-disabled="isAddingFolder()"
ng-options="folder.name for folder in getFolders()"
add-folder-select>
<option value="" selected><?php p($l->t('No folder')); ?></option>
diff --git a/templates/part.items.php b/templates/part.items.php
index 8bede824f..9bc3206ca 100644
--- a/templates/part.items.php
+++ b/templates/part.items.php
@@ -43,14 +43,6 @@
<div class="bottom_utils">
<ul class="secondary_item_utils"
ng-class="{show_keep_unread: isKeptUnread(item.id)}">
- <!--<li class="share_link">
- <a class="share" data-item-type="news_item"
- data-item="{{item.id}}" title="<?php p($l->t('Share')) ?>"
- data-possible-permissions="<?php //p((OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE)) ?>"
- href="#">
- <?php p($l->t('Share')) ?>
- </a>
- </li>-->
<li ng-click="keepUnread(item.id, item.feedId)"
class="keep_unread"><?php p($l->t('Keep unread')); ?>
<input type="checkbox" ng-checked="isKeptUnread(item.id)"/>
diff --git a/templates/part.listfeed.php b/templates/part.listfeed.php
index 51b249eb5..a6193afe7 100644
--- a/templates/part.listfeed.php
+++ b/templates/part.listfeed.php
@@ -1,10 +1,13 @@
-<li ng-class="{active: isFeedActive(feedType.Feed, feed.id), unread: feed.unreadCount!=0}"
+<li ng-class="{
+ active: isFeedActive(feedType.Feed, feed.id),
+ unread: feed.unreadCount!=0
+ }"
ng-repeat="feed in getFeedsOfFolder(<?php p($_['folderId']); ?>)"
ng-show="isShown(feedType.Feed, feed.id)"
data-id="{{feed.id}}"
class="feed"
draggable>
- <a ng-style="{backgroundImage: feed.icon}"
+ <a ng-style="{backgroundImage: feed.faviconLink}"
href="#"
class="title"
ng-click="loadFeed(feedType.Feed, feed.id)">
diff --git a/templates/part.listfolder.php b/templates/part.listfolder.php
index 4285ed0ae..e30610d19 100644
--- a/templates/part.listfolder.php
+++ b/templates/part.listfolder.php
@@ -32,10 +32,10 @@
ng-click="markAllRead(feedType.Folder, folder.id)"
title="<?php p($l->t('Mark all read')); ?>"></button>
- <button class="svg action edit-icon"
+<!-- <button class="svg action edit-icon"
ng-click="renameFolder(folder.id)"
title="<?php p($l->t('Rename folder')); ?>"></button>
-
+-->
</span>
<ul>
diff --git a/templates/part.showall.php b/templates/part.showall.php
index 61f9cc11d..6d7473e43 100644
--- a/templates/part.showall.php
+++ b/templates/part.showall.php
@@ -1,7 +1,7 @@
-<li ui-if="!isShowAll()" class="show-all">
+<li ui-if="!isShowAll() && isShown(feedType.Subscributions, 0)" class="show-all">
<a ng-click="setShowAll(true)" href="#"><?php p($l->t('Show all')); ?></a>
</li>
-<li ui-if="isShowAll()" class="show-all">
+<li ui-if="isShowAll() && isShown(feedType.Subscributions, 0)" class="show-all">
<a ng-click="setShowAll(false)" href="#"><?php p($l->t('Show only unread')); ?></a>
</li>
diff --git a/tests/db/FeedMapperTest.php b/tests/db/FeedMapperTest.php
index 27ea769d1..11afbbe7f 100644
--- a/tests/db/FeedMapperTest.php
+++ b/tests/db/FeedMapperTest.php
@@ -56,11 +56,16 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$rows = array(
array('id' => $this->feeds[0]->getId()),
);
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `id` = ? ' .
- 'AND `user_id` = ?';
-
- $this->setMapperResult($sql, array($id, $userId), $rows);
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`id` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $params = array(StatusFlag::UNREAD, $id, $userId);
+ $this->setMapperResult($sql, $params, $rows);
$result = $this->mapper->find($id, $userId);
$this->assertEquals($this->feeds[0], $result);
@@ -71,11 +76,16 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
public function testFindNotFound(){
$userId = 'john';
$id = 3;
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `id` = ? ' .
- 'AND `user_id` = ?';
-
- $this->setMapperResult($sql, array($id, $userId));
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`id` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $params = array(StatusFlag::UNREAD, $id, $userId);
+ $this->setMapperResult($sql, $params);
$this->setExpectedException('\OCA\AppFramework\Db\DoesNotExistException');
$result = $this->mapper->find($id, $userId);
@@ -89,12 +99,17 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
array('id' => $this->feeds[0]->getId()),
array('id' => $this->feeds[1]->getId())
);
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `id` = ? ' .
- 'AND `user_id` = ?';
-
- $this->setMapperResult($sql, array($id, $userId), $rows);
-
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`id` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $params = array(StatusFlag::UNREAD, $id, $userId);
+ $this->setMapperResult($sql, $params, $rows);
+
$this->setExpectedException('\OCA\AppFramework\Db\MultipleObjectsReturnedException');
$result = $this->mapper->find($id, $userId);
}
@@ -123,13 +138,13 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
);
$sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
'FROM `*PREFIX*news_feeds` `feeds` ' .
- 'LEFT OUTER JOIN `*PREFIX*news_items` `items` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'WHERE (`items`.`status` & ?) > 0 ' .
- 'AND `feeds`.`user_id` = ? ' .
- 'GROUP BY `items`.`feed_id`';
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
- $this->setMapperResult($sql, array($userId), $rows);
+ $this->setMapperResult($sql, array(StatusFlag::UNREAD, $userId), $rows);
$result = $this->mapper->findAllFromUser($userId);
$this->assertEquals($this->feeds, $result);
@@ -141,10 +156,15 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$row = array(
array('id' => $this->feeds[0]->getId()),
);
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `url_hash` = ? ' .
- 'AND `user_id` = ?';
- $this->setMapperResult($sql, array($urlHash, $this->user), $row);
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`url_hash` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';
+ $this->setMapperResult($sql, array(StatusFlag::UNREAD, $urlHash, $this->user), $row);
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
$this->assertEquals($this->feeds[0], $result);
@@ -153,12 +173,16 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
public function testFindByUrlHashNotFound(){
$urlHash = md5('hihi');
- $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
- 'WHERE `url_hash` = ? ' .
- 'AND `user_id` = ?';
+ $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' .
+ 'FROM `*PREFIX*news_feeds` `feeds` ' .
+ 'LEFT JOIN `*PREFIX*news_items` `items` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'AND (`items`.`status` & ?) > 0 ' .
+ 'WHERE `feeds`.`url_hash` = ? ' .
+ 'AND `feeds`.`user_id` = ? ' .
+ 'GROUP BY `feeds`.`id`';