From f267a5568eb9577daa17d7766134cec541443fa4 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 3 Feb 2014 22:00:07 +0100 Subject: [PATCH 1/5] Fix latest merge --- .../Tests/Phrasea/Command/Plugin/RemovePluginTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Alchemy/Tests/Phrasea/Command/Plugin/RemovePluginTest.php b/tests/Alchemy/Tests/Phrasea/Command/Plugin/RemovePluginTest.php index ccc6e5f638..e9ad2541dd 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Plugin/RemovePluginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Plugin/RemovePluginTest.php @@ -76,6 +76,15 @@ class RemovePluginTest extends PluginCommandTestCase $command = new RemovePlugin(); $command->setContainer(self::$DI['cli']); + self::$DI['cli']['plugins.manager'] = $this->getMockBuilder('Alchemy\Phrasea\Plugin\PluginManager') + ->disableOriginalConstructor() + ->getMock(); + + self::$DI['cli']['plugins.manager']->expects($this->once()) + ->method('hasPlugin') + ->with('test-plugin') + ->will($this->returnValue(true)); + $data = $this->addPluginData(); self::$DI['cli']['filesystem'] = $this->createFilesystemMock(); From ef781c43c8f3b055c38a2a14593c6bdb2650953b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 3 Feb 2014 16:44:02 +0100 Subject: [PATCH 2/5] Avoid exception driven filters --- lib/Alchemy/Phrasea/Controller/Root/Login.php | 44 ++++++++++++++----- lib/Alchemy/Phrasea/Security/Firewall.php | 7 +-- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index aee69adcbc..ddf6afb362 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -101,7 +101,9 @@ class Login implements ControllerProviderInterface // Displays the homepage $controllers->get('/', 'login.controller:login') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } if (null !== $request->query->get('postlog')) { @@ -126,14 +128,18 @@ class Login implements ControllerProviderInterface // Authentication end point $controllers->post('/authenticate/', 'login.controller:authenticate') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } }) ->bind('login_authenticate'); // Guest access end point $controllers->match('/authenticate/guest/', 'login.controller:authenticateAsGuest') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } }) ->bind('login_authenticate_as_guest') ->method('GET|POST'); @@ -141,14 +147,18 @@ class Login implements ControllerProviderInterface // Authenticate with an AuthProvider $controllers->get('/provider/{providerId}/authenticate/', 'login.controller:authenticateWithProvider') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } }) ->bind('login_authentication_provider_authenticate'); // AuthProviders callbacks $controllers->get('/provider/{providerId}/callback/', 'login.controller:authenticationCallback') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } })->bind('login_authentication_provider_callback'); // Logout end point @@ -160,13 +170,17 @@ class Login implements ControllerProviderInterface // Registration end point ; redirects to classic registration or AuthProvider registration $controllers->get('/register/', 'login.controller:displayRegisterForm') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } })->bind('login_register'); // Classic registration end point $controllers->match('/register-classic/', 'login.controller:doRegistration') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } }) ->bind('login_register_classic'); @@ -178,25 +192,33 @@ class Login implements ControllerProviderInterface // Unlocks an email address that is currently locked $controllers->get('/register-confirm/', 'login.controller:registerConfirm') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } })->bind('login_register_confirm'); // Displays a form to send an account unlock email again $controllers->get('/send-mail-confirm/', 'login.controller:sendConfirmMail') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } })->bind('login_send_mail'); // Forgot password end point $controllers->match('/forgot-password/', 'login.controller:forgotPassword') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } })->bind('login_forgot_password'); // Renew password end point $controllers->match('/renew-password/', 'login.controller:renewPassword') ->before(function (Request $request) use ($app) { - $app['firewall']->requireNotAuthenticated(); + if (null !== $response = $app['firewall']->requireNotAuthenticated()) { + return $response; + } })->bind('login_renew_password'); // Displays Terms of use diff --git a/lib/Alchemy/Phrasea/Security/Firewall.php b/lib/Alchemy/Phrasea/Security/Firewall.php index ab9307d968..793e8fa555 100644 --- a/lib/Alchemy/Phrasea/Security/Firewall.php +++ b/lib/Alchemy/Phrasea/Security/Firewall.php @@ -3,6 +3,7 @@ namespace Alchemy\Phrasea\Security; use Silex\Application; +use Symfony\Component\HttpFoundation\RedirectResponse; class Firewall { @@ -126,12 +127,8 @@ class Firewall public function requireNotAuthenticated() { if ($this->app['authentication']->isAuthenticated()) { - $this->app->abort(302, 'You are authenticated', array( - 'X-Phraseanet-Redirect' => $this->app->path('prod') - )); + return new RedirectResponse($this->app->path('prod')); } - - return $this; } public function requireOrdersAdmin() From 6159b357ae62d2ea1ddd6d7ee8a5c585652885ab Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 3 Feb 2014 16:54:43 +0100 Subject: [PATCH 3/5] Fix less bootstrap path variables --- www/skins/account/variables.less | 4 ++-- www/skins/login/less/variables.less | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/www/skins/account/variables.less b/www/skins/account/variables.less index 976e2cadd5..8aef114aa3 100644 --- a/www/skins/account/variables.less +++ b/www/skins/account/variables.less @@ -190,8 +190,8 @@ // Sprite icons path // ------------------------- -@iconSpritePath: "../img/glyphicons-halflings.png"; -@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png"; +@iconSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings.png"; +@iconWhiteSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings-white.png"; // Input placeholder text color diff --git a/www/skins/login/less/variables.less b/www/skins/login/less/variables.less index b5dd5d2619..6c31428a04 100644 --- a/www/skins/login/less/variables.less +++ b/www/skins/login/less/variables.less @@ -194,8 +194,8 @@ // Sprite icons path // ------------------------- -@iconSpritePath: "../img/glyphicons-halflings.png"; -@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png"; +@iconSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings.png"; +@iconWhiteSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings-white.png"; // Input placeholder text color From 4fdadfa83693afcb7c69555411270cc5da530f31 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 3 Feb 2014 17:58:03 +0100 Subject: [PATCH 4/5] Fix #1681 : Avoid basket tooltip overflow --- templates/web/prod/Tooltip/Basket.html.twig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/web/prod/Tooltip/Basket.html.twig b/templates/web/prod/Tooltip/Basket.html.twig index c50c8c470f..4027629676 100644 --- a/templates/web/prod/Tooltip/Basket.html.twig +++ b/templates/web/prod/Tooltip/Basket.html.twig @@ -3,12 +3,12 @@ {% extends 'prod/Tooltip/Tooltip.html.twig'%} {% set title %} {{ basket.getName() }} {% endset %} -{% set width = 300 %} +{% set width = 500 %} {% set maxwidth = null %} {% block content %} -
-
+
+
{{ basket.getDescription()|nl2br }}
@@ -19,9 +19,9 @@ {% endtrans %} - {{ date }}
-
+
{% for element in basket.getElements() %} - {% if loop.index <= 9 %} + {% if loop.index <= 10 %}
{{ thumbnail.format(element.getRecord(app).get_thumbnail(), 80, 80 , '', false, false) }}
From eafb632557f26e08dfce2bf86493d0616b0799dc Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 4 Feb 2014 11:21:04 +0100 Subject: [PATCH 5/5] Enhance exception message --- lib/classes/collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/collection.php b/lib/classes/collection.php index 8ca6200eb1..ed99d9d45b 100644 --- a/lib/classes/collection.php +++ b/lib/classes/collection.php @@ -436,7 +436,7 @@ class collection implements cache_cacheableInterface $coll_id = phrasea::collFromBas($app, $base_id); $sbas_id = phrasea::sbasFromBas($app, $base_id); if (! $sbas_id || ! $coll_id) { - throw new Exception_Databox_CollectionNotFound(sprintf("Collection could not be found")); + throw new Exception_Databox_CollectionNotFound(sprintf("Collection with base_id %s could not be found", $base_id)); } $databox = $app['phraseanet.appbox']->get_databox($sbas_id);