Offer the possibility to edit/delete groups

master
Frederic Guillot 6 years ago
parent 19a0f41a9e
commit 3dfc748155
  1. 87
      app/controllers/groups.php
  2. 6
      app/helpers/template.php
  3. 11
      app/locales/ar_AR/translations.php
  4. 11
      app/locales/cs_CZ/translations.php
  5. 11
      app/locales/de_DE/translations.php
  6. 11
      app/locales/es_ES/translations.php
  7. 11
      app/locales/fr_FR/translations.php
  8. 11
      app/locales/it_IT/translations.php
  9. 11
      app/locales/ja_JP/translations.php
  10. 11
      app/locales/pt_BR/translations.php
  11. 11
      app/locales/ru_RU/translations.php
  12. 11
      app/locales/sr_RS/translations.php
  13. 11
      app/locales/sr_RS@latin/translations.php
  14. 11
      app/locales/tr_TR/translations.php
  15. 11
      app/locales/zh_CN/translations.php
  16. 27
      app/models/group.php
  17. 1
      app/templates/feeds/create.php
  18. 1
      app/templates/feeds/edit.php
  19. 1
      app/templates/feeds/list.php
  20. 24
      app/templates/groups/edit.php
  21. 32
      app/templates/groups/list.php
  22. 10
      app/templates/groups/remove.php
  23. 21
      app/validators/group.php
  24. 1
      composer.json
  25. 12
      composer.lock
  26. 1
      index.php
  27. 1
      vendor/composer/autoload_files.php
  28. 1
      vendor/composer/autoload_static.php

@ -0,0 +1,87 @@
<?php
namespace Miniflux\Controller;
use Miniflux\Session\SessionStorage;
use Miniflux\Validator;
use Miniflux\Router;
use Miniflux\Response;
use Miniflux\Request;
use Miniflux\Template;
use Miniflux\Handler;
use Miniflux\Model;
// Display all groups
Router\get_action('groups', function () {
$user_id = SessionStorage::getInstance()->getUserId();
Response\html(Template\layout('groups/list', array(
'groups' => Model\Group\get_all($user_id),
'menu' => 'feeds',
'title' => t('Groups'),
)));
});
// Confirmation dialog to remove a group
Router\get_action('confirm-remove-group', function () {
$user_id = SessionStorage::getInstance()->getUserId();
$group_id = Request\int_param('group_id');
Response\html(Template\layout('groups/remove', array(
'group' => Model\Group\get_group($user_id, $group_id),
'menu' => 'feeds',
'title' => t('Confirmation')
)));
});
// Remove a group
Router\get_action('remove-group', function () {
$user_id = SessionStorage::getInstance()->getUserId();
$group_id = Request\int_param('group_id');
if (Model\Group\remove_group($user_id, $group_id)) {
SessionStorage::getInstance()->setFlashMessage(t('This group has been removed successfully.'));
} else {
SessionStorage::getInstance()->setFlashErrorMessage(t('Unable to remove this group.'));
}
Response\redirect('?action=groups');
});
// Edit group form
Router\get_action('edit-group', function () {
$user_id = SessionStorage::getInstance()->getUserId();
$group_id = Request\int_param('group_id');
$values = Model\Group\get_group($user_id, $group_id);
Response\html(Template\layout('groups/edit', array(
'values' => $values,
'errors' => array(),
'menu' => 'feeds',
'title' => t('Edit group')
)));
});
// Submit edit group form
Router\post_action('edit-group', function () {
$user_id = SessionStorage::getInstance()->getUserId();
$values = Request\values();
list($valid, $errors) = Validator\Group\validate_modification($values);
if ($valid) {
if (Model\Group\update_group($user_id, $values['id'], $values['title'])) {
SessionStorage::getInstance()->setFlashMessage(t('Group updated successfully.'));
Response\redirect('?action=groups');
} else {
SessionStorage::getInstance()->setFlashErrorMessage(t('Unable to edit this group.'));
}
}
Response\html(Template\layout('groups/edit', array(
'values' => $values,
'errors' => $errors,
'menu' => 'feeds',
'title' => t('Edit group')
)));
});

