X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FConfigController.php;h=28e33998d12a63f82cf688f3f7c3c5dbedc4181b;hb=bf3dc999e7b25888460faff2251f75e4a79491c4;hp=75a9af0b5c1f6bb5259f317b84e92f99f01bfaba;hpb=c4bf7af96f52aaafd13049e74f27b368eec79bf8;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 75a9af0b..28e33998 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -108,7 +108,21 @@ class ConfigController extends Controller // handle tagging rule $taggingRule = new TaggingRule(); - $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']); + $action = $this->generateUrl('config').'#set5'; + + if ($request->query->has('tagging-rule')) { + $taggingRule = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:TaggingRule') + ->find($request->query->get('tagging-rule')); + + if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) { + return $this->redirect($action); + } + + $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5'; + } + + $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]); $newTaggingRule->handleRequest($request); if ($newTaggingRule->isValid()) { @@ -221,6 +235,24 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config').'#set5'); } + /** + * Edit a tagging rule. + * + * @param TaggingRule $rule + * + * @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule") + * + * @return RedirectResponse + */ + public function editTaggingRuleAction(TaggingRule $rule) + { + if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { + throw $this->createAccessDeniedException('You can not access this tagging rule.'); + } + + return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5'); + } + /** * Retrieve config for the current user. * If no config were found, create a new one.