2013-12-23 02:55:53 +01:00
|
|
|
<?php
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
namespace Miniflux\Controller;
|
|
|
|
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Router;
|
|
|
|
use Miniflux\Response;
|
|
|
|
use Miniflux\Request;
|
2016-12-26 15:44:53 +01:00
|
|
|
use Miniflux\Session\SessionStorage;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Template;
|
|
|
|
use Miniflux\Model;
|
|
|
|
|
2013-12-23 02:55:53 +01:00
|
|
|
// Display history page
|
2016-04-18 01:44:45 +02:00
|
|
|
Router\get_action('history', function () {
|
2016-12-26 15:44:53 +01:00
|
|
|
$params = items_list(Model\Item\STATUS_READ);
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
Response\html(Template\layout('history', $params + array(
|
|
|
|
'title' => t('History') . ' (' . $params['nb_items'] . ')',
|
|
|
|
'menu' => 'history',
|
2013-12-23 02:55:53 +01:00
|
|
|
)));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Confirmation box to flush history
|
2016-04-18 01:44:45 +02:00
|
|
|
Router\get_action('confirm-flush-history', function () {
|
2016-12-26 15:44:53 +01:00
|
|
|
$group_id = Request\int_param('group_id');
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2013-12-23 02:55:53 +01:00
|
|
|
Response\html(Template\layout('confirm_flush_items', array(
|
2016-02-28 14:58:07 +01:00
|
|
|
'group_id' => $group_id,
|
2013-12-23 02:55:53 +01:00
|
|
|
'menu' => 'history',
|
|
|
|
'title' => t('Confirmation')
|
|
|
|
)));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Flush history
|
2016-04-18 01:44:45 +02:00
|
|
|
Router\get_action('flush-history', function () {
|
2016-12-26 15:44:53 +01:00
|
|
|
$user_id = SessionStorage::getInstance()->getUserId();
|
|
|
|
$group_id = Request\int_param('group_id');
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
if ($group_id !== 0) {
|
|
|
|
Model\ItemGroup\change_items_status($user_id, $group_id, Model\Item\STATUS_READ, Model\Item\STATUS_REMOVED);
|
2016-02-28 14:58:07 +01:00
|
|
|
} else {
|
2016-12-26 15:44:53 +01:00
|
|
|
Model\Item\change_items_status($user_id, Model\Item\STATUS_READ, Model\Item\STATUS_REMOVED);
|
2016-02-28 14:58:07 +01:00
|
|
|
}
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2013-12-23 02:55:53 +01:00
|
|
|
Response\redirect('?action=history');
|
|
|
|
});
|