@ -126,3 +126,9 @@ function link($label, $action, array $params = array())
$params['action'] = $action;
return sprintf('<a href="?%s">%s</a>', http_build_query($params, '', '&amp;'), escape($label));
}
function button($type, $label, $action, array $params = array())
{
$params['action'] = $action;
return sprintf('<a href="?%s" class="btn btn-%s">%s</a>', http_build_query($params, '', '&amp;'), $type, escape($label));
}

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
'New Password' => 'Nové heslo',
'Wrong password' => 'Špatné heslo',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
'New Password' => 'Nouveau mot de passe',
'Wrong password' => 'Mauvais mot de passe',
'Duplicated feed' => 'Abonnement dupliqué',
'This group has been removed successfully.' => 'Ce libellé a été supprimé avec succès.',
'Unable to remove this group.' => 'Impossible de supprimer ce libellé.',
'Edit group' => 'Modifier un libellé',
'Group updated successfully.' => 'Libellé modifié avec succès.',
'Unable to edit this group.' => 'Impossible de modifier ce libellé.',
'groups' => 'libellés',
'There is no group.' => 'Il n\'y a aucun libellé.',
'Do you really want to remove this group: "%s"?' => 'Voulez-vous vraiment supprimer ce libellé : « %s » ?',
'This field is required' => 'Ce champ est requis',
'This value must be an integer' => 'Cette valeur doit être un entier',
'This text is too long (max. %d)' => 'Ce texte est trop long (max. %d)',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -257,4 +257,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
'New Password' => 'Новый пароль',
'Wrong password' => 'Неверный пароль',
'Duplicated feed' => 'Дублирующийся канал',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
// 'New Password' => '',
// 'Wrong password' => '',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -255,4 +255,15 @@ return array(
'New Password' => '新密码',
'Wrong password' => '密码错误',
// 'Duplicated feed' => '',
// 'This group has been removed successfully.' => '',
// 'Unable to remove this group.' => '',
// 'Edit group' => '',
// 'Group updated successfully.' => '',
// 'Unable to edit this group.' => '',
// 'groups' => '',
// 'There is no group.' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'This field is required' => '',
// 'This value must be an integer' => '',
// 'This text is too long (max. %d)' => '',
);

