Add an auto flush function while reaching action=default or action=history.
It will flush all read items older than the specified number of days in the preferences 1 correction in the translation file fr_FR
This commit is contained in:
parent
9b6dfeca4e
commit
f03c543ded
@ -9,14 +9,12 @@ require 'vendor/PicoDb/Table.php';
|
|||||||
require 'schema.php';
|
require 'schema.php';
|
||||||
require 'model.php';
|
require 'model.php';
|
||||||
|
|
||||||
|
const DB_VERSION = 6;
|
||||||
const DB_VERSION = 5;
|
|
||||||
const APP_VERSION = 'master';
|
const APP_VERSION = 'master';
|
||||||
const APP_USERAGENT = 'Miniflux - http://miniflux.net';
|
const APP_USERAGENT = 'Miniflux - http://miniflux.net';
|
||||||
const HTTP_TIMEOUT = 5;
|
const HTTP_TIMEOUT = 5;
|
||||||
const LIMIT_ALL = -1;
|
const LIMIT_ALL = -1;
|
||||||
|
|
||||||
|
|
||||||
function get_db_filename()
|
function get_db_filename()
|
||||||
{
|
{
|
||||||
return 'data/db.sqlite';
|
return 'data/db.sqlite';
|
||||||
@ -29,13 +27,12 @@ PicoTools\container('db', function() {
|
|||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'filename' => get_db_filename()
|
'filename' => get_db_filename()
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($db->schema()->check(DB_VERSION)) {
|
if ($db->schema()->check(DB_VERSION)) {
|
||||||
|
|
||||||
return $db;
|
return $db;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
die('Unable to migrate database schema.');
|
die('Unable to migrate database schema.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -94,7 +94,6 @@ Router\post_action('login', function() {
|
|||||||
|
|
||||||
|
|
||||||
Router\get_action('show', function() {
|
Router\get_action('show', function() {
|
||||||
|
|
||||||
$id = Request\param('id');
|
$id = Request\param('id');
|
||||||
|
|
||||||
Response\html(Template\layout('read_item', array(
|
Response\html(Template\layout('read_item', array(
|
||||||
@ -170,6 +169,8 @@ Router\post_action('change-item-status', function() {
|
|||||||
|
|
||||||
|
|
||||||
Router\get_action('history', function() {
|
Router\get_action('history', function() {
|
||||||
|
// start auto purge if correctly set in preferences
|
||||||
|
Model\flush_read();
|
||||||
|
|
||||||
Response\html(Template\layout('history', array(
|
Response\html(Template\layout('history', array(
|
||||||
'items' => Model\get_read_items(),
|
'items' => Model\get_read_items(),
|
||||||
@ -388,6 +389,8 @@ Router\post_action('config', function() {
|
|||||||
|
|
||||||
|
|
||||||
Router\notfound(function() {
|
Router\notfound(function() {
|
||||||
|
// start auto purge if correctly set in preferences
|
||||||
|
Model\flush_read();
|
||||||
|
|
||||||
$items = Model\get_unread_items();
|
$items = Model\get_unread_items();
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ return array(
|
|||||||
'Password' => 'Mot de passe',
|
'Password' => 'Mot de passe',
|
||||||
'Confirmation' => 'Confirmation',
|
'Confirmation' => 'Confirmation',
|
||||||
'Language' => 'Langue',
|
'Language' => 'Langue',
|
||||||
|
'Number of days to keep (-1 disable auto flush)' => 'Nombre de jour à conserver (-1 désactive la purge auto)',
|
||||||
'Update' => 'Mettre à jour',
|
'Update' => 'Mettre à jour',
|
||||||
'More informations' => 'Plus d\'informations',
|
'More informations' => 'Plus d\'informations',
|
||||||
'Database' => 'Base de données',
|
'Database' => 'Base de données',
|
||||||
@ -79,7 +80,7 @@ return array(
|
|||||||
'The password is required' => 'Le mot de passe est obligatoire',
|
'The password is required' => 'Le mot de passe est obligatoire',
|
||||||
'The minimum length is 6 characters' => 'La longueur minimale est de 6 caractères',
|
'The minimum length is 6 characters' => 'La longueur minimale est de 6 caractères',
|
||||||
'The confirmation is required' => 'La confirmation est obligatoire',
|
'The confirmation is required' => 'La confirmation est obligatoire',
|
||||||
'Passwords doesn\'t match' => 'Les mots de passe ne sont pas identique',
|
'Passwords doesn\'t match' => 'Les mots de passe ne sont pas identiques',
|
||||||
'Do you really want to remove these items from your history?' => 'Voulez-vous vraiment supprimer les éléments de votre historique ?',
|
'Do you really want to remove these items from your history?' => 'Voulez-vous vraiment supprimer les éléments de votre historique ?',
|
||||||
'Do you really want to remove this subscription: "%s"?' => 'Voulez-vous vraiment supprimer cet abonnement : "%s" ?',
|
'Do you really want to remove this subscription: "%s"?' => 'Voulez-vous vraiment supprimer cet abonnement : "%s" ?',
|
||||||
'Nothing to read, do you want to <a href="?action=refresh-all" data-action="refresh-all">update your subscriptions?</a>' =>
|
'Nothing to read, do you want to <a href="?action=refresh-all" data-action="refresh-all">update your subscriptions?</a>' =>
|
||||||
|
24
model.php
24
model.php
@ -365,11 +365,23 @@ function flush_unread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function flush_read()
|
function flush_read() {
|
||||||
{
|
|
||||||
|
$max_days = \PicoTools\singleton('db')
|
||||||
|
->table('config')
|
||||||
|
->columns('max_days')
|
||||||
|
->findOne();
|
||||||
|
$max_days=$max_days['max_days'];
|
||||||
|
|
||||||
|
$max_age = 0;
|
||||||
|
if ($max_days != -1 ){
|
||||||
|
$max_age = time()- ($max_days*86400); //86400 = 1 day
|
||||||
|
}
|
||||||
|
|
||||||
\PicoTools\singleton('db')
|
\PicoTools\singleton('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
->eq('status', 'read')
|
->eq('status', 'read')
|
||||||
|
->lt('updated',$max_age)
|
||||||
->save(array('status' => 'removed'));
|
->save(array('status' => 'removed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +438,7 @@ function get_config()
|
|||||||
{
|
{
|
||||||
return \PicoTools\singleton('db')
|
return \PicoTools\singleton('db')
|
||||||
->table('config')
|
->table('config')
|
||||||
->columns('username', 'language')
|
->columns('username', 'language','max_days')
|
||||||
->findOne();
|
->findOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +447,7 @@ function get_user()
|
|||||||
{
|
{
|
||||||
return \PicoTools\singleton('db')
|
return \PicoTools\singleton('db')
|
||||||
->table('config')
|
->table('config')
|
||||||
->columns('username', 'password', 'language')
|
->columns('username', 'password', 'language','max_days')
|
||||||
->findOne();
|
->findOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +496,9 @@ function validate_config_update(array $values)
|
|||||||
new Validators\Required('password', t('The password is required')),
|
new Validators\Required('password', t('The password is required')),
|
||||||
new Validators\MinLength('password', t('The minimum length is 6 characters'), 6),
|
new Validators\MinLength('password', t('The minimum length is 6 characters'), 6),
|
||||||
new Validators\Required('confirmation', t('The confirmation is required')),
|
new Validators\Required('confirmation', t('The confirmation is required')),
|
||||||
new Validators\Equals('password', 'confirmation', t('Passwords doesn\'t match'))
|
new Validators\Equals('password', 'confirmation', t('Passwords doesn\'t match')),
|
||||||
|
new Validators\Required('max_days', t('The number of days to keep read item is required'))
|
||||||
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
namespace Schema;
|
namespace Schema;
|
||||||
|
|
||||||
|
function version_6($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec('ALTER TABLE config ADD COLUMN max_days INTEGER DEFAULT -1');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function version_5($pdo)
|
function version_5($pdo)
|
||||||
{
|
{
|
||||||
@ -66,3 +71,4 @@ function version_1($pdo)
|
|||||||
)
|
)
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
<?= Helper\form_label(t('Language'), 'language') ?>
|
<?= Helper\form_label(t('Language'), 'language') ?>
|
||||||
<?= Helper\form_select('language', $languages, $values, $errors) ?><br/>
|
<?= Helper\form_select('language', $languages, $values, $errors) ?><br/>
|
||||||
|
|
||||||
|
<?= Helper\form_label(t('Number of days to keep (-1 disable auto flush)'), 'max_days') ?>
|
||||||
|
<?= Helper\form_text('max_days', $values, $errors) ?><br/>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" value="<?= t('Update') ?>" class="btn btn-blue"/>
|
<input type="submit" value="<?= t('Update') ?>" class="btn btn-blue"/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user