aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
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