@ -16,6 +16,33 @@ function get_all($user_id)
->findAll();
}
function get_group($user_id, $group_id)
{
return Database::getInstance('db')
->table(TABLE)
->eq('user_id', $user_id)
->eq('id', $group_id)
->findOne();
}
function remove_group($user_id, $group_id)
{
return Database::getInstance('db')
->table(TABLE)
->eq('user_id', $user_id)
->eq('id', $group_id)
->remove();
}
function update_group($user_id, $group_id, $title)
{
return Database::getInstance('db')
->table(TABLE)
->eq('user_id', $user_id)
->eq('id', $group_id)
->update(array('title' => $title));
}
function get_groups_feed_ids($user_id)
{
$result = array();

@ -4,6 +4,7 @@
<ul>
<li class="active"><a href="?action=add"><?php echo t('add') ?></a></li>
<li><a href="?action=feeds"><?php echo t('feeds') ?></a></li>
<li><a href="?action=groups"><?php echo t('groups') ?></a></li>
<li><a href="?action=import"><?php echo t('import') ?></a></li>
<li><a href="?action=export"><?php echo t('export') ?></a></li>
</ul>

@ -3,6 +3,7 @@
<ul>
<li><a href="?action=add"><?php echo t('add') ?></a></li>
<li><a href="?action=feeds"><?php echo t('feeds') ?></a></li>
<li><a href="?action=groups"><?php echo t('groups') ?></a></li>
<li><a href="?action=import"><?php echo t('import') ?></a></li>
<li><a href="?action=export"><?php echo t('export') ?></a></li>
</ul>

@ -4,6 +4,7 @@
<ul>
<li><a href="?action=add"><?php echo t('add') ?></a></li>
<li class="active"><a href="?action=feeds"><?php echo t('feeds') ?></a></li>
<li><a href="?action=groups"><?php echo t('groups') ?></a></li>
<li><a href="?action=import"><?php echo t('import') ?></a></li>
<li><a href="?action=export"><?php echo t('export') ?></a></li>
<li><a href="?action=refresh-all" data-action="refresh-all" data-concurrent-requests="<?php echo SUBSCRIPTION_CONCURRENT_REQUESTS ?>"><?php echo t('refresh all') ?></a></li>

@ -0,0 +1,24 @@
<div class="page-header">
<h2><?php echo t('Edt group') ?></h2>
<nav>
<ul>
<li><a href="?action=add"><?php echo t('add') ?></a></li>
<li><a href="?action=feeds"><?php echo t('feeds') ?></a></li>
<li class="active"><a href="?action=groups"><?php echo t('groups') ?></a></li>
<li><a href="?action=import"><?php echo t('import') ?></a></li>
<li><a href="?action=export"><?php echo t('export') ?></a></li>
</ul>
</nav>
</div>
<form method="post" action="?action=edit-group" autocomplete="off">
<?php echo Miniflux\Helper\form_hidden('id', $values) ?>
<?php echo Miniflux\Helper\form_label(t('Title'), 'title') ?>
<?php echo Miniflux\Helper\form_text('title', $values, $errors, array('required', 'autofocus')) ?>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?php echo t('Save') ?></button>
<?php echo t('or') ?> <?php echo Miniflux\Helper\link(t('cancel'), 'groups') ?>
</div>
</form>

@ -0,0 +1,32 @@
<div class="page-header">
<h2><?php echo t('Groups') ?></h2>
<nav>
<ul>
<li><a href="?action=add"><?php echo t('add') ?></a></li>
<li><a href="?action=feeds"><?php echo t('feeds') ?></a></li>
<li class="active"><a href="?action=groups"><?php echo t('groups') ?></a></li>
<li><a href="?action=import"><?php echo t('import') ?></a></li>
<li><a href="?action=export"><?php echo t('export') ?></a></li>
</ul>
</nav>
</div>
<?php if (empty($groups)): ?>
<p class="alert alert-info"><?php echo t('There is no group.') ?></p>
<?php else: ?>
<section class="items">
<?php foreach ($groups as $group): ?>
<article>
<h2><?php echo Miniflux\Helper\escape($group['title']) ?></h2>
<ul class="item-menu">
<li>
<?php echo Miniflux\Helper\link(t('edit'), 'edit-group', array('group_id' => $group['id'])) ?>
</li>
<li>
<?php echo Miniflux\Helper\link(t('remove'), 'confirm-remove-group', array('group_id' => $group['id'])) ?>
</li>
</ul>
</article>
<?php endforeach ?>
</section>
<?php endif ?>

@ -0,0 +1,10 @@
<div class="page-header">
<h2><?php echo t('Confirmation') ?></h2>
</div>
<p class="alert alert-info"><?php echo t('Do you really want to remove this group: "%s"?', Miniflux\Helper\escape($group['title'])) ?></p>
<div class="form-actions">
<?php echo Miniflux\Helper\button('red', t('Remove'), 'remove-group', array('group_id' => $group['id'])) ?>
<?php echo t('or') ?> <?php echo Miniflux\Helper\link(t('cancel'), 'groups') ?>
</div>

@ -0,0 +1,21 @@
<?php
namespace Miniflux\Validator\Group;
use SimpleValidator\Validator;
use SimpleValidator\Validators;
function validate_modification(array $values)
{
$v = new Validator($values, array(
new Validators\Required('id', t('This field is required')),
new Validators\Integer('id', t('This value must be an integer')),
new Validators\Required('title', t('The title is required')),
new Validators\MaxLength('title', t('This text is too long (max. %d)', 255), 255),
));
return array(
$v->execute(),
$v->getErrors(),
);
}

@ -63,6 +63,7 @@
"app/models/favicon.php",
"app/validators/config.php",
"app/validators/feed.php",
"app/validators/group.php",
"app/validators/user.php"
],
"classmap": [

12
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "84a5e3b6cc5bebc61559f062e3d3cb6f",
"hash": "287ac8083a99b8a4abb829567a4a7627",
"content-hash": "7964640dd4d057358aeb236996973c90",
"packages": [
{
@ -967,16 +967,16 @@
},
{
"name": "sebastian/comparator",
"version": "1.2.2",
"version": "1.2.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f"
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1ed12e8b2409076ab22e3897126211ff8b1f7f",
"reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
"shasum": ""
},
"require": {
@ -1027,7 +1027,7 @@
"compare",
"equality"
],
"time": "2016-11-19 09:18:40"
"time": "2017-01-29 09:50:25"
},
{
"name": "sebastian/diff",

@ -18,6 +18,7 @@ Router\bootstrap(
'bookmark',
'config',
'feed',
'groups',
'help',
'history',
'item',

@ -39,5 +39,6 @@ return array(
'785cebb801997d40232b8337459f1606' => $baseDir . '/app/models/favicon.php',
'e348a7661429e81fa0e42efff1ebfe6e' => $baseDir . '/app/validators/config.php',
'679a0a7c75414c39298328823e0be180' => $baseDir . '/app/validators/feed.php',
'c9b6df0c6d89508a97bc5c3af8a92707' => $baseDir . '/app/validators/group.php',
'eea04c7f459daa801618b71f49a8c470' => $baseDir . '/app/validators/user.php',
);

@ -40,6 +40,7 @@ class ComposerStaticInitfc88bf644a3dc0d30b5792ad2fec7895
'785cebb801997d40232b8337459f1606' => __DIR__ . '/../..' . '/app/models/favicon.php',
'e348a7661429e81fa0e42efff1ebfe6e' => __DIR__ . '/../..' . '/app/validators/config.php',
'679a0a7c75414c39298328823e0be180' => __DIR__ . '/../..' . '/app/validators/feed.php',
'c9b6df0c6d89508a97bc5c3af8a92707' => __DIR__ . '/../..' . '/app/validators/group.php',
'eea04c7f459daa801618b71f49a8c470' => __DIR__ . '/../..' . '/app/validators/user.php',
);

Loading…
Cancel
Save