aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-06-23 22:13:44 +0200
committerKevin Decherf <kevin@kdecherf.com>2020-04-25 15:59:23 +0200
commit24230a5130005e274e1d8d3fe8eaca13cb978b9c (patch)
treedd91e56d1f8ea2ad0302440206688d13f66d1bfc
parentc675bd11c66e60a1976dfd66484448dcc9d80f0f (diff)
downloadwallabag-24230a5130005e274e1d8d3fe8eaca13cb978b9c.tar.gz
wallabag-24230a5130005e274e1d8d3fe8eaca13cb978b9c.tar.zst
wallabag-24230a5130005e274e1d8d3fe8eaca13cb978b9c.zip
Add new Ignore Origin rules tab, update ConfigController
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php79
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php36
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php37
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml6
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.th.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml3
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig27
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig49
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php148
20 files changed, 406 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 56efe82b..3efc7bb3 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;
14use Symfony\Component\Routing\Annotation\Route; 14use Symfony\Component\Routing\Annotation\Route;
15use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; 15use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
16use Wallabag\CoreBundle\Entity\Config; 16use Wallabag\CoreBundle\Entity\Config;
17use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
18use Wallabag\CoreBundle\Entity\RuleInterface;
17use Wallabag\CoreBundle\Entity\TaggingRule; 19use Wallabag\CoreBundle\Entity\TaggingRule;
18use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 20use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
19use Wallabag\CoreBundle\Form\Type\ConfigType; 21use Wallabag\CoreBundle\Form\Type\ConfigType;
20use Wallabag\CoreBundle\Form\Type\FeedType; 22use Wallabag\CoreBundle\Form\Type\FeedType;
23use Wallabag\CoreBundle\Form\Type\IgnoreOriginUserRuleType;
21use Wallabag\CoreBundle\Form\Type\TaggingRuleImportType; 24use Wallabag\CoreBundle\Form\Type\TaggingRuleImportType;
22use Wallabag\CoreBundle\Form\Type\TaggingRuleType; 25use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
23use Wallabag\CoreBundle\Form\Type\UserInformationType; 26use Wallabag\CoreBundle\Form\Type\UserInformationType;
@@ -173,6 +176,40 @@ class ConfigController extends Controller
173 return $this->redirect($this->generateUrl('config') . '#set5'); 176 return $this->redirect($this->generateUrl('config') . '#set5');
174 } 177 }
175 178
179 // handle ignore origin rules
180 $ignoreOriginUserRule = new IgnoreOriginUserRule();
181 $action = $this->generateUrl('config') . '#set6';
182
183 if ($request->query->has('ignore-origin-user-rule')) {
184 $ignoreOriginUserRule = $this->getDoctrine()
185 ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
186 ->find($request->query->get('ignore-origin-user-rule'));
187
188 if ($this->getUser()->getId() !== $ignoreOriginUserRule->getConfig()->getUser()->getId()) {
189 return $this->redirect($action);
190 }
191
192 $action = $this->generateUrl('config', [
193 'ignore-origin-user-rule' => $ignoreOriginUserRule->getId(),
194 ]) . '#set6';
195 }
196
197 $newIgnoreOriginUserRule = $this->createForm(IgnoreOriginUserRuleType::class, $ignoreOriginUserRule, ['action' => $action]);
198 $newIgnoreOriginUserRule->handleRequest($request);
199
200 if ($newIgnoreOriginUserRule->isSubmitted() && $newIgnoreOriginUserRule->isValid()) {
201 $ignoreOriginUserRule->setConfig($config);
202 $em->persist($ignoreOriginUserRule);
203 $em->flush();
204
205 $this->addFlash(
206 'notice',
207 'flashes.config.notice.ignore_origin_rules_updated'
208 );
209
210 return $this->redirect($this->generateUrl('config') . '#set6');
211 }
212
176 return $this->render('WallabagCoreBundle:Config:index.html.twig', [ 213 return $this->render('WallabagCoreBundle:Config:index.html.twig', [
177 'form' => [ 214 'form' => [
178 'config' => $configForm->createView(), 215 'config' => $configForm->createView(),
@@ -181,6 +218,7 @@ class ConfigController extends Controller
181 'user' => $userForm->createView(), 218 'user' => $userForm->createView(),
182 'new_tagging_rule' => $newTaggingRule->createView(), 219 'new_tagging_rule' => $newTaggingRule->createView(),
183 'import_tagging_rule' => $taggingRulesImportform->createView(), 220 'import_tagging_rule' => $taggingRulesImportform->createView(),
221 'new_ignore_origin_user_rule' => $newIgnoreOriginUserRule->createView(),
184 ], 222 ],
185 'feed' => [ 223 'feed' => [
186 'username' => $user->getUsername(), 224 'username' => $user->getUsername(),
@@ -448,6 +486,43 @@ class ConfigController extends Controller
448 } 486 }
449 487
450 /** 488 /**
489 * Deletes an ignore origin rule and redirect to the config homepage.
490 *
491 * @Route("/ignore-origin-user-rule/delete/{id}", requirements={"id" = "\d+"}, name="delete_ignore_origin_rule")
492 *
493 * @return RedirectResponse
494 */
495 public function deleteIgnoreOriginRuleAction(IgnoreOriginUserRule $rule)
496 {
497 $this->validateRuleAction($rule);
498
499 $em = $this->getDoctrine()->getManager();
500 $em->remove($rule);
501 $em->flush();
502
503 $this->addFlash(
504 'notice',
505 'flashes.config.notice.ignore_origin_rules_deleted'
506 );
507
508 return $this->redirect($this->generateUrl('config') . '#set6');
509 }
510
511 /**
512 * Edit an ignore origin rule.
513 *
514 * @Route("/ignore-origin-user-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_ignore_origin_rule")
515 *
516 * @return RedirectResponse
517 */
518 public function editIgnoreOriginRuleAction(IgnoreOriginUserRule $rule)
519 {
520 $this->validateRuleAction($rule);
521
522 return $this->redirect($this->generateUrl('config') . '?ignore-origin-user-rule=' . $rule->getId() . '#set6');
523 }
524
525 /**
451 * Remove all annotations OR tags OR entries for the current user. 526 * Remove all annotations OR tags OR entries for the current user.
452 * 527 *
453 * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset") 528 * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset")
@@ -659,10 +734,10 @@ class ConfigController extends Controller
659 /** 734 /**
660 * Validate that a rule can be edited/deleted by the current user. 735 * Validate that a rule can be edited/deleted by the current user.
661 */ 736 */
662 private function validateRuleAction(TaggingRule $rule) 737 private function validateRuleAction(RuleInterface $rule)
663 { 738 {
664 if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) { 739 if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) {
665 throw $this->createAccessDeniedException('You can not access this tagging rule.'); 740 throw $this->createAccessDeniedException('You can not access this rule.');
666 } 741 }
667 } 742 }
668 743
diff --git a/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php
new file mode 100644
index 00000000..679eff7d
--- /dev/null
+++ b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php
@@ -0,0 +1,36 @@
1<?php
2
3namespace Wallabag\CoreBundle\DataFixtures;
4
5use Doctrine\Bundle\FixturesBundle\Fixture;
6use Doctrine\Common\DataFixtures\DependentFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
9use Wallabag\UserBundle\DataFixtures\UserFixtures;
10
11class IgnoreOriginUserRuleFixtures extends Fixture implements DependentFixtureInterface
12{
13 /**
14 * {@inheritdoc}
15 */
16 public function load(ObjectManager $manager)
17 {
18 $rule = new IgnoreOriginUserRule();
19 $rule->setRule('host = "example.fr"');
20 $rule->setConfig($this->getReference('admin-user')->getConfig());
21
22 $manager->persist($rule);
23
24 $manager->flush();
25 }
26
27 /**
28 * {@inheritdoc}
29 */
30 public function getDependencies()
31 {
32 return [
33 UserFixtures::class,
34 ];
35 }
36}
diff --git a/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php
new file mode 100644
index 00000000..b9110f17
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php
@@ -0,0 +1,37 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\SubmitType;
7use Symfony\Component\Form\Extension\Core\Type\TextType;
8use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver;
10
11class IgnoreOriginUserRuleType extends AbstractType
12{
13 public function buildForm(FormBuilderInterface $builder, array $options)
14 {
15 $builder
16 ->add('rule', TextType::class, [
17 'required' => true,
18 'label' => 'config.form_rules.rule_label',
19 ])
20 ->add('save', SubmitType::class, [
21 'label' => 'config.form.save',
22 ])
23 ;
24 }
25
26 public function configureOptions(OptionsResolver $resolver)
27 {
28 $resolver->setDefaults([
29 'data_class' => 'Wallabag\CoreBundle\Entity\IgnoreOriginUserRule',
30 ]);
31 }
32
33 public function getBlockPrefix()
34 {
35 return 'ignore_origin_user_rule';
36 }
37}
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 4d525979..92440c92 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Brugeroplysninger' 59 user_info: 'Brugeroplysninger'
60 password: 'Adgangskode' 60 password: 'Adgangskode'
61 # rules: 'Tagging rules' 61 # rules: 'Tagging rules'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Tilføj bruger' 63 new_user: 'Tilføj bruger'
63 # reset: 'Reset area' 64 # reset: 'Reset area'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 619 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 620 # tagging_rules_not_imported: Error while importing tagging rules
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 # entry_already_saved: 'Entry already saved on %date%' 625 # 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 cd70c99f..7a9382cb 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Benutzerinformation' 59 user_info: 'Benutzerinformation'
60 password: 'Kennwort' 60 password: 'Kennwort'
61 rules: 'Tagging-Regeln' 61 rules: 'Tagging-Regeln'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Benutzer hinzufügen' 63 new_user: 'Benutzer hinzufügen'
63 reset: 'Zurücksetzen' 64 reset: 'Zurücksetzen'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 619 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 620 # tagging_rules_not_imported: Error while importing tagging rules
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'Eintrag bereits am %date% gespeichert' 625 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 1bc32423..b16662c3 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'User information' 59 user_info: 'User information'
60 password: 'Password' 60 password: 'Password'
61 rules: 'Tagging rules' 61 rules: 'Tagging rules'
62 ignore_origin: 'Ignore origin rules'
62 new_user: 'Add a user' 63 new_user: 'Add a user'
63 reset: 'Reset area' 64 reset: 'Reset area'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 otp_disabled: Two-factor authentication disabled 618 otp_disabled: Two-factor authentication disabled
618 tagging_rules_imported: Tagging rules imported 619 tagging_rules_imported: Tagging rules imported
619 tagging_rules_not_imported: Error while importing tagging rules 620 tagging_rules_not_imported: Error while importing tagging rules
621 ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'Entry already saved on %date%' 625 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 bced72e9..3e77afd6 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Información de usuario' 59 user_info: 'Información de usuario'
60 password: 'Contraseña' 60 password: 'Contraseña'
61 rules: 'Reglas de etiquetado automáticas' 61 rules: 'Reglas de etiquetado automáticas'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Añadir un usuario' 63 new_user: 'Añadir un usuario'
63 reset: 'Reiniciar mi cuenta' 64 reset: 'Reiniciar mi cuenta'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 tagging_rules_imported: Reglas de etiquetado importadas 619 tagging_rules_imported: Reglas de etiquetado importadas
619 tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado 620 tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'Artículo ya guardado el %fecha%' 625 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 0704204a..38c252f7 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'اطلاعات کاربر' 59 user_info: 'اطلاعات کاربر'
60 password: 'رمز' 60 password: 'رمز'
61 rules: 'برچسب‌گذاری خودکار' 61 rules: 'برچسب‌گذاری خودکار'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'افزودن کاربر' 63 new_user: 'افزودن کاربر'
63 # reset: 'Reset area' 64 # reset: 'Reset area'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 619 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 620 # tagging_rules_not_imported: Error while importing tagging rules
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' 625 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 5d5878eb..b12dd9ca 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -59,6 +59,7 @@ config:
59 user_info: "Mon compte" 59 user_info: "Mon compte"
60 password: "Mot de passe" 60 password: "Mot de passe"
61 rules: "Règles de tag automatiques" 61 rules: "Règles de tag automatiques"
62 ignore_origin: "Règles d'omission d'origine"
62 new_user: "Créer un compte" 63 new_user: "Créer un compte"
63 reset: "Réinitialisation" 64 reset: "Réinitialisation"
64 form: 65 form:
@@ -618,6 +619,11 @@ flashes:
618 otp_disabled: "Authentification à double-facteur désactivée" 619 otp_disabled: "Authentification à double-facteur désactivée"
619 tagging_rules_imported: Règles bien importées 620 tagging_rules_imported: Règles bien importées
620 tagging_rules_not_imported: Impossible d'importer les règles 621 tagging_rules_not_imported: Impossible d'importer les règles
622<<<<<<< HEAD
623=======
624 ignore_origin_rules_deleted: "Règle d'omission d'origine supprimée"
625 ignore_origin_rules_updated: "Règle d'omission d'origine mise à jour"
626>>>>>>> 4c595340... fixup! Add new Ignore Origin rules tab, update ConfigController
621 entry: 627 entry:
622 notice: 628 notice:
623 entry_already_saved: "Article déjà sauvegardé le %date%" 629 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 23e72f20..eb44318b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Informazioni utente' 59 user_info: 'Informazioni utente'
60 password: 'Password' 60 password: 'Password'
61 rules: 'Regole di etichettatura' 61 rules: 'Regole di etichettatura'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Aggiungi utente' 63 new_user: 'Aggiungi utente'
63 reset: 'Area di reset' 64 reset: 'Area di reset'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 619 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 620 # tagging_rules_not_imported: Error while importing tagging rules
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'Contenuto già salvato in data %date%' 625 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 6ddff6ea..165186b1 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Mon compte' 59 user_info: 'Mon compte'
60 password: 'Senhal' 60 password: 'Senhal'
61 rules: "Règlas d'etiquetas automaticas" 61 rules: "Règlas d'etiquetas automaticas"
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Crear un compte' 63 new_user: 'Crear un compte'
63 reset: 'Zòna de reïnicializacion' 64 reset: 'Zòna de reïnicializacion'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 tagging_rules_imported: Règlas d’etiquetatge importadas 619 tagging_rules_imported: Règlas d’etiquetatge importadas
619 tagging_rules_not_imported: Error en important las règlas d’etiquetatge 620 tagging_rules_not_imported: Error en important las règlas d’etiquetatge
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'Article ja salvagardat lo %date%' 625 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 770477c9..fbf64f30 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Informacje o użytkowniku' 59 user_info: 'Informacje o użytkowniku'
60 password: 'Hasło' 60 password: 'Hasło'
61 rules: 'Zasady tagowania' 61 rules: 'Zasady tagowania'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Dodaj użytkownika' 63 new_user: 'Dodaj użytkownika'
63 reset: 'Reset' 64 reset: 'Reset'
64 form: 65 form:
@@ -617,6 +618,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 618 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 619 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 620 # tagging_rules_not_imported: Error while importing tagging rules
621 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
622 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 623 entry:
621 notice: 624 notice:
622 entry_already_saved: 'Wpis już został dodany %date%' 625 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 d993cb05..93910d4b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Informação do Usuário' 59 user_info: 'Informação do Usuário'
60 password: 'Senha' 60 password: 'Senha'
61 rules: 'Regras de tags' 61 rules: 'Regras de tags'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Adicionar um usuário' 63 new_user: 'Adicionar um usuário'
63 reset: 'Reiniciar minha conta' 64 reset: 'Reiniciar minha conta'
64 form: 65 form:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index bc8b72e0..5984d229 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Informații despre utilizator' 59 user_info: 'Informații despre utilizator'
60 password: 'Parolă' 60 password: 'Parolă'
61 # rules: 'Tagging rules' 61 # rules: 'Tagging rules'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Crează un utilizator' 63 new_user: 'Crează un utilizator'
63 # reset: 'Reset area' 64 # reset: 'Reset area'
64 form: 65 form:
@@ -616,6 +617,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 617 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 618 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 619 # tagging_rules_not_imported: Error while importing tagging rules
620 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
621 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 622 entry:
620 notice: 623 notice:
621 # entry_already_saved: 'Entry already saved on %date%' 624 # 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 2f7f55e5..a138ee5d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Информация о пользователе' 59 user_info: 'Информация о пользователе'
60 password: 'Пароль' 60 password: 'Пароль'
61 rules: 'Правила настройки простановки тегов' 61 rules: 'Правила настройки простановки тегов'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Добавить пользователя' 63 new_user: 'Добавить пользователя'
63 reset: 'Сброс данных' 64 reset: 'Сброс данных'
64 form: 65 form:
@@ -616,6 +617,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 617 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 618 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 619 # tagging_rules_not_imported: Error while importing tagging rules
620 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
621 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 622 entry:
620 notice: 623 notice:
621 entry_already_saved: 'Запись была сохранена ранее %date%' 624 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 48e1c34a..b786a73d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'ข้อมูลผู้ใช้' 59 user_info: 'ข้อมูลผู้ใช้'
60 password: 'รหัสผ่าน' 60 password: 'รหัสผ่าน'
61 rules: 'การแท็กข้อบังคับ' 61 rules: 'การแท็กข้อบังคับ'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'เพิ่มผู้ใช้' 63 new_user: 'เพิ่มผู้ใช้'
63 reset: 'รีเซ็ตพื้นที่ ' 64 reset: 'รีเซ็ตพื้นที่ '
64 form: 65 form:
@@ -616,6 +617,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 617 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 618 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 619 # tagging_rules_not_imported: Error while importing tagging rules
620 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
621 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 622 entry:
620 notice: 623 notice:
621 entry_already_saved: 'รายการพร้อมบันทึกที่ %date%' 624 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 19029c0b..a317c2f5 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -59,6 +59,7 @@ config:
59 user_info: 'Kullanıcı bilgileri' 59 user_info: 'Kullanıcı bilgileri'
60 password: 'Şifre' 60 password: 'Şifre'
61 rules: 'Etiketleme kuralları' 61 rules: 'Etiketleme kuralları'
62 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Bir kullanıcı ekle' 63 new_user: 'Bir kullanıcı ekle'
63 # reset: 'Reset area' 64 # reset: 'Reset area'
64 form: 65 form:
@@ -616,6 +617,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 617 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 618 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 619 # tagging_rules_not_imported: Error while importing tagging rules
620 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
621 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 622 entry:
620 notice: 623 notice:
621 entry_already_saved: 'Entry already saved on %date%' 624 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 eb395eac..f182fda4 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 @@
404 </div> 404 </div>
405 </div> 405 </div>
406 406
407 <h2>{{ 'config.tab_menu.ignore_origin'|trans }}</h2>
408
409 <ul>
410 {% for ignore_origin_rule in app.user.config.ignoreOriginRules %}
411 <li>
412 {{ 'config.form_rules.if_label'|trans }}
413 « {{ ignore_origin_rule.rule }} »
414 <a href="{{ path('edit_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="tool mode_edit">✎</a>
415 <a href="{{ path('delete_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="tool delete icon-trash icon"></a>
416 </li>
417 {% endfor %}
418 </ul>
419
420 {{ form_start(form.new_ignore_origin_user_rule) }}
421 {{ form_errors(form.new_ignore_origin_user_rule) }}
422
423 <fieldset class="w500p inline">
424 <div class="row">
425 {{ form_label(form.new_ignore_origin_user_rule.rule) }}
426 {{ form_errors(form.new_ignore_origin_user_rule.rule) }}
427 {{ form_widget(form.new_ignore_origin_user_rule.rule) }}
428 </div>
429 </fieldset>
430
431 {{ form_rest(form.new_ignore_origin_user_rule) }}
432 </form>
433
407 <h2>{{ 'config.reset.title'|trans }}</h2> 434 <h2>{{ 'config.reset.title'|trans }}</h2>
408 <fieldset class="w500p inline"> 435 <fieldset class="w500p inline">
409 <p>{{ 'config.reset.description'|trans }}</p> 436 <p>{{ 'config.reset.description'|trans }}</p>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
index c2e92ad1..faf9a424 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
@@ -16,7 +16,8 @@
16 <li class="tab col s12 m6 l3"><a href="#set3">{{ 'config.tab_menu.user_info'|trans }}</a></li> 16 <li class="tab col s12 m6 l3"><a href="#set3">{{ 'config.tab_menu.user_info'|trans }}</a></li>
17 <li class="tab col s12 m6 l3"><a href="#set4">{{ 'config.tab_menu.password'|trans }}</a></li> 17 <li class="tab col s12 m6 l3"><a href="#set4">{{ 'config.tab_menu.password'|trans }}</a></li>
18 <li class="tab col s12 m6 l3"><a href="#set5">{{ 'config.tab_menu.rules'|trans }}</a></li> 18 <li class="tab col s12 m6 l3"><a href="#set5">{{ 'config.tab_menu.rules'|trans }}</a></li>
19 <li class="tab col s12 m6 l3"><a href="#set6">{{ 'config.tab_menu.reset'|trans }}</a></li> 19 <li class="tab col s12 m6 l3"><a href="#set6">{{ 'config.tab_menu.ignore_origin'|trans }}</a></li>
20 <li class="tab col s12 m6 l3"><a href="#set7">{{ 'config.tab_menu.reset'|trans }}</a></li>
20 </ul> 21 </ul>
21 </div> 22 </div>
22 23
@@ -294,11 +295,11 @@
294 « {{ tagging_rule.rule }} » 295 « {{ tagging_rule.rule }} »
295 {{ 'config.form_rules.then_tag_as_label'|trans }} 296 {{ 'config.form_rules.then_tag_as_label'|trans }}
296 « {{ tagging_rule.tags|join(', ') }} » 297 « {{ tagging_rule.tags|join(', ') }} »
297 <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}"> 298 <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="mode_edit">
298 <i class="tool grey-text mode_edit material-icons">mode_edit</i> 299 <i class="tool grey-text material-icons">mode_edit</i>
299 </a> 300 </a>
300 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}"> 301 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="delete">
301 <i class="tool grey-text delete material-icons">delete</i> 302 <i class="tool grey-text material-icons">delete</i>
302 </a> 303 </a>
303 </li> 304 </li>
304 {% endfor %} 305 {% endfor %}
@@ -466,6 +467,44 @@
466 </div> 467 </div>
467 468
468 <div id="set6" class="col s12"> 469 <div id="set6" class="col s12">
470 {% if app.user.config.ignoreOriginRules is not empty %}
471 <div class="row">
472 <div class="input-field col s12">
473 <ul>
474 {% for ignore_origin_rule in app.user.config.ignoreOriginRules %}
475 <li>
476 {{ 'config.form_rules.if_label'|trans }}
477 « {{ ignore_origin_rule.rule }} »
478 <a href="{{ path('edit_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="mode_edit">
479 <i class="tool grey-text material-icons">mode_edit</i>
480 </a>
481 <a href="{{ path('delete_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="delete">
482 <i class="tool grey-text material-icons">delete</i>
483 </a>
484 </li>
485 {% endfor %}
486 </ul>
487 </div>
488 </div>
489 {% endif %}
490
491 {{ form_start(form.new_ignore_origin_user_rule) }}
492 {{ form_errors(form.new_ignore_origin_user_rule) }}
493
494 <div class="row">
495 <div class="input-field col s12">
496 {{ form_label(form.new_ignore_origin_user_rule.rule) }}
497 {{ form_errors(form.new_ignore_origin_user_rule.rule) }}
498 {{ form_widget(form.new_ignore_origin_user_rule.rule) }}
499 </div>
500 </div>
501
502 {{ form_widget(form.new_ignore_origin_user_rule.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
503 {{ form_rest(form.new_ignore_origin_user_rule) }}
504 </form>
505 </div>
506
507 <div id="set7" class="col s12">
469 <div class="row"> 508 <div class="row">
470 <h5>{{ 'config.reset.title'|trans }}</h5> 509 <h5>{{ 'config.reset.title'|trans }}</h5>
471 <p>{{ 'config.reset.description'|trans }}</p> 510 <p>{{ 'config.reset.description'|trans }}</p>
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index b3b3a19a..40a1aa97 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -435,7 +435,6 @@ class ConfigControllerTest extends WallabagCoreTestCase
435 public function testTaggingRuleCreation() 435 public function testTaggingRuleCreation()
436 { 436 {
437 $this->logInAs('admin'); 437 $this->logInAs('admin');
438 $this->useTheme('baggy');
439 $client = $this->getClient(); 438 $client = $this->getClient();
440 439
441 $crawler = $client->request('GET', '/config'); 440 $crawler = $client->request('GET', '/config');
@@ -457,7 +456,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
457 456
458 $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]); 457 $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]);
459 458
460 $editLink = $crawler->filter('.mode_edit')->last()->link(); 459 $editLink = $crawler->filter('div[id=set5] a.mode_edit')->last()->link();
461 460
462 $crawler = $client->click($editLink); 461 $crawler = $client->click($editLink);
463 $this->assertSame(302, $client->getResponse()->getStatusCode()); 462 $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -482,7 +481,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
482 481
483 $this->assertContains('readingTime <= 30', $crawler->filter('body')->extract(['_text'])[0]); 482 $this->assertContains('readingTime <= 30', $crawler->filter('body')->extract(['_text'])[0]);
484 483
485 $deleteLink = $crawler->filter('.delete')->last()->link(); 484 $deleteLink = $crawler->filter('div[id=set5] a.delete')->last()->link();
486 485
487 $crawler = $client->click($deleteLink); 486 $crawler = $client->click($deleteLink);
488 $this->assertSame(302, $client->getResponse()->getStatusCode()); 487 $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -574,11 +573,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
574 ->getRepository('WallabagCoreBundle:TaggingRule') 573 ->getRepository('WallabagCoreBundle:TaggingRule')
575 ->findAll()[0]; 574 ->findAll()[0];
576 575
577 $crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId()); 576 $crawler = $client->request('GET', '/tagging-rule/delete/' . $rule->getId());
578 577
579 $this->assertSame(403, $client->getResponse()->getStatusCode()); 578 $this->assertSame(403, $client->getResponse()->getStatusCode());
580 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 579 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
581 $this->assertContains('You can not access this tagging rule', $body[0]); 580 $this->assertContains('You can not access this rule', $body[0]);
582 } 581 }
583 582
584 public function testEditingTaggingRuleFromAnOtherUser() 583 public function testEditingTaggingRuleFromAnOtherUser()
@@ -594,7 +593,144 @@ class ConfigControllerTest extends WallabagCoreTestCase
594 593
595 $this->assertSame(403, $client->getResponse()->getStatusCode()); 594 $this->assertSame(403, $client->getResponse()->getStatusCode());
596 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 595 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
597 $this->assertContains('You can not access this tagging rule', $body[0]); 596 $this->assertContains('You can not access this rule', $body[0]);
597 }
598
599 public function testIgnoreOriginRuleCreation()
600 {
601 $this->logInAs('admin');
602 $client = $this->getClient();
603
604 $crawler = $client->request('GET', '/config');
605
606 $this->assertSame(200, $client->getResponse()->getStatusCode());
607
608 $form = $crawler->filter('button[id=ignore_origin_user_rule_save]')->form();
609
610 $data = [
611 'ignore_origin_user_rule[rule]' => 'host = "example.com"',
612 ];
613
614 $client->submit($form, $data);
615
616 $this->assertSame(302, $client->getResponse()->getStatusCode());
617
618 $crawler = $client->followRedirect();
619
620 $this->assertContains('flashes.config.notice.ignore_origin_rules_updated', $crawler->filter('body')->extract(['_text'])[0]);
621
622 $editLink = $crawler->filter('div[id=set6] a.mode_edit')->last()->link();
623
624 $crawler = $client->click($editLink);
625 $this->assertSame(302, $client->getResponse()->getStatusCode());
626 $this->assertContains('?ignore-origin-user-rule=', $client->getResponse()->headers->get('location'));
627
628 $crawler = $client->followRedirect();
629
630 $form = $crawler->filter('button[id=ignore_origin_user_rule_save]')->form();
631
632 $data = [
633 'ignore_origin_user_rule[rule]' => 'host = "example.org"',
634 ];
635
636 $client->submit($form, $data);
637
638 $this->assertSame(302, $client->getResponse()->getStatusCode());
639
640 $crawler = $client->followRedirect();
641
642 $this->assertContains('flashes.config.notice.ignore_origin_rules_updated', $crawler->filter('body')->extract(['_text'])[0]);
643
644 $this->assertContains('host = "example.org"', $crawler->filter('body')->extract(['_text'])[0]);
645
646 $deleteLink = $crawler->filter('div[id=set6] a.delete')->last()->link();
647
648 $crawler = $client->click($deleteLink);
649 $this->assertSame(302, $client->getResponse()->getStatusCode());
650
651 $crawler = $client->followRedirect();
652 $this->assertContains('flashes.config.notice.ignore_origin_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]);
653 }
654
655 public function dataForIgnoreOriginRuleCreationFail()
656 {
657 return [
658 [
659 [
660 'ignore_origin_user_rule[rule]' => 'foo = "bar"',
661 ],
662 [
663 'The variable',
664 'does not exist.',
665 ],
666 ],
667 [
668 [
669 'ignore_origin_user_rule[rule]' => '_all != "none"',
670 ],
671 [
672 'The operator',
673 'does not exist.',
674 ],
675 ],
676 ];
677 }
678
679 /**
680 * @dataProvider dataForIgnoreOriginRuleCreationFail
681 */
682 public function testIgnoreOriginRuleCreationFail($data, $messages)
683 {
684 $this->logInAs('admin');
685 $client = $this->getClient();
686
687 $crawler = $client->request('GET', '/config');
688
689 $this->assertSame(200, $client->getResponse()->getStatusCode());
690
691 $form = $crawler->filter('button[id=ignore_origin_user_rule_save]')->form();
692
693 $crawler = $client->submit($form, $data);
694
695 $this->assertSame(200, $client->getResponse()->getStatusCode());
696
697 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
698
699 foreach ($messages as $message) {
700 $this->assertContains($message, $body[0]);
701 }
702 }
703
704 public function testDeletingIgnoreOriginRuleFromAnOtherUser()
705 {
706 $this->logInAs('bob');
707 $client = $this->getClient();
708
709 $rule = $client->getContainer()->get('doctrine.orm.entity_manager')
710 ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
711 ->findAll()[0];
712
713 $crawler = $client->request('GET', '/ignore-origin-user-rule/edit/' . $rule->getId());
714
715 $this->assertSame(403, $client->getResponse()->getStatusCode());
716 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
717 $this->assertContains('You can not access this rule', $body[0]);
718 }
719
720 public function testEditingIgnoreOriginRuleFromAnOtherUser()
721 {
722 $this->logInAs('bob');
723 $client = $this->getClient();
724
725 $rule = $client->getContainer()->get('doctrine.orm.entity_manager')
726 ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
727 ->findAll()[0];
728
729 $crawler = $client->request('GET', '/ignore-origin-user-rule/edit/' . $rule->getId());
730
731 $this->assertSame(403, $client->getResponse()->getStatusCode());
732 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
733 $this->assertContains('You can not access this rule', $body[0]);
598 } 734 }
599 735
600 public function testDemoMode() 736 public function testDemoMode()