diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 56efe82bb..3efc7bb32 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -14,10 +14,13 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; use Wallabag\CoreBundle\Entity\Config; +use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule; +use Wallabag\CoreBundle\Entity\RuleInterface; use Wallabag\CoreBundle\Entity\TaggingRule; use Wallabag\CoreBundle\Form\Type\ChangePasswordType; use Wallabag\CoreBundle\Form\Type\ConfigType; use Wallabag\CoreBundle\Form\Type\FeedType; +use Wallabag\CoreBundle\Form\Type\IgnoreOriginUserRuleType; use Wallabag\CoreBundle\Form\Type\TaggingRuleImportType; use Wallabag\CoreBundle\Form\Type\TaggingRuleType; use Wallabag\CoreBundle\Form\Type\UserInformationType; @@ -173,6 +176,40 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config') . '#set5'); } + // handle ignore origin rules + $ignoreOriginUserRule = new IgnoreOriginUserRule(); + $action = $this->generateUrl('config') . '#set6'; + + if ($request->query->has('ignore-origin-user-rule')) { + $ignoreOriginUserRule = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule') + ->find($request->query->get('ignore-origin-user-rule')); + + if ($this->getUser()->getId() !== $ignoreOriginUserRule->getConfig()->getUser()->getId()) { + return $this->redirect($action); + } + + $action = $this->generateUrl('config', [ + 'ignore-origin-user-rule' => $ignoreOriginUserRule->getId(), + ]) . '#set6'; + } + + $newIgnoreOriginUserRule = $this->createForm(IgnoreOriginUserRuleType::class, $ignoreOriginUserRule, ['action' => $action]); + $newIgnoreOriginUserRule->handleRequest($request); + + if ($newIgnoreOriginUserRule->isSubmitted() && $newIgnoreOriginUserRule->isValid()) { + $ignoreOriginUserRule->setConfig($config); + $em->persist($ignoreOriginUserRule); + $em->flush(); + + $this->addFlash( + 'notice', + 'flashes.config.notice.ignore_origin_rules_updated' + ); + + return $this->redirect($this->generateUrl('config') . '#set6'); + } + return $this->render('WallabagCoreBundle:Config:index.html.twig', [ 'form' => [ 'config' => $configForm->createView(), @@ -181,6 +218,7 @@ class ConfigController extends Controller 'user' => $userForm->createView(), 'new_tagging_rule' => $newTaggingRule->createView(), 'import_tagging_rule' => $taggingRulesImportform->createView(), + 'new_ignore_origin_user_rule' => $newIgnoreOriginUserRule->createView(), ], 'feed' => [ 'username' => $user->getUsername(), @@ -447,6 +485,43 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config') . '?tagging-rule=' . $rule->getId() . '#set5'); } + /** + * Deletes an ignore origin rule and redirect to the config homepage. + * + * @Route("/ignore-origin-user-rule/delete/{id}", requirements={"id" = "\d+"}, name="delete_ignore_origin_rule") + * + * @return RedirectResponse + */ + public function deleteIgnoreOriginRuleAction(IgnoreOriginUserRule $rule) + { + $this->validateRuleAction($rule); + + $em = $this->getDoctrine()->getManager(); + $em->remove($rule); + $em->flush(); + + $this->addFlash( + 'notice', + 'flashes.config.notice.ignore_origin_rules_deleted' + ); + + return $this->redirect($this->generateUrl('config') . '#set6'); + } + + /** + * Edit an ignore origin rule. + * + * @Route("/ignore-origin-user-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_ignore_origin_rule") + * + * @return RedirectResponse + */ + public function editIgnoreOriginRuleAction(IgnoreOriginUserRule $rule) + { + $this->validateRuleAction($rule); + + return $this->redirect($this->generateUrl('config') . '?ignore-origin-user-rule=' . $rule->getId() . '#set6'); + } + /** * Remove all annotations OR tags OR entries for the current user. * @@ -659,10 +734,10 @@ class ConfigController extends Controller /** * Validate that a rule can be edited/deleted by the current user. */ - private function validateRuleAction(TaggingRule $rule) + private function validateRuleAction(RuleInterface $rule) { if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) { - throw $this->createAccessDeniedException('You can not access this tagging rule.'); + throw $this->createAccessDeniedException('You can not access this rule.'); } } diff --git a/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php new file mode 100644 index 000000000..679eff7de --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php @@ -0,0 +1,36 @@ +setRule('host = "example.fr"'); + $rule->setConfig($this->getReference('admin-user')->getConfig()); + + $manager->persist($rule); + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() + { + return [ + UserFixtures::class, + ]; + } +} diff --git a/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php new file mode 100644 index 000000000..b9110f17b --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php @@ -0,0 +1,37 @@ +add('rule', TextType::class, [ + 'required' => true, + 'label' => 'config.form_rules.rule_label', + ]) + ->add('save', SubmitType::class, [ + 'label' => 'config.form.save', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => 'Wallabag\CoreBundle\Entity\IgnoreOriginUserRule', + ]); + } + + public function getBlockPrefix() + { + return 'ignore_origin_user_rule'; + } +} diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 4d5259797..92440c92c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -59,6 +59,7 @@ config: user_info: 'Brugeroplysninger' password: 'Adgangskode' # rules: 'Tagging rules' + # ignore_origin: 'Ignore origin rules' new_user: 'Tilføj bruger' # reset: 'Reset area' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: # entry_already_saved: 'Entry already saved on %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index cd70c99ff..7a9382cb3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -59,6 +59,7 @@ config: user_info: 'Benutzerinformation' password: 'Kennwort' rules: 'Tagging-Regeln' + # ignore_origin: 'Ignore origin rules' new_user: 'Benutzer hinzufügen' reset: 'Zurücksetzen' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Eintrag bereits am %date% gespeichert' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 1bc32423a..b16662c31 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -59,6 +59,7 @@ config: user_info: 'User information' password: 'Password' rules: 'Tagging rules' + ignore_origin: 'Ignore origin rules' new_user: 'Add a user' reset: 'Reset area' form: @@ -617,6 +618,8 @@ flashes: otp_disabled: Two-factor authentication disabled tagging_rules_imported: Tagging rules imported tagging_rules_not_imported: Error while importing tagging rules + ignore_origin_rules_deleted: 'Ignore origin rule deleted' + ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Entry already saved on %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index bced72e95..3e77afd6b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -59,6 +59,7 @@ config: user_info: 'Información de usuario' password: 'Contraseña' rules: 'Reglas de etiquetado automáticas' + # ignore_origin: 'Ignore origin rules' new_user: 'Añadir un usuario' reset: 'Reiniciar mi cuenta' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled tagging_rules_imported: Reglas de etiquetado importadas tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Artículo ya guardado el %fecha%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 0704204aa..38c252f73 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -59,6 +59,7 @@ config: user_info: 'اطلاعات کاربر' password: 'رمز' rules: 'برچسبگذاری خودکار' + # ignore_origin: 'Ignore origin rules' new_user: 'افزودن کاربر' # reset: 'Reset area' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 5d5878eba..b12dd9ca9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -59,6 +59,7 @@ config: user_info: "Mon compte" password: "Mot de passe" rules: "Règles de tag automatiques" + ignore_origin: "Règles d'omission d'origine" new_user: "Créer un compte" reset: "Réinitialisation" form: @@ -618,6 +619,11 @@ flashes: otp_disabled: "Authentification à double-facteur désactivée" tagging_rules_imported: Règles bien importées tagging_rules_not_imported: Impossible d'importer les règles +<<<<<<< HEAD +======= + ignore_origin_rules_deleted: "Règle d'omission d'origine supprimée" + ignore_origin_rules_updated: "Règle d'omission d'origine mise à jour" +>>>>>>> 4c595340... fixup! Add new Ignore Origin rules tab, update ConfigController entry: notice: entry_already_saved: "Article déjà sauvegardé le %date%" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 23e72f20a..eb44318b9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -59,6 +59,7 @@ config: user_info: 'Informazioni utente' password: 'Password' rules: 'Regole di etichettatura' + # ignore_origin: 'Ignore origin rules' new_user: 'Aggiungi utente' reset: 'Area di reset' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Contenuto già salvato in data %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 6ddff6ea7..165186b1d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -59,6 +59,7 @@ config: user_info: 'Mon compte' password: 'Senhal' rules: "Règlas d'etiquetas automaticas" + # ignore_origin: 'Ignore origin rules' new_user: 'Crear un compte' reset: 'Zòna de reïnicializacion' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled tagging_rules_imported: Règlas d’etiquetatge importadas tagging_rules_not_imported: Error en important las règlas d’etiquetatge + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Article ja salvagardat lo %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 770477c96..fbf64f30b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -59,6 +59,7 @@ config: user_info: 'Informacje o użytkowniku' password: 'Hasło' rules: 'Zasady tagowania' + # ignore_origin: 'Ignore origin rules' new_user: 'Dodaj użytkownika' reset: 'Reset' form: @@ -617,6 +618,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Wpis już został dodany %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index d993cb059..93910d4be 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -59,6 +59,7 @@ config: user_info: 'Informação do Usuário' password: 'Senha' rules: 'Regras de tags' + # ignore_origin: 'Ignore origin rules' new_user: 'Adicionar um usuário' reset: 'Reiniciar minha conta' form: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index bc8b72e0b..5984d2298 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -59,6 +59,7 @@ config: user_info: 'Informații despre utilizator' password: 'Parolă' # rules: 'Tagging rules' + # ignore_origin: 'Ignore origin rules' new_user: 'Crează un utilizator' # reset: 'Reset area' form: @@ -616,6 +617,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: # entry_already_saved: 'Entry already saved on %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml index 2f7f55e53..a138ee5d3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml @@ -59,6 +59,7 @@ config: user_info: 'Информация о пользователе' password: 'Пароль' rules: 'Правила настройки простановки тегов' + # ignore_origin: 'Ignore origin rules' new_user: 'Добавить пользователя' reset: 'Сброс данных' form: @@ -616,6 +617,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Запись была сохранена ранее %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml index 48e1c34ad..b786a73d1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml @@ -59,6 +59,7 @@ config: user_info: 'ข้อมูลผู้ใช้' password: 'รหัสผ่าน' rules: 'การแท็กข้อบังคับ' + # ignore_origin: 'Ignore origin rules' new_user: 'เพิ่มผู้ใช้' reset: 'รีเซ็ตพื้นที่ ' form: @@ -616,6 +617,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'รายการพร้อมบันทึกที่ %date%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 19029c0b1..a317c2f50 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -59,6 +59,7 @@ config: user_info: 'Kullanıcı bilgileri' password: 'Şifre' rules: 'Etiketleme kuralları' + # ignore_origin: 'Ignore origin rules' new_user: 'Bir kullanıcı ekle' # reset: 'Reset area' form: @@ -616,6 +617,8 @@ flashes: # otp_disabled: Two-factor authentication disabled # tagging_rules_imported: Tagging rules imported # tagging_rules_not_imported: Error while importing tagging rules + # ignore_origin_rules_deleted: 'Ignore origin rule deleted' + # ignore_origin_rules_updated: 'Ignore origin rule updated' entry: notice: entry_already_saved: 'Entry already saved on %date%' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index eb395eac4..f182fda40 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -404,6 +404,33 @@ +