]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Change share entry behavior
authorNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 23 Aug 2016 14:49:12 +0000 (16:49 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 23 Aug 2016 14:49:21 +0000 (16:49 +0200)
17 files changed:
app/DoctrineMigrations/Version20160410190541.php
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
var/SymfonyRequirements.php

index f35f54cebd4573b14c9748db7b67c9fc396571a5..77c78c54357340099216d2c74a07eb1cae6d9a53 100644 (file)
@@ -28,18 +28,6 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
         $this->addSql('ALTER TABLE `wallabag_entry` ADD `uuid` LONGTEXT DEFAULT NULL');
     }
 
-    public function postUp(Schema $schema)
-    {
-        $em = $this->container->get('doctrine.orm.entity_manager');
-        $repository = $em->getRepository('WallabagCoreBundle:Entry');
-        $entries = $repository->findAll();
-
-        /** @var Entry $entry */
-        foreach ($entries as $entry) {
-            $this->addSql('UPDATE `wallabag_entry` SET `uuid` = "'.uniqid('', true).'" WHERE id = '.$entry->getId());
-        }
-    }
-
     /**
      * @param Schema $schema
      */
index c94b47f0db5e6f05d9926aa8cf09cbf1d4f559ea..e500ad752af6f0af4e30a502542634a2bc5fafca 100644 (file)
@@ -292,8 +292,6 @@ class EntryController extends Controller
     {
         $this->checkUserAction($entry);
 
-        $this->generateEntryUuid($entry);
-
         return $this->render(
             'WallabagCoreBundle:Entry:entry.html.twig',
             ['entry' => $entry]
@@ -437,7 +435,7 @@ class EntryController extends Controller
      */
     private function checkUserAction(Entry $entry)
     {
-        if ($this->getUser()->getId() != $entry->getUser()->getId()) {
+        if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) {
             throw $this->createAccessDeniedException('You can not access this entry.');
         }
     }
@@ -454,12 +452,57 @@ class EntryController extends Controller
         return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
     }
 
+    /**
+     * Get public URL for entry (and generate it if necessary).
+     *
+     * @param Entry $entry
+     *
+     * @Route("/share/{id}", requirements={"id" = "\d+"}, name="share")
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function shareAction(Entry $entry)
+    {
+        $this->checkUserAction($entry);
+
+        if ('' === $entry->getUuid() || null === $entry->getUuid()) {
+            $this->generateEntryUuid($entry);
+        }
+
+        return $this->redirect($this->generateUrl('share_entry', [
+            'uuid' => $entry->getUuid(),
+        ]));
+    }
+
+    /**
+     * Disable public sharing for an entry.
+     *
+     * @param Entry $entry
+     *
+     * @Route("/share/delete/{id}", requirements={"id" = "\d+"}, name="delete_share")
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function deleteShareAction(Entry $entry)
+    {
+        $this->checkUserAction($entry);
+
+        $entry->cleanUuid();
+        $em = $this->getDoctrine()->getManager();
+        $em->persist($entry);
+        $em->flush();
+
+        return $this->redirect($this->generateUrl('view', [
+            'id' => $entry->getId(),
+        ]));
+    }
+
     /**
      * Share entry content.
      *
      * @param Entry $entry
      *
-     * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share")
+     * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry")
      * @Cache(maxage="25200", public=true)
      *
      * @return \Symfony\Component\HttpFoundation\Response
index a629efc763e454fe28172256d3f326363fd44396..8c20cde22e938d9df424d9b2c823540071386a64 100644 (file)
@@ -436,8 +436,6 @@ class Entry
         }
 
         $this->updatedAt = new \DateTime();
-
-        $this->generateUuid();
     }
 
     /**
@@ -634,4 +632,9 @@ class Entry
             $this->uuid = uniqid('', true);
         }
     }
+
+    public function cleanUuid()
+    {
+        $this->uuid = null;
+    }
 }
index 2eb0b7b0a29012d5761017a25770ea7d54465816..f9b7bfacdac8c9a93aeb541527f77eaf1dbb5e94 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Deling'
             # share_email_label: 'Email'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Download'
             # print: 'Print'
             problem:
index 3d4ae9b3219c76b709cd7922c1ee5eb541443e9f..79d03286bdc7e989784168b8dc534fcd0b686cc8 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Teilen'
             share_email_label: 'E-Mail'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Herunterladen'
             print: 'Drucken'
             problem:
index b7a1644607fa7b48de3f96ee655898e5a0e2f6be..d921b39f9579a9cac1123a45dc3f7d96fe8d71ef 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Share'
             share_email_label: 'Email'
             public_link: 'public link'
+            delete_public_link: 'delete public link'
             download: 'Download'
             print: 'Print'
             problem:
index 0e4c0e6eb6b9ba117e9b1ad9902f9b5650d49b56..c2ec4dbd77fae8227a168c2420cde87737d4ae70 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Compartir'
             share_email_label: 'Dirección e-mail'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Descargar'
             print: 'Imprimir'
             problem:
index 3b36f6f2944533b0565e9b8d348ff20ce04050c8..561ed907487675070e5677cbffc0e84780f85100 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'هم‌رسانی'
             share_email_label: 'نشانی ایمیل'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'بارگیری'
             print: 'چاپ'
             problem:
index df7c22716f72f6e238867bcd379463273824e87d..c0671883ab9432c86d85d8a396f7ab226eb1261f 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Partager'
             share_email_label: 'Email'
             public_link: 'Lien public'
+            delete_public_link: 'Supprimer lien public'
             download: 'Télécharger'
             print: 'Imprimer'
             problem:
index 3760c2d64f4d3de3e290a48d87cee085dcbf40b7..2e3dd08b0c82680b706badc54e1d7039367691d1 100644 (file)
@@ -185,6 +185,8 @@ entry:
             add_a_tag: 'Aggiungi un tag'
             share_content: 'Condividi'
             share_email_label: 'E-mail'
+            # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Download'
             print: 'Stampa'
             problem:
index f3bfbd80d4d63f6ab7fd3e80933d9f085a8d7e66..7b978a609eadf0abaccb477ea746e3ace0dc8922 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Partatjar'
             share_email_label: 'Corrièl'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Telecargar'
             print: 'Imprimir'
             problem:
index 93d3e91ff9aa3dc8cb807b7958bab34ebe7309cc..da170e4d64cd50459bdadfebd43842d947a24407 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Udostępnij'
             share_email_label: 'Adres email'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Pobierz'
             print: 'Drukuj'
             problem:
index 3ba1e0787ee9c12021de23dfce0d52552c70bc06..fa2d6468cd8b253c1e6031c5b83c99bbf008d3eb 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Dă mai departe'
             share_email_label: 'E-mail'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'Descarcă'
             # print: 'Print'
             problem:
index f6337caa0dcaa5ef4e2c3cdba846b1febdfe81cd..05c31336fb8d8f204b7ec47e349c53a288cbfac1 100644 (file)
@@ -188,6 +188,7 @@ entry:
             share_content: 'Paylaş'
             share_email_label: 'E-posta'
             # public_link: 'public link'
+            # delete_public_link: 'delete public link'
             download: 'İndir'
             # print: 'Print'
             problem:
index 585e4dd5f091660cbc792c9b25d641b5c7002bdc..05bb378d33aeb0c60f3549051915b239359f4bf9 100644 (file)
                 <ul>
                     {% if craue_setting('share_public') %}
                         <li>
-                            <a href="{{ path('share', {'uuid': entry.uuid }) }}" target="_blank" class="tool public" title="{{ 'entry.view.left_menu.public_link'|trans }}">
+                            <a href="{{ path('share', {'id': entry.id }) }}" target="_blank" class="tool public" title="{{ 'entry.view.left_menu.public_link'|trans }}">
                                 <span>{{ 'entry.view.left_menu.public_link'|trans }}</span>
                             </a>
                         </li>
+                        <li>
+                            <a href="{{ path('delete_share', {'id': entry.id }) }}" class="tool public" title="{{ 'entry.view.left_menu.delete_public_link'|trans }}">
+                                <span>{{ 'entry.view.left_menu.delete_public_link'|trans }}</span>
+                            </a>
+                        </li>
                     {% endif %}
                     {% if craue_setting('share_twitter') %}
                         <li>
index c0133af4ab6cb7260dade5ca34f03dc9dacf5352..07ff2772e05d4b7f50255975f3d44f4347c8065f 100644 (file)
@@ -33,7 +33,7 @@ class InstallCommandTest extends WallabagCoreTestCase
     }
 
     /**
-     * Ensure next tests will have a clean database
+     * Ensure next tests will have a clean database.
      */
     public static function tearDownAfterClass()
     {
index 841338f443bebd1c6ef1fb9490fc05fa00d81800..0a5de5461b46d31fd1006244bb33c235676efc29 100644 (file)
@@ -681,10 +681,17 @@ class SymfonyRequirements extends RequirementCollection
 
             if (class_exists('Symfony\Component\Intl\Intl')) {
                 $this->addRecommendation(
-                    \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(),
-                    sprintf('intl ICU version installed on your system (%s) should match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()),
-                    'In most cases you should be fine, but please verify there is no inconsistencies between data provided by Symfony and the intl extension. See https://github.com/symfony/symfony/issues/15007 for an example of inconsistencies you might run into.'
+                    \Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion(),
+                    sprintf('intl ICU version installed on your system is outdated (%s) and does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()),
+                    'To get the latest internationalization data upgrade the ICU system package and the intl PHP extension.'
                 );
+                if (\Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion()) {
+                    $this->addRecommendation(
+                        \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(),
+                        sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()),
+                        'To avoid internationalization data incosistencies upgrade the symfony/intl component.'
+                    );
+                }
             }
 
             $this->addPhpIniRecommendation(