mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-22 23:56:29 +00:00
Change share entry behavior
This commit is contained in:
parent
3377c938f8
commit
f1be7af446
17 changed files with 81 additions and 23 deletions
|
@ -28,18 +28,6 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
|
||||||
$this->addSql('ALTER TABLE `wallabag_entry` ADD `uuid` LONGTEXT DEFAULT NULL');
|
$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
|
* @param Schema $schema
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -292,8 +292,6 @@ class EntryController extends Controller
|
||||||
{
|
{
|
||||||
$this->checkUserAction($entry);
|
$this->checkUserAction($entry);
|
||||||
|
|
||||||
$this->generateEntryUuid($entry);
|
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'WallabagCoreBundle:Entry:entry.html.twig',
|
'WallabagCoreBundle:Entry:entry.html.twig',
|
||||||
['entry' => $entry]
|
['entry' => $entry]
|
||||||
|
@ -437,7 +435,7 @@ class EntryController extends Controller
|
||||||
*/
|
*/
|
||||||
private function checkUserAction(Entry $entry)
|
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.');
|
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());
|
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.
|
* Share entry content.
|
||||||
*
|
*
|
||||||
* @param Entry $entry
|
* @param Entry $entry
|
||||||
*
|
*
|
||||||
* @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share")
|
* @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry")
|
||||||
* @Cache(maxage="25200", public=true)
|
* @Cache(maxage="25200", public=true)
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
|
|
@ -436,8 +436,6 @@ class Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updatedAt = new \DateTime();
|
$this->updatedAt = new \DateTime();
|
||||||
|
|
||||||
$this->generateUuid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -634,4 +632,9 @@ class Entry
|
||||||
$this->uuid = uniqid('', true);
|
$this->uuid = uniqid('', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cleanUuid()
|
||||||
|
{
|
||||||
|
$this->uuid = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Deling'
|
share_content: 'Deling'
|
||||||
# share_email_label: 'Email'
|
# share_email_label: 'Email'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Download'
|
download: 'Download'
|
||||||
# print: 'Print'
|
# print: 'Print'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Teilen'
|
share_content: 'Teilen'
|
||||||
share_email_label: 'E-Mail'
|
share_email_label: 'E-Mail'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Herunterladen'
|
download: 'Herunterladen'
|
||||||
print: 'Drucken'
|
print: 'Drucken'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Share'
|
share_content: 'Share'
|
||||||
share_email_label: 'Email'
|
share_email_label: 'Email'
|
||||||
public_link: 'public link'
|
public_link: 'public link'
|
||||||
|
delete_public_link: 'delete public link'
|
||||||
download: 'Download'
|
download: 'Download'
|
||||||
print: 'Print'
|
print: 'Print'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Compartir'
|
share_content: 'Compartir'
|
||||||
share_email_label: 'Dirección e-mail'
|
share_email_label: 'Dirección e-mail'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Descargar'
|
download: 'Descargar'
|
||||||
print: 'Imprimir'
|
print: 'Imprimir'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'همرسانی'
|
share_content: 'همرسانی'
|
||||||
share_email_label: 'نشانی ایمیل'
|
share_email_label: 'نشانی ایمیل'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'بارگیری'
|
download: 'بارگیری'
|
||||||
print: 'چاپ'
|
print: 'چاپ'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Partager'
|
share_content: 'Partager'
|
||||||
share_email_label: 'Email'
|
share_email_label: 'Email'
|
||||||
public_link: 'Lien public'
|
public_link: 'Lien public'
|
||||||
|
delete_public_link: 'Supprimer lien public'
|
||||||
download: 'Télécharger'
|
download: 'Télécharger'
|
||||||
print: 'Imprimer'
|
print: 'Imprimer'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -185,6 +185,8 @@ entry:
|
||||||
add_a_tag: 'Aggiungi un tag'
|
add_a_tag: 'Aggiungi un tag'
|
||||||
share_content: 'Condividi'
|
share_content: 'Condividi'
|
||||||
share_email_label: 'E-mail'
|
share_email_label: 'E-mail'
|
||||||
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Download'
|
download: 'Download'
|
||||||
print: 'Stampa'
|
print: 'Stampa'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Partatjar'
|
share_content: 'Partatjar'
|
||||||
share_email_label: 'Corrièl'
|
share_email_label: 'Corrièl'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Telecargar'
|
download: 'Telecargar'
|
||||||
print: 'Imprimir'
|
print: 'Imprimir'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Udostępnij'
|
share_content: 'Udostępnij'
|
||||||
share_email_label: 'Adres email'
|
share_email_label: 'Adres email'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Pobierz'
|
download: 'Pobierz'
|
||||||
print: 'Drukuj'
|
print: 'Drukuj'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Dă mai departe'
|
share_content: 'Dă mai departe'
|
||||||
share_email_label: 'E-mail'
|
share_email_label: 'E-mail'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'Descarcă'
|
download: 'Descarcă'
|
||||||
# print: 'Print'
|
# print: 'Print'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -188,6 +188,7 @@ entry:
|
||||||
share_content: 'Paylaş'
|
share_content: 'Paylaş'
|
||||||
share_email_label: 'E-posta'
|
share_email_label: 'E-posta'
|
||||||
# public_link: 'public link'
|
# public_link: 'public link'
|
||||||
|
# delete_public_link: 'delete public link'
|
||||||
download: 'İndir'
|
download: 'İndir'
|
||||||
# print: 'Print'
|
# print: 'Print'
|
||||||
problem:
|
problem:
|
||||||
|
|
|
@ -101,10 +101,15 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% if craue_setting('share_public') %}
|
{% if craue_setting('share_public') %}
|
||||||
<li>
|
<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>
|
<span>{{ 'entry.view.left_menu.public_link'|trans }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</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 %}
|
{% endif %}
|
||||||
{% if craue_setting('share_twitter') %}
|
{% if craue_setting('share_twitter') %}
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -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()
|
public static function tearDownAfterClass()
|
||||||
{
|
{
|
||||||
|
|
|
@ -681,10 +681,17 @@ class SymfonyRequirements extends RequirementCollection
|
||||||
|
|
||||||
if (class_exists('Symfony\Component\Intl\Intl')) {
|
if (class_exists('Symfony\Component\Intl\Intl')) {
|
||||||
$this->addRecommendation(
|
$this->addRecommendation(
|
||||||
\Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(),
|
\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()),
|
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()),
|
||||||
'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.'
|
'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(
|
$this->addPhpIniRecommendation(
|
||||||
|
|
Loading…
Reference in a new issue