miniflux-legacy/app/models/bookmark.php

71 lines
1.9 KiB
PHP
Raw Normal View History

2016-08-19 03:44:36 +02:00
<?php
2016-08-25 03:17:58 +02:00
namespace Miniflux\Model\Bookmark;
2016-08-19 03:44:36 +02:00
use Miniflux\Helper;
use Miniflux\Model;
2016-08-19 03:44:36 +02:00
use PicoDb\Database;
function count_bookmarked_items($user_id, array $feed_ids = array())
2016-08-19 03:44:36 +02:00
{
return Database::getInstance('db')
->table(Model\Item\TABLE)
2016-08-19 03:44:36 +02:00
->eq('bookmark', 1)
->eq('user_id', $user_id)
2016-08-19 03:44:36 +02:00
->in('feed_id', $feed_ids)
->in('status', array(Model\Item\STATUS_READ, Model\Item\STATUS_UNREAD))
2016-08-19 03:44:36 +02:00
->count();
}
function get_bookmarked_items($user_id, $offset = null, $limit = null, array $feed_ids = array())
2016-08-19 03:44:36 +02:00
{
return Database::getInstance('db')
->table(Model\Item\TABLE)
2016-08-19 03:44:36 +02:00
->columns(
'items.id',
'items.checksum',
2016-08-19 03:44:36 +02:00
'items.title',
'items.updated',
'items.url',
'items.enclosure_url',
2016-08-19 03:44:36 +02:00
'items.enclosure_type',
'items.bookmark',
'items.status',
'items.content',
'items.feed_id',
'items.language',
'items.rtl',
2016-08-19 03:44:36 +02:00
'items.author',
'feeds.site_url',
'feeds.title AS feed_title'
2016-08-19 03:44:36 +02:00
)
->join(Model\Feed\TABLE, 'id', 'feed_id')
->eq('items.user_id', $user_id)
->in('items.feed_id', $feed_ids)
->neq('items.status', Model\Item\STATUS_REMOVED)
->eq('items.bookmark', 1)
->orderBy('items.updated', Helper\config('items_sorting_direction'))
2016-08-19 03:44:36 +02:00
->offset($offset)
->limit($limit)
->findAll();
}
function get_bookmarked_item_ids($user_id)
2016-08-19 03:44:36 +02:00
{
return Database::getInstance('db')
->table(Model\Item\TABLE)
->eq('user_id', $user_id)
->eq('bookmark', 1)
2016-12-30 00:04:56 +01:00
->asc('id')
->findAllByColumn('id');
}
2016-08-19 03:44:36 +02:00
function set_flag($user_id, $item_id, $value)
{
2016-08-19 03:44:36 +02:00
return Database::getInstance('db')
->table(Model\Item\TABLE)
->eq('user_id', $user_id)
->eq('id', $item_id)
->update(array('bookmark' => (int) $value));
2016-08-19 03:44:36 +02:00
}