aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
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
parent3377c938f8e5bd6af2cd4430494f39a517a7e910 (diff)
downloadwallabag-f1be7af446052c6fed7033664c6c6350f558961b.tar.gz
wallabag-f1be7af446052c6fed7033664c6c6350f558961b.tar.zst
wallabag-f1be7af446052c6fed7033664c6c6350f558961b.zip
Change share entry behavior
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php51
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php7
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig7
14 files changed, 70 insertions, 7 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
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index a629efc7..8c20cde2 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -436,8 +436,6 @@ class Entry
436 } 436 }
437 437
438 $this->updatedAt = new \DateTime(); 438 $this->updatedAt = new \DateTime();
439
440 $this->generateUuid();
441 } 439 }
442 440
443 /** 441 /**
@@ -634,4 +632,9 @@ class Entry
634 $this->uuid = uniqid('', true); 632 $this->uuid = uniqid('', true);
635 } 633 }
636 } 634 }
635
636 public function cleanUuid()
637 {
638 $this->uuid = null;
639 }
637} 640}
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 2eb0b7b0..f9b7bfac 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Deling' 188 share_content: 'Deling'
189 # share_email_label: 'Email' 189 # share_email_label: 'Email'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'Download' 192 download: 'Download'
192 # print: 'Print' 193 # print: 'Print'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 3d4ae9b3..79d03286 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Teilen' 188 share_content: 'Teilen'
189 share_email_label: 'E-Mail' 189 share_email_label: 'E-Mail'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'Herunterladen' 192 download: 'Herunterladen'
192 print: 'Drucken' 193 print: 'Drucken'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index b7a16446..d921b39f 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Share' 188 share_content: 'Share'
189 share_email_label: 'Email' 189 share_email_label: 'Email'
190 public_link: 'public link' 190 public_link: 'public link'
191 delete_public_link: 'delete public link'
191 download: 'Download' 192 download: 'Download'
192 print: 'Print' 193 print: 'Print'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index 0e4c0e6e..c2ec4dbd 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Compartir' 188 share_content: 'Compartir'
189 share_email_label: 'Dirección e-mail' 189 share_email_label: 'Dirección e-mail'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'Descargar' 192 download: 'Descargar'
192 print: 'Imprimir' 193 print: 'Imprimir'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 3b36f6f2..561ed907 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'هم‌رسانی' 188 share_content: 'هم‌رسانی'
189 share_email_label: 'نشانی ایمیل' 189 share_email_label: 'نشانی ایمیل'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'بارگیری' 192 download: 'بارگیری'
192 print: 'چاپ' 193 print: 'چاپ'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index df7c2271..c0671883 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Partager' 188 share_content: 'Partager'
189 share_email_label: 'Email' 189 share_email_label: 'Email'
190 public_link: 'Lien public' 190 public_link: 'Lien public'
191 delete_public_link: 'Supprimer lien public'
191 download: 'Télécharger' 192 download: 'Télécharger'
192 print: 'Imprimer' 193 print: 'Imprimer'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 3760c2d6..2e3dd08b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -185,6 +185,8 @@ entry:
185 add_a_tag: 'Aggiungi un tag' 185 add_a_tag: 'Aggiungi un tag'
186 share_content: 'Condividi' 186 share_content: 'Condividi'
187 share_email_label: 'E-mail' 187 share_email_label: 'E-mail'
188 # public_link: 'public link'
189 # delete_public_link: 'delete public link'
188 download: 'Download' 190 download: 'Download'
189 print: 'Stampa' 191 print: 'Stampa'
190 problem: 192 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index f3bfbd80..7b978a60 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Partatjar' 188 share_content: 'Partatjar'
189 share_email_label: 'Corrièl' 189 share_email_label: 'Corrièl'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'Telecargar' 192 download: 'Telecargar'
192 print: 'Imprimir' 193 print: 'Imprimir'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 93d3e91f..da170e4d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Udostępnij' 188 share_content: 'Udostępnij'
189 share_email_label: 'Adres email' 189 share_email_label: 'Adres email'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'Pobierz' 192 download: 'Pobierz'
192 print: 'Drukuj' 193 print: 'Drukuj'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index 3ba1e078..fa2d6468 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Dă mai departe' 188 share_content: 'Dă mai departe'
189 share_email_label: 'E-mail' 189 share_email_label: 'E-mail'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'Descarcă' 192 download: 'Descarcă'
192 # print: 'Print' 193 # print: 'Print'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index f6337caa..05c31336 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -188,6 +188,7 @@ entry:
188 share_content: 'Paylaş' 188 share_content: 'Paylaş'
189 share_email_label: 'E-posta' 189 share_email_label: 'E-posta'
190 # public_link: 'public link' 190 # public_link: 'public link'
191 # delete_public_link: 'delete public link'
191 download: 'İndir' 192 download: 'İndir'
192 # print: 'Print' 193 # print: 'Print'
193 problem: 194 problem:
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
index 585e4dd5..05bb378d 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
@@ -101,10 +101,15 @@
101 <ul> 101 <ul>
102 {% if craue_setting('share_public') %} 102 {% if craue_setting('share_public') %}
103 <li> 103 <li>
104 <a href="{{ path('share', {'uuid': entry.uuid }) }}" target="_blank" class="tool public" title="{{ 'entry.view.left_menu.public_link'|trans }}"> 104 <a href="{{ path('share', {'id': entry.id }) }}" target="_blank" class="tool public" title="{{ 'entry.view.left_menu.public_link'|trans }}">
105 <span>{{ 'entry.view.left_menu.public_link'|trans }}</span> 105 <span>{{ 'entry.view.left_menu.public_link'|trans }}</span>
106 </a> 106 </a>
107 </li> 107 </li>
108 <li>
109 <a href="{{ path('delete_share', {'id': entry.id }) }}" class="tool public" title="{{ 'entry.view.left_menu.delete_public_link'|trans }}">
110 <span>{{ 'entry.view.left_menu.delete_public_link'|trans }}</span>
111 </a>
112 </li>
108 {% endif %} 113 {% endif %}
109 {% if craue_setting('share_twitter') %} 114 {% if craue_setting('share_twitter') %}
110 <li> 115 <li>