aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-08-23 16:49:12 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-08-23 16:49:21 +0200
commitf1be7af446052c6fed7033664c6c6350f558961b (patch)
tree41889e7ace01b1f1df05ffb412bac0427d9975a2 /src/Wallabag/CoreBundle/Controller
parent3377c938f8e5bd6af2cd4430494f39a517a7e910 (diff)
downloadwallabag-f1be7af446052c6fed7033664c6c6350f558961b.tar.gz
wallabag-f1be7af446052c6fed7033664c6c6350f558961b.tar.zst
wallabag-f1be7af446052c6fed7033664c6c6350f558961b.zip
Change share entry behavior
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index c94b47f0..e500ad75 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -292,8 +292,6 @@ class EntryController extends Controller
292 { 292 {
293 $this->checkUserAction($entry); 293 $this->checkUserAction($entry);
294 294
295 $this->generateEntryUuid($entry);
296
297 return $this->render( 295 return $this->render(
298 'WallabagCoreBundle:Entry:entry.html.twig', 296 'WallabagCoreBundle:Entry:entry.html.twig',
299 ['entry' => $entry] 297 ['entry' => $entry]
@@ -437,7 +435,7 @@ class EntryController extends Controller
437 */ 435 */
438 private function checkUserAction(Entry $entry) 436 private function checkUserAction(Entry $entry)
439 { 437 {
440 if ($this->getUser()->getId() != $entry->getUser()->getId()) { 438 if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) {
441 throw $this->createAccessDeniedException('You can not access this entry.'); 439 throw $this->createAccessDeniedException('You can not access this entry.');
442 } 440 }
443 } 441 }
@@ -455,11 +453,56 @@ class EntryController extends Controller
455 } 453 }
456 454
457 /** 455 /**
456 * Get public URL for entry (and generate it if necessary).
457 *
458 * @param Entry $entry
459 *
460 * @Route("/share/{id}", requirements={"id" = "\d+"}, name="share")
461 *
462 * @return \Symfony\Component\HttpFoundation\Response
463 */
464 public function shareAction(Entry $entry)
465 {
466 $this->checkUserAction($entry);
467
468 if ('' === $entry->getUuid() || null === $entry->getUuid()) {
469 $this->generateEntryUuid($entry);
470 }
471
472 return $this->redirect($this->generateUrl('share_entry', [
473 'uuid' => $entry->getUuid(),
474 ]));
475 }
476
477 /**
478 * Disable public sharing for an entry.
479 *
480 * @param Entry $entry
481 *
482 * @Route("/share/delete/{id}", requirements={"id" = "\d+"}, name="delete_share")
483 *
484 * @return \Symfony\Component\HttpFoundation\Response
485 */
486 public function deleteShareAction(Entry $entry)
487 {
488 $this->checkUserAction($entry);
489
490 $entry->cleanUuid();
491 $em = $this->getDoctrine()->getManager();
492 $em->persist($entry);
493 $em->flush();
494
495 return $this->redirect($this->generateUrl('view', [
496 'id' => $entry->getId(),
497 ]));
498 }
499
500 /**
458 * Share entry content. 501 * Share entry content.
459 * 502 *
460 * @param Entry $entry 503 * @param Entry $entry
461 * 504 *
462 * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share") 505 * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry")
463 * @Cache(maxage="25200", public=true) 506 * @Cache(maxage="25200", public=true)
464 * 507 *
465 * @return \Symfony\Component\HttpFoundation\Response 508 * @return \Symfony\Component\HttpFoundation\Response