2013-12-23 02:55:53 +01:00
|
|
|
<?php
|
|
|
|
|
2016-08-25 03:17:58 +02:00
|
|
|
namespace Miniflux\Model\Item;
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-08-19 04:33:58 +02:00
|
|
|
use PicoDb\Database;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Model\Group;
|
|
|
|
use Miniflux\Handler;
|
2016-12-26 15:44:53 +01:00
|
|
|
use Miniflux\Helper;
|
|
|
|
use PicoFeed\Parser\Parser;
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
const TABLE = 'items';
|
|
|
|
const STATUS_UNREAD = 'unread';
|
|
|
|
const STATUS_READ = 'read';
|
|
|
|
const STATUS_REMOVED = 'removed';
|
|
|
|
|
|
|
|
function change_item_status($user_id, $item_id, $status)
|
2014-02-15 20:09:50 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
if (! in_array($status, array(STATUS_READ, STATUS_UNREAD, STATUS_REMOVED))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->eq('id', $item_id)
|
2017-01-09 23:57:31 +01:00
|
|
|
->update(array('status' => $status));
|
2014-02-15 20:09:50 +01:00
|
|
|
}
|
|
|
|
|
2017-01-09 23:57:31 +01:00
|
|
|
function change_items_status($user_id, $current_status, $new_status, $before = null)
|
2014-02-15 20:09:50 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
if (! in_array($new_status, array(STATUS_READ, STATUS_UNREAD, STATUS_REMOVED))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-09 23:57:31 +01:00
|
|
|
$query = Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
2017-01-09 23:57:31 +01:00
|
|
|
->eq('status', $current_status);
|
|
|
|
|
|
|
|
if ($before !== null) {
|
|
|
|
$query->lte('updated', $before);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $query->update(array('status' => $new_status));
|
2014-02-15 20:09:50 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function change_item_ids_status($user_id, array $item_ids, $status)
|
implement frontend autoupdate
Only the unread counter is updated right know.
The AutoUpdate Feature is designed on the premise of don't wasting resources. A
distinction is made between updates when Miniflux is visible or hidden.
To determine the visibility status, the Page Visibility API is used. The API is
available starting with Chrome 33, Firefox 18 and IE10. [https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API]
As IE9 returns an undefined, it doesn't break the compatibility at least.
If Miniflux is visible, the unread counter on the web page is updated as soon as
a mismatch between the counter and the number of unread articles in the database
is found.
If Miniflux is hidden, the timestamp of the most recent article from each feed
is compared with the value from the last run. We have an update If the timestamp
of the latest article is greater than the stored one and the latest article is
unread. The web page title is updated with a ? symbol to notify the user and the
update check pauses till Miniflux gets visible again. If Miniflux gets visible
again, the number of unread articles is queried from the database, the unread
counter on the web page is updated and finally the ? symbol is removed from the
web page title.
This way I can use my fever API client to read new articles (or at least the
latest article) while Miniflux is hidden and as I've seen the new articles
already a new articles notification is prevented.
It's intentionally that the page does not reload automatically as long as
articles are visible. If I'm in hurry, I only scroll through the articles to
spot something interesting. Most of the time I don't reach the last article.
If the page is reloaded while I'm away, I would have to scan from the top again.
If we're on a nothing_to_read page and have unread articles in the database, a
redirect to the unread page will be done.
The default update check interval is 10 minutes and can be changed on the
settings page. A zero value disables the update check entirely.
fixes #213
2014-11-27 22:36:04 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
if (! in_array($status, array(STATUS_READ, STATUS_UNREAD, STATUS_REMOVED))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($item_ids)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->in('id', $item_ids)
|
2017-01-09 23:57:31 +01:00
|
|
|
->update(array('status' => $status));
|
implement frontend autoupdate
Only the unread counter is updated right know.
The AutoUpdate Feature is designed on the premise of don't wasting resources. A
distinction is made between updates when Miniflux is visible or hidden.
To determine the visibility status, the Page Visibility API is used. The API is
available starting with Chrome 33, Firefox 18 and IE10. [https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API]
As IE9 returns an undefined, it doesn't break the compatibility at least.
If Miniflux is visible, the unread counter on the web page is updated as soon as
a mismatch between the counter and the number of unread articles in the database
is found.
If Miniflux is hidden, the timestamp of the most recent article from each feed
is compared with the value from the last run. We have an update If the timestamp
of the latest article is greater than the stored one and the latest article is
unread. The web page title is updated with a ? symbol to notify the user and the
update check pauses till Miniflux gets visible again. If Miniflux gets visible
again, the number of unread articles is queried from the database, the unread
counter on the web page is updated and finally the ? symbol is removed from the
web page title.
This way I can use my fever API client to read new articles (or at least the
latest article) while Miniflux is hidden and as I've seen the new articles
already a new articles notification is prevented.
It's intentionally that the page does not reload automatically as long as
articles are visible. If I'm in hurry, I only scroll through the articles to
spot something interesting. Most of the time I don't reach the last article.
If the page is reloaded while I'm away, I would have to scan from the top again.
If we're on a nothing_to_read page and have unread articles in the database, a
redirect to the unread page will be done.
The default update check interval is 10 minutes and can be changed on the
settings page. A zero value disables the update check entirely.
fixes #213
2014-11-27 22:36:04 +01:00
|
|
|
}
|
|
|
|
|
2017-01-16 01:53:11 +01:00
|
|
|
function update_feed_items($user_id, $feed_id, array $items, $rtl = false, array $ignore_urls = array())
|
2014-02-15 20:09:50 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
$items_in_feed = array();
|
|
|
|
$db = Database::getInstance('db');
|
|
|
|
$db->startTransaction();
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
if ($item->getId() && $item->getUrl()) {
|
|
|
|
$item_id = get_item_id_from_checksum($feed_id, $item->getId());
|
2017-01-16 01:53:11 +01:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
$values = array(
|
|
|
|
'title' => $item->getTitle(),
|
|
|
|
'url' => $item->getUrl(),
|
|
|
|
'updated' => $item->getDate()->getTimestamp(),
|
|
|
|
'author' => $item->getAuthor(),
|
|
|
|
'content' => Helper\bool_config('nocontent') ? '' : $item->getContent(),
|
|
|
|
'enclosure_url' => $item->getEnclosureUrl(),
|
|
|
|
'enclosure_type' => $item->getEnclosureType(),
|
|
|
|
'language' => $item->getLanguage(),
|
|
|
|
'rtl' => $rtl || Parser::isLanguageRTL($item->getLanguage()) ? 1 : 0,
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($item_id > 0) {
|
2017-01-16 01:53:11 +01:00
|
|
|
if (in_array($item->getUrl(), $ignore_urls)) {
|
|
|
|
unset($values['content']);
|
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
$db
|
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->eq('feed_id', $feed_id)
|
|
|
|
->eq('id', $item_id)
|
|
|
|
->update($values);
|
|
|
|
} else {
|
|
|
|
$values['checksum'] = $item->getId();
|
|
|
|
$values['user_id'] = $user_id;
|
|
|
|
$values['feed_id'] = $feed_id;
|
|
|
|
$values['status'] = STATUS_UNREAD;
|
|
|
|
$item_id = $db->table(TABLE)->persist($values);
|
|
|
|
}
|
|
|
|
|
|
|
|
$items_in_feed[] = $item_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_feed_items($feed_id, $items_in_feed);
|
|
|
|
$db->closeTransaction();
|
2014-02-15 20:09:50 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function cleanup_feed_items($feed_id, array $items_in_feed)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
if (! empty($items_in_feed)) {
|
|
|
|
$db = Database::getInstance('db');
|
|
|
|
|
|
|
|
$removed_items = $db
|
|
|
|
->table(TABLE)
|
|
|
|
->columns('id')
|
|
|
|
->notIn('id', $items_in_feed)
|
|
|
|
->eq('status', STATUS_REMOVED)
|
|
|
|
->eq('feed_id', $feed_id)
|
|
|
|
->desc('updated')
|
|
|
|
->findAllByColumn('id');
|
|
|
|
|
|
|
|
// Keep a buffer of 2 items
|
|
|
|
// It's workaround for buggy feeds (cache issue with some Wordpress plugins)
|
|
|
|
if (is_array($removed_items)) {
|
|
|
|
$items_to_remove = array_slice($removed_items, 2);
|
|
|
|
|
|
|
|
if (! empty($items_to_remove)) {
|
|
|
|
// Handle the case when there is a huge number of items to remove
|
|
|
|
// Sqlite have a limit of 1000 sql variables by default
|
|
|
|
// Avoid the error message "too many SQL variables"
|
|
|
|
// We remove old items by batch of 500 items
|
|
|
|
$chunks = array_chunk($items_to_remove, 500);
|
|
|
|
|
|
|
|
foreach ($chunks as $chunk) {
|
|
|
|
$db->table(TABLE)
|
|
|
|
->in('id', $chunk)
|
|
|
|
->eq('status', STATUS_REMOVED)
|
|
|
|
->eq('feed_id', $feed_id)
|
|
|
|
->remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_item_id_from_checksum($feed_id, $checksum)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
return (int) Database::getInstance('db')
|
|
|
|
->table(TABLE)
|
|
|
|
->eq('feed_id', $feed_id)
|
|
|
|
->eq('checksum', $checksum)
|
|
|
|
->findOneColumn('id');
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_item($user_id, $item_id)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2013-12-23 02:55:53 +01:00
|
|
|
->table('items')
|
2016-12-26 15:44:53 +01:00
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->eq('id', $item_id)
|
2013-12-23 02:55:53 +01:00
|
|
|
->findOne();
|
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_item_nav($user_id, array $item, $status = array(STATUS_UNREAD), $bookmark = array(1, 0), $feed_id = null, $group_id = null)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2015-08-15 03:33:39 +02:00
|
|
|
$query = Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
2013-12-23 02:55:53 +01:00
|
|
|
->columns('id', 'status', 'title', 'bookmark')
|
2016-12-26 15:44:53 +01:00
|
|
|
->neq('status', STATUS_REMOVED)
|
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->orderBy('updated', Helper\config('items_sorting_direction'))
|
|
|
|
->desc('id')
|
|
|
|
;
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-04-18 01:44:45 +02:00
|
|
|
if ($feed_id) {
|
|
|
|
$query->eq('feed_id', $feed_id);
|
|
|
|
}
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-04-18 01:44:45 +02:00
|
|
|
if ($group_id) {
|
2016-12-26 15:44:53 +01:00
|
|
|
$query->in('feed_id', Group\get_feed_ids_by_group($group_id));
|
2016-04-18 01:44:45 +02:00
|
|
|
}
|
2015-11-19 16:31:31 +01:00
|
|
|
|
2013-12-23 02:55:53 +01:00
|
|
|
$items = $query->findAll();
|
|
|
|
|
|
|
|
$next_item = null;
|
|
|
|
$previous_item = null;
|
|
|
|
|
2016-05-03 10:45:07 +02:00
|
|
|
for ($i = 0, $ilen = count($items); $i < $ilen; ++$i) {
|
2013-12-23 02:55:53 +01:00
|
|
|
if ($items[$i]['id'] == $item['id']) {
|
|
|
|
if ($i > 0) {
|
|
|
|
$j = $i - 1;
|
|
|
|
|
|
|
|
while ($j >= 0) {
|
|
|
|
if (in_array($items[$j]['status'], $status) && in_array($items[$j]['bookmark'], $bookmark)) {
|
|
|
|
$previous_item = $items[$j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-03 10:45:07 +02:00
|
|
|
--$j;
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($i < ($ilen - 1)) {
|
|
|
|
$j = $i + 1;
|
|
|
|
|
|
|
|
while ($j < $ilen) {
|
|
|
|
if (in_array($items[$j]['status'], $status) && in_array($items[$j]['bookmark'], $bookmark)) {
|
|
|
|
$next_item = $items[$j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-03 10:45:07 +02:00
|
|
|
++$j;
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'next' => $next_item,
|
|
|
|
'previous' => $previous_item
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_items_by_status($user_id, $status, $feed_ids = array(), $offset = null, $limit = null, $order_column = 'updated', $order_direction = 'desc')
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2017-01-16 01:53:11 +01:00
|
|
|
->table(TABLE)
|
2016-12-26 15:44:53 +01:00
|
|
|
->columns(
|
|
|
|
'items.id',
|
|
|
|
'items.checksum',
|
|
|
|
'items.title',
|
|
|
|
'items.updated',
|
|
|
|
'items.url',
|
|
|
|
'items.enclosure_url',
|
|
|
|
'items.enclosure_type',
|
|
|
|
'items.bookmark',
|
|
|
|
'items.feed_id',
|
|
|
|
'items.status',
|
|
|
|
'items.content',
|
|
|
|
'items.language',
|
|
|
|
'items.rtl',
|
|
|
|
'items.author',
|
|
|
|
'feeds.site_url',
|
|
|
|
'feeds.title AS feed_title'
|
|
|
|
)
|
|
|
|
->join('feeds', 'id', 'feed_id')
|
|
|
|
->eq('items.user_id', $user_id)
|
|
|
|
->eq('items.status', $status)
|
|
|
|
->in('items.feed_id', $feed_ids)
|
|
|
|
->orderBy($order_column, $order_direction)
|
|
|
|
->offset($offset)
|
|
|
|
->limit($limit)
|
|
|
|
->findAll();
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_items($user_id, $since_id = null, array $item_ids = array(), $limit = 50)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
$query = Database::getInstance('db')
|
2017-01-16 01:53:11 +01:00
|
|
|
->table(TABLE)
|
2016-12-26 15:44:53 +01:00
|
|
|
->columns(
|
|
|
|
'items.id',
|
|
|
|
'items.checksum',
|
|
|
|
'items.title',
|
|
|
|
'items.updated',
|
|
|
|
'items.url',
|
|
|
|
'items.enclosure_url',
|
|
|
|
'items.enclosure_type',
|
|
|
|
'items.bookmark',
|
|
|
|
'items.feed_id',
|
|
|
|
'items.status',
|
|
|
|
'items.content',
|
|
|
|
'items.language',
|
|
|
|
'items.rtl',
|
|
|
|
'items.author',
|
|
|
|
'feeds.site_url',
|
|
|
|
'feeds.title AS feed_title'
|
|
|
|
)
|
|
|
|
->join('feeds', 'id', 'feed_id')
|
|
|
|
->eq('items.user_id', $user_id)
|
|
|
|
->neq('items.status', STATUS_REMOVED)
|
|
|
|
->limit($limit)
|
|
|
|
->asc('items.id');
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
if ($since_id !== null) {
|
|
|
|
$query->gt('items.id', $since_id);
|
|
|
|
} elseif (! empty($item_ids)) {
|
|
|
|
$query->in('items.id', $item_ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $query->findAll();
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_item_ids_by_status($user_id, $status)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2017-01-16 01:53:11 +01:00
|
|
|
->table(TABLE)
|
2016-12-26 15:44:53 +01:00
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->eq('status', $status)
|
2016-12-30 00:04:56 +01:00
|
|
|
->asc('id')
|
2016-12-26 15:44:53 +01:00
|
|
|
->findAllByColumn('id');
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2017-01-16 01:53:11 +01:00
|
|
|
function get_item_urls($user_id, $feed_id)
|
|
|
|
{
|
|
|
|
return Database::getInstance('db')
|
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->eq('feed_id', $feed_id)
|
|
|
|
->findAllByColumn('url');
|
|
|
|
}
|
|
|
|
|
2016-12-26 21:07:18 +01:00
|
|
|
function get_latest_unread_items_timestamps($user_id)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2016-12-26 21:07:18 +01:00
|
|
|
->table(TABLE)
|
2016-12-26 15:44:53 +01:00
|
|
|
->columns(
|
2016-12-26 21:07:18 +01:00
|
|
|
'feed_id',
|
|
|
|
'MAX(updated) as updated'
|
2016-12-26 15:44:53 +01:00
|
|
|
)
|
2016-12-26 21:07:18 +01:00
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->eq('status', STATUS_UNREAD)
|
|
|
|
->groupBy('feed_id')
|
|
|
|
->desc('updated')
|
2016-12-26 15:44:53 +01:00
|
|
|
->findAll();
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function count_by_status($user_id, $status, $feed_ids = array())
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
$query = Database::getInstance('db')
|
2017-01-16 01:53:11 +01:00
|
|
|
->table(TABLE)
|
2016-12-26 15:44:53 +01:00
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->in('feed_id', $feed_ids);
|
|
|
|
|
|
|
|
if (is_array($status)) {
|
|
|
|
$query->in('status', $status);
|
|
|
|
} else {
|
|
|
|
$query->eq('status', $status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $query->count();
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function autoflush_read($user_id)
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
$autoflush = Helper\int_config('autoflush');
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2013-12-23 03:25:54 +01:00
|
|
|
if ($autoflush > 0) {
|
2015-08-15 03:33:39 +02:00
|
|
|
Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
2013-12-23 02:55:53 +01:00
|
|
|
->eq('bookmark', 0)
|
2016-12-26 15:44:53 +01:00
|
|
|
->eq('status', STATUS_READ)
|
2013-12-23 02:55:53 +01:00
|
|
|
->lt('updated', strtotime('-'.$autoflush.'day'))
|
2016-12-26 15:44:53 +01:00
|
|
|
->save(array('status' => STATUS_REMOVED, 'content' => ''));
|
2016-04-18 01:44:45 +02:00
|
|
|
} elseif ($autoflush === -1) {
|
2015-08-15 03:33:39 +02:00
|
|
|
Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
2013-12-23 03:25:54 +01:00
|
|
|
->eq('bookmark', 0)
|
2016-12-26 15:44:53 +01:00
|
|
|
->eq('status', STATUS_READ)
|
|
|
|
->save(array('status' => STATUS_REMOVED, 'content' => ''));
|
2014-12-16 02:38:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function autoflush_unread($user_id)
|
2014-12-16 02:38:35 +01:00
|
|
|
{
|
2016-12-26 15:44:53 +01:00
|
|
|
$autoflush = Helper\int_config('autoflush_unread');
|
2014-12-16 02:38:35 +01:00
|
|
|
|
|
|
|
if ($autoflush > 0) {
|
2015-08-15 03:33:39 +02:00
|
|
|
Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
2014-12-16 02:38:35 +01:00
|
|
|
->eq('bookmark', 0)
|
2016-12-26 15:44:53 +01:00
|
|
|
->eq('status', STATUS_UNREAD)
|
2014-12-16 02:38:35 +01:00
|
|
|
->lt('updated', strtotime('-'.$autoflush.'day'))
|
2016-12-26 15:44:53 +01:00
|
|
|
->save(array('status' => STATUS_REMOVED, 'content' => ''));
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
}
|