From abc4d815212dff6f9ab04357e25cf73cfc63fd1d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 21 Sep 2012 12:42:32 +0200 Subject: [PATCH] Update controllers --- .../Phrasea/Controller/AbstractDelivery.php | 4 +- .../Phrasea/Controller/Admin/Collection.php | 12 +- .../Controller/Admin/ConnectedUsers.php | 66 +++- .../Phrasea/Controller/Admin/Dashboard.php | 9 +- .../Phrasea/Controller/Admin/Databox.php | 352 +++++++----------- .../Phrasea/Controller/Admin/Databoxes.php | 189 +++++++++- .../Phrasea/Controller/Admin/Publications.php | 4 +- lib/Alchemy/Phrasea/Controller/Admin/Root.php | 12 +- .../Phrasea/Controller/Admin/Setup.php | 8 +- .../Phrasea/Controller/Admin/Sphinx.php | 8 +- .../Phrasea/Controller/Admin/Users.php | 7 +- lib/Alchemy/Phrasea/Controller/Datafiles.php | 4 +- lib/Alchemy/Phrasea/Controller/Permalink.php | 6 +- .../Phrasea/Controller/Prod/Basket.php | 8 + .../Phrasea/Controller/Prod/Bridge.php | 72 +--- lib/Alchemy/Phrasea/Controller/Prod/Edit.php | 17 +- .../Phrasea/Controller/Prod/Printer.php | 4 +- lib/Alchemy/Phrasea/Controller/Prod/Push.php | 6 +- lib/Alchemy/Phrasea/Controller/Prod/Query.php | 10 +- lib/Alchemy/Phrasea/Controller/Prod/Root.php | 26 +- lib/Alchemy/Phrasea/Controller/Prod/TOU.php | 3 +- .../Phrasea/Controller/Prod/Tooltip.php | 9 + .../Controller/Prod/UserPreferences.php | 8 + .../Phrasea/Controller/Prod/WorkZone.php | 8 + .../Phrasea/Controller/Root/Account.php | 52 ++- .../Phrasea/Controller/Root/Developers.php | 4 +- lib/Alchemy/Phrasea/Controller/Root/Login.php | 198 +++++++--- .../Phrasea/Controller/Root/RSSFeeds.php | 19 +- .../Phrasea/Controller/Setup/Installer.php | 14 +- .../Phrasea/Controller/Setup/Upgrader.php | 2 +- templates/web/account/account.html.twig | 2 +- .../web/account/authorized_apps.html.twig | 22 +- templates/web/account/sessions.html.twig | 28 +- templates/web/admin/users.html.twig | 2 +- .../web/developers/application.html.twig | 20 +- .../web/developers/applications.html.twig | 14 +- .../Phrasea/Controller/Admin/DataboxTest.php | 148 -------- .../Controller/Admin/DataboxesTest.php | 95 +++++ .../Controller/Admin/PublicationTest.php | 23 +- .../Phrasea/Controller/Root/LoginTest.php | 18 +- .../Phrasea/Controller/Root/RSSFeedTest.php | 21 +- 41 files changed, 910 insertions(+), 624 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php b/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php index 8de1c25f7b..a4d4e6c01a 100644 --- a/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php +++ b/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php @@ -24,7 +24,7 @@ use Symfony\Component\HttpFoundation\Response; abstract class AbstractDelivery implements ControllerProviderInterface { - public function deliverContent(Request $request, \Session_Handler $session, \record_adapter $record, $subdef, $watermark, $stamp, Application $app) + public function deliverContent(Request $request, \record_adapter $record, $subdef, $watermark, $stamp, Application $app) { $file = $record->get_subdef($subdef); @@ -39,7 +39,7 @@ abstract class AbstractDelivery implements ControllerProviderInterface $log_id = null; try { $registry = $app['phraseanet.registry']; - $logger = $session->get_logger($record->get_databox()); + $logger = $app['phraseanet.logger']($record->get_databox()); $log_id = $logger->get_id(); $referrer = 'NO REFERRER'; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index 7e8327cbab..e9d549b1b7 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -31,14 +31,12 @@ class Collection implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - if (null !== $response = $app['firewall']->requireAdmin($app)) { - return $response; - } + $response = $app['firewall']->requireRightOnBase($app['request']->attributes->get('bas_id'), 'canadmin'); - if (!$app['phraseanet.user']->ACL()->has_right_on_base($app['request']->attributes->get('bas_id'), 'canadmin')) { - $app->abort(403); - } - }); + if($response instanceof Response) { + return $response; + } + }); /** * Get a collection diff --git a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php index 5aec202132..5475c26867 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php @@ -28,13 +28,69 @@ class ConnectedUsers implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + + $response = $app['firewall']->requireAccessToModule('Admin'); + + if ($response instanceof Response) { + return $response; + } + }); + + $controllers->get('/', function(Application $app, Request $request) { - return new Response( - $app['twig']->render( - 'admin/connected-users.html.twig', array('datas' => \Session_Handler::get_active_sessions($app) - ) - ) + + + $dql = 'SELECT s FROM Entities\Session s + LEFT JOIN s.modules m + WHERE + s.created > (CURRENT_TIMESTAMP() - 15 * 60) + OR m.created > (CURRENT_TIMESTAMP() - 5 * 60) + ORDER BY s.created DESC'; + + $query = $app['EM']->createQuery($dql); + $sessions = $query->getResult(); + + $ret = array( + 'sessions' => $sessions, + 'applications' => array( + '0' => 0, + '1' => 0, + '2' => 0, + '3' => 0, + '4' => 0, + '5' => 0, + '6' => 0, + '7' => 0, + '8' => 0, + ) ); + + foreach ($sessions as $session) { + foreach ($session->getModules() as $module) { + if (isset($ret['applications'][$module->getModuleId()])) { + $ret['applications'][$module->getModuleId()]++; + } + } + } + + +// $datas = $app['geonames']->find_geoname_from_ip($row['ip']); +// +// if ($datas['city']) { +// $infos = $datas['city'] . ' (' . $datas['country'] . ')'; +// } elseif ($datas['fips']) { +// $infos = $datas['fips'] . ' (' . $datas['country'] . ')'; +// } elseif ($datas['country']) { +// $infos = $datas['country']; +// } else { +// $infos = ''; +// } +// +// $session['ip_infos'] = $infos; + + + return new Response($app['twig']->render('admin/connected-users.html.twig', array('data' => $ret))); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index 0ed754d658..7f19a70064 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -29,8 +29,13 @@ class Dashboard implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - return $app['firewall']->requireAdmin($app); - }); + + $response = $app['firewall']->requireAdmin(); + + if ($response instanceof Response) { + return $response; + } + }); /** * Get admin dashboard diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index f9984af9b3..8f8e8b8698 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -30,26 +30,15 @@ class Databox implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - return $app['firewall']->requireAdmin($app); + + $response = $app['firewall']->requireAccessToModule('admin') + ->requireAccessToSbas($request->attributes->get('databox_id')); + + if ($response instanceof Response) { + return $response; + } }); - - /** - * Create Database - * - * name : admin_database_new - * - * description : Create Database - * - * method : POST - * - * parameters : none - * - * return : Redirect Response - */ - $controllers->post('/', $this->call('createDatabase')) - ->bind('admin_database_new'); - /** * Get admin database * @@ -82,23 +71,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/delete/', $this->call('deleteBase')) ->assert('databox_id', '\d+') - ->bind('admin_database_delete'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); - /** - * Mount a database - * - * name : admin_database_mount - * - * description : Upgrade all databases - * - * method : POST - * - * parameters : none - * - * return : Redirect Response - */ - $controllers->post('/mount/', $this->call('databaseMount')) - ->bind('admin_database_mount'); + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_delete'); /** * Unmount a database @@ -115,7 +94,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/unmount/', $this->call('unmountDatabase')) ->assert('databox_id', '\d+') - ->bind('admin_database_unmount'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_unmount'); /** * Empty a database @@ -132,7 +117,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/empty/', $this->call('emptyDatabase')) ->assert('databox_id', '\d+') - ->bind('admin_database_empty'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_empty'); /** * Reorder database collection @@ -149,7 +140,13 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/collections/order/', $this->call('getReorder')) ->assert('databox_id', '\d+') - ->bind('admin_database_display_collections_order'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_display_collections_order'); /** * Reorder database collection @@ -166,7 +163,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/collections/order/', $this->call('setReorder')) ->assert('databox_id', '\d+') - ->bind('admin_database_submit_collections_order'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_submit_collections_order'); /** * Create new collection @@ -183,7 +186,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/collection/', $this->call('createCollection')) ->assert('databox_id', '\d+') - ->bind('admin_database_submit_collection'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_submit_collection'); /** * Get database CGU @@ -200,7 +209,13 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/cgus/', $this->call('getDatabaseCGU')) ->assert('databox_id', '\d+') - ->bind('admin_database_display_cgus'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_modify_struct'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_display_cgus'); /** * Update database CGU @@ -217,7 +232,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/cgus/', $this->call('updateDatabaseCGU')) ->assert('databox_id', '\d+') - ->bind('admin_database_submit_cgus'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_modify_struct'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_submit_cgus'); /** * Update document information @@ -234,7 +255,13 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/informations/documents/', $this->call('progressBarInfos')) ->assert('databox_id', '\d+') - ->bind('admin_database_display_document_information'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_display_document_information'); /** * Get document details @@ -251,7 +278,13 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/informations/details/', $this->call('getDetails')) ->assert('databox_id', '\d+') - ->bind('admin_database_display_document_details'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_display_document_details'); /** * Mount collection on collection @@ -269,7 +302,13 @@ class Databox implements ControllerProviderInterface $controllers->post('/{databox_id}/collection/{collection_id}/mount/', $this->call('mountCollection')) ->assert('databox_id', '\d+') ->assert('collection_id', '\d+') - ->bind('admin_database_mount_collection'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_mount_collection'); /** * Get a new collection form @@ -286,7 +325,13 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/collection/', $this->call('getNewCollection')) ->assert('databox_id', '\d+') - ->bind('admin_database_display_new_collection_form'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_display_new_collection_form'); /** * Add databox logo @@ -303,7 +348,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/logo/', $this->call('sendLogoPdf')) ->assert('databox_id', '\d+') - ->bind('admin_database_submit_logo'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_submit_logo'); /** * Delete databox logo @@ -320,7 +371,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/logo/delete/', $this->call('deleteLogoPdf')) ->assert('databox_id', '\d+') - ->bind('admin_database_delete_logo'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_delete_logo'); /** * Clear databox logs @@ -337,7 +394,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/clear-logs/', $this->call('clearLogs')) ->assert('databox_id', '\d+') - ->bind('admin_database_clear_logs'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_clear_logs'); /** * Reindex database @@ -354,7 +417,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/reindex/', $this->call('reindex')) ->assert('databox_id', '\d+') - ->bind('admin_database_reindex'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_reindex'); /** * Set database indexable @@ -371,7 +440,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/indexable/', $this->call('setIndexable')) ->assert('databox_id', '\d+') - ->bind('admin_database_set_indexable'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_set_indexable'); /** * Set database name @@ -388,7 +463,13 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/view-name/', $this->call('changeViewName')) ->assert('databox_id', '\d+') - ->bind('admin_database_rename'); + ->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireRightOnSbas($request->attributes->get('databox_id'), 'bas_manage'); + + if ($response instanceof Response) { + return $response; + } + })->bind('admin_database_rename'); return $controllers; } @@ -433,15 +514,10 @@ class Databox implements ControllerProviderInterface */ public function getDatabaseCGU(Application $app, Request $request, $databox_id) { - if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { - $app->abort(403); - } - - return new Response($app['twig']->render('admin/databox/cgus.html.twig', array( 'languages' => $app->getAvailableLanguages(), 'cgus' => $app['phraseanet.appbox']->get_databox($databox_id)->get_cgus(), - 'current_locale' => \Session_Handler::get_locale() + 'current_locale' => $app['locale'] ))); } @@ -529,7 +605,7 @@ class Databox implements ControllerProviderInterface $success = false; try { - $app['phraseanet.appbox']->set_databox_indexable($app['phraseanet.appbox']->get_databox($databox_id), ! ! $request->request->get('indexable', false)); + $app['phraseanet.appbox']->set_databox_indexable($app['phraseanet.appbox']->get_databox($databox_id), !!$request->request->get('indexable', false)); $success = true; } catch (\Exception $e) { @@ -557,15 +633,11 @@ class Databox implements ControllerProviderInterface */ public function updateDatabaseCGU(Application $app, Request $request, $databox_id) { - if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { - $app->abort(403); - } - $databox = $app['phraseanet.appbox']->get_databox($databox_id); try { foreach ($request->request->get('TOU', array()) as $loc => $terms) { - $databox->update_cgus($loc, $terms, ! ! $request->request->get('valid', false)); + $databox->update_cgus($loc, $terms, !!$request->request->get('valid', false)); } } catch (\Exception $e) { @@ -575,154 +647,6 @@ class Databox implements ControllerProviderInterface return $app->redirect('/admin/databox/' . $databox_id . '/cgus/?success=1'); } - /** - * Create a new databox - * - * @param Application $app The silex application - * @param Request $request The current HTTP request - * @param integer $databox_id The requested databox - * @return RedirectResponse - */ - public function createDatabase(Application $app, Request $request) - { - if ('' === $dbName = $request->request->get('new_dbname', '')) { - - return $app->redirect('/admin/databoxes/?error=no-empty'); - } - - if (\p4string::hasAccent($dbName)) { - - return $app->redirect('/admin/databoxes/?error=special-chars'); - } - - $registry = $app['phraseanet.registry']; - - if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) { - - $configuration = $app['phraseanet.configuration']; - $choosenConnexion = $configuration->getPhraseanet()->get('database'); - $connexion = $configuration->getConnexion($choosenConnexion); - - $hostname = $connexion->get('host'); - $port = $connexion->get('port'); - $user = $connexion->get('user'); - $password = $connexion->get('password'); - - $dataTemplate = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml'); - - try { - $connbas = new \connection_pdo('databox_creation', $hostname, $port, $user, $password, $dbName, array(), $registry); - } catch (\PDOException $e) { - - return $app->redirect('/admin/databoxes/?success=0&error=database-failed'); - } - - try { - $base = \databox::create($app, $connbas, $dataTemplate, $registry); - $base->registerAdmin($app['phraseanet.user']); - $app['phraseanet.user']->ACL()->delete_data_from_cache(); - - return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); - } catch (\Exception $e) { - - return $app->redirect('/admin/databoxes/?success=0&error=base-failed'); - } - } - - if ( - null !== $request->request->get('new_settings') - && (null !== $hostname = $request->request->get('new_hostname')) - && (null !== $port = $request->request->get('new_port')) - && (null !== $userDb = $request->request->get('new_user')) - && (null !== $passwordDb = $request->request->get('new_password')) - && (null !== $dataTemplate = $request->request->get('new_data_template'))) { - - try { - $data_template = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml'); - $connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $registry); - try { - $base = \databox::create($app, $connbas, $data_template, $registry); - $base->registerAdmin($app['phraseanet.user']); - - return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); - } catch (\Exception $e) { - - return $app->redirect('/admin/databoxes/?success=0&error=base-failed'); - } - } catch (\Exception $e) { - - return $app->redirect('/admin/databoxes/?success=0&error=database-failed'); - } - } - } - - /** - * Mount a databox - * - * @param Application $app The silex application - * @param Request $request The current HTTP request - * @return RedirectResponse - */ - public function databaseMount(Application $app, Request $request) - { - if ('' === $dbName = trim($request->request->get('new_dbname', ''))) { - - return $app->redirect('/admin/databoxes/?success=0&error=no-empty'); - } - - if (\p4string::hasAccent($dbName)) { - - return $app->redirect('/admin/databoxes/?success=0&error=special-chars'); - } - - $appbox = $app['phraseanet.appbox']; - $registry = $app['phraseanet.registry']; - - if ((null === $request->request->get('new_settings'))) { - try { - $configuration = $app['phraseanet.configuration']; - $connexion = $configuration->getConnexion(); - - $hostname = $connexion->get('host'); - $port = $connexion->get('port'); - $user = $connexion->get('user'); - $password = $connexion->get('password'); - - $appbox->get_connection()->beginTransaction(); - $base = \databox::mount($app, $hostname, $port, $user, $password, $dbName, $registry); - $base->registerAdmin($app['phraseanet.user']); - $appbox->get_connection()->commit(); - - return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); - } catch (\Exception $e) { - $appbox->get_connection()->rollBack(); - - return $app->redirect('/admin/databoxes/?success=0&error=mount-failed'); - } - } - - if ( - null !== $request->request->get('new_settings') - && (null !== $hostname = $request->request->get('new_hostname')) - && (null !== $port = $request->request->get('new_port')) - && (null !== $userDb = $request->request->get('new_user')) - && (null !== $passwordDb = $request->request->get('new_password'))) { - - try { - $appbox->get_connection()->beginTransaction(); - $base = \databox::mount($app, $hostname, $port, $userDb, $passwordDb, $dbName, $registry); - $base->registerAdmin($app['phraseanet.user']); - $appbox->get_connection()->commit(); - - return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); - } catch (\Exception $e) { - $appbox->get_connection()->rollBack(); - - return $app->redirect('/admin/databoxes/?success=0&error=mount-failed'); - } - } - } - /** * Mount a collection on a databox * @@ -736,10 +660,6 @@ class Databox implements ControllerProviderInterface $appbox = $app['phraseanet.appbox']; $user = $app['phraseanet.user']; - if ( ! $user->ACL()->has_right_on_sbas($databox_id, 'bas_manage')) { - $app->abort(403); - } - $appbox->get_connection()->beginTransaction(); try { $baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $user); @@ -988,7 +908,7 @@ class Databox implements ControllerProviderInterface */ public function progressBarInfos(Application $app, Request $request, $databox_id) { - if ( ! $app['request']->isXmlHttpRequest() || 'json' !== $app['request']->getRequestFormat()) { + if (!$app['request']->isXmlHttpRequest() || 'json' !== $app['request']->getRequestFormat()) { $app->abort(400, _('Bad request format, only JSON is allowed')); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php index 2e8bce3c83..a227a93f04 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php @@ -30,8 +30,13 @@ class Databoxes implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - return $app['firewall']->requireAdmin($app); - }); + $response = $app['firewall']->requireAdmin(); + + if ($response instanceof Response) { + return $response; + } + }); + /** * Get Databases control panel @@ -50,6 +55,38 @@ class Databoxes implements ControllerProviderInterface ->bind('admin_databases'); + /** + * Create Database + * + * name : admin_database_new + * + * description : Create Database + * + * method : POST + * + * parameters : none + * + * return : Redirect Response + */ + $controllers->post('/', $this->call('createDatabase')) + ->bind('admin_database_new'); + + /** + * Mount a database + * + * name : admin_database_mount + * + * description : Upgrade all databases + * + * method : POST + * + * parameters : none + * + * return : Redirect Response + */ + $controllers->post('/mount/', $this->call('databaseMount')) + ->bind('admin_database_mount'); + /** * Upgrade all databases * @@ -159,6 +196,154 @@ class Databoxes implements ControllerProviderInterface ))); } + /** + * Create a new databox + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @param integer $databox_id The requested databox + * @return RedirectResponse + */ + public function createDatabase(Application $app, Request $request) + { + if ('' === $dbName = $request->request->get('new_dbname', '')) { + + return $app->redirect('/admin/databoxes/?error=no-empty'); + } + + if (\p4string::hasAccent($dbName)) { + + return $app->redirect('/admin/databoxes/?error=special-chars'); + } + + $registry = $app['phraseanet.registry']; + + if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) { + + $configuration = $app['phraseanet.configuration']; + $choosenConnexion = $configuration->getPhraseanet()->get('database'); + $connexion = $configuration->getConnexion($choosenConnexion); + + $hostname = $connexion->get('host'); + $port = $connexion->get('port'); + $user = $connexion->get('user'); + $password = $connexion->get('password'); + + $dataTemplate = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml'); + + try { + $connbas = new \connection_pdo('databox_creation', $hostname, $port, $user, $password, $dbName, array(), $registry); + } catch (\PDOException $e) { + + return $app->redirect('/admin/databoxes/?success=0&error=database-failed'); + } + + try { + $base = \databox::create($app, $connbas, $dataTemplate, $registry); + $base->registerAdmin($app['phraseanet.user']); + $app['phraseanet.user']->ACL()->delete_data_from_cache(); + + return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); + } catch (\Exception $e) { + + return $app->redirect('/admin/databoxes/?success=0&error=base-failed'); + } + } + + if ( + null !== $request->request->get('new_settings') + && (null !== $hostname = $request->request->get('new_hostname')) + && (null !== $port = $request->request->get('new_port')) + && (null !== $userDb = $request->request->get('new_user')) + && (null !== $passwordDb = $request->request->get('new_password')) + && (null !== $dataTemplate = $request->request->get('new_data_template'))) { + + try { + $data_template = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml'); + $connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $registry); + try { + $base = \databox::create($app, $connbas, $data_template, $registry); + $base->registerAdmin($app['phraseanet.user']); + + return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); + } catch (\Exception $e) { + + return $app->redirect('/admin/databoxes/?success=0&error=base-failed'); + } + } catch (\Exception $e) { + + return $app->redirect('/admin/databoxes/?success=0&error=database-failed'); + } + } + } + + /** + * Mount a databox + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @return RedirectResponse + */ + public function databaseMount(Application $app, Request $request) + { + if ('' === $dbName = trim($request->request->get('new_dbname', ''))) { + + return $app->redirect('/admin/databoxes/?success=0&error=no-empty'); + } + + if (\p4string::hasAccent($dbName)) { + + return $app->redirect('/admin/databoxes/?success=0&error=special-chars'); + } + + $appbox = $app['phraseanet.appbox']; + $registry = $app['phraseanet.registry']; + + if ((null === $request->request->get('new_settings'))) { + try { + $configuration = $app['phraseanet.configuration']; + $connexion = $configuration->getConnexion(); + + $hostname = $connexion->get('host'); + $port = $connexion->get('port'); + $user = $connexion->get('user'); + $password = $connexion->get('password'); + + $appbox->get_connection()->beginTransaction(); + $base = \databox::mount($app, $hostname, $port, $user, $password, $dbName, $registry); + $base->registerAdmin($app['phraseanet.user']); + $appbox->get_connection()->commit(); + + return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); + } catch (\Exception $e) { + $appbox->get_connection()->rollBack(); + + return $app->redirect('/admin/databoxes/?success=0&error=mount-failed'); + } + } + + if ( + null !== $request->request->get('new_settings') + && (null !== $hostname = $request->request->get('new_hostname')) + && (null !== $port = $request->request->get('new_port')) + && (null !== $userDb = $request->request->get('new_user')) + && (null !== $passwordDb = $request->request->get('new_password'))) { + + try { + $appbox->get_connection()->beginTransaction(); + $base = \databox::mount($app, $hostname, $port, $userDb, $passwordDb, $dbName, $registry); + $base->registerAdmin($app['phraseanet.user']); + $appbox->get_connection()->commit(); + + return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); + } catch (\Exception $e) { + $appbox->get_connection()->rollBack(); + + return $app->redirect('/admin/databoxes/?success=0&error=mount-failed'); + } + } + } + /** * Upgrade all databases * diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index 1fc111e830..00c9288c83 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -40,10 +40,8 @@ class Publications implements ControllerProviderInterface $controllers->post('/create/', function(PhraseaApplication $app, Request $request) { - $user = $app['phraseanet.user']; - $feed = \Feed_Adapter::create( - $app, $user, $request->request->get('title'), $request->request->get('subtitle') + $app, $app['phraseanet.user'], $request->request->get('title'), $request->request->get('subtitle') ); if ($request->request->get('public') == '1') { diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index 62c59c3e1e..881c5dbfce 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -28,8 +28,18 @@ class Root implements ControllerProviderInterface { $controllers = $app['controllers_factory']; - $controllers->get('/', function(Application $app, Request $request) { + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAccessToModule('admin'); + + if ($response instanceof Response) { + return $response; + } + }); + + + + $controllers->get('/', function(Application $app, Request $request) { $appbox = $app['phraseanet.appbox']; $user = $app['phraseanet.user']; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php index b71fbee0c8..227103355c 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php @@ -37,8 +37,12 @@ class Setup implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - return $app['firewall']->requireAdmin($app); - }); + $response = $app['firewall']->requireAdmin(); + + if ($response instanceof Response) { + return $response; + } + }); /** * Get globals values diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php b/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php index 02f17ab5c2..72cca17287 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php @@ -30,8 +30,12 @@ class Sphinx implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - return $app['firewall']->requireAdmin($app); - }); + $response = $app['firewall']->requireAdmin(); + + if ($response instanceof Response) { + return $response; + } + }); /** * Sphinx configuration diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index 3be2a8bae7..008ba80c03 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -288,7 +288,6 @@ class Users implements ControllerProviderInterface ->on_sbas_ids($on_sbas); $offset = 0; - $geoname = new \geonames(); $buffer = array(); $buffer[] = array( @@ -322,12 +321,12 @@ class Users implements ControllerProviderInterface , $user->get_lastname() , $user->get_firstname() , $user->get_email() - , \phraseadate::format_mysql($user->get_creation_date()) - , \phraseadate::format_mysql($user->get_modification_date()) + , $app['date-formatter']->format_mysql($user->get_creation_date()) + , $app['date-formatter']->format_mysql($user->get_modification_date()) , $user->get_address() , $user->get_city() , $user->get_zipcode() - , $geoname->get_country($user->get_geonameid(), $app) + , $app['geonames']->get_country($user->get_geonameid()) , $user->get_tel() , $user->get_fax() , $user->get_job() diff --git a/lib/Alchemy/Phrasea/Controller/Datafiles.php b/lib/Alchemy/Phrasea/Controller/Datafiles.php index 4c4fbb5acf..94f857d5ef 100644 --- a/lib/Alchemy/Phrasea/Controller/Datafiles.php +++ b/lib/Alchemy/Phrasea/Controller/Datafiles.php @@ -33,7 +33,7 @@ class Datafiles extends AbstractDelivery $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $record = new \record_adapter($app, $sbas_id, $record_id); - if (!$app['phraseanet.session']->is_authenticated()) { + if (!$app->isAuthenticated()) { throw new \Exception_Session_NotAuthenticated(); } @@ -89,7 +89,7 @@ class Datafiles extends AbstractDelivery } } - return $that->deliverContent($app['request'], $app['phraseanet.session'], $record, $subdef, $watermark, $stamp, $app); + return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Permalink.php b/lib/Alchemy/Phrasea/Controller/Permalink.php index 67cdd797da..9fedd16866 100644 --- a/lib/Alchemy/Phrasea/Controller/Permalink.php +++ b/lib/Alchemy/Phrasea/Controller/Permalink.php @@ -61,7 +61,7 @@ class Permalink extends AbstractDelivery $watermark = $stamp = false; - if ($app['phraseanet.session']->is_authenticated()) { + if ($app->isAuthenticated()) { $user = \User_Adapter::getInstance($app['phraseanet.user']->get_id(), $app); $watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark'); @@ -77,7 +77,7 @@ class Permalink extends AbstractDelivery } } - return $that->deliverContent($app['request'], $app['phraseanet.session'], $record, $subdef, $watermark, $stamp, $app); + return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); } else { $collection = \collection::get_from_base_id($app, $record->get_base_id()); switch ($collection->get_pub_wm()) { @@ -94,7 +94,7 @@ class Permalink extends AbstractDelivery } } - return $that->deliverContent($app['request'], $app['phraseanet.session'], $record, $subdef, $watermark, $stamp, $app); + return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); } ) ->assert('sbas_id', '\d+')->assert('record_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php index 5f7cfe5230..ccb70bfe3a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php @@ -31,6 +31,14 @@ class Basket implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); + /** * Get a basket */ diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index b7c9478ec0..2554ab5706 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -11,13 +11,11 @@ namespace Alchemy\Phrasea\Controller\Prod; +use Alchemy\Phrasea\Helper\Record as RecordHelper; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Alchemy\Phrasea\Helper\Record as RecordHelper; - +use Symfony\Component\HttpFoundation\Request; /** * @@ -31,14 +29,25 @@ class Bridge implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + + $response = $app['firewall'] + ->requireNotGuest() + ->requireRight('bas_chupub'); + + if ($response instanceof Response) { + return $response; + } + }); + $app['require_connection'] = $app->protect(function(\Bridge_Account $account) use ($app) { $app['current_account'] = function() use ($account) { return $account; }; - if ( ! $account->get_api()->get_connector()->is_configured()) + if (!$account->get_api()->get_connector()->is_configured()) throw new \Bridge_Exception_ApiConnectorNotConfigured("Bridge API Connector is not configured"); - if ( ! $account->get_api()->get_connector()->is_connected()) + if (!$account->get_api()->get_connector()->is_connected()) throw new \Bridge_Exception_ApiConnectorNotConnected("Bridge API Connector is not connected"); return; @@ -420,57 +429,6 @@ class Bridge implements ControllerProviderInterface return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . sprintf(_('%d elements en attente'), count($route->get_elements()))); }); -// -// $app->error(function(\Exception $e, $code) use ($app) { -// -// $request = $app['request']; -// -// if ($e instanceof \Bridge_Exception) { -// -// $params = array( -// 'message' => $e->getMessage() -// , 'file' => $e->getFile() -// , 'line' => $e->getLine() -// , 'r_method' => $request->getMethod() -// , 'r_action' => $request->getRequestUri() -// , 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all()) -// ); -// -// if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) { -// $params = array_merge($params, array('account' => $app['current_account'])); -// -// $response = new Response($app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200); -// } elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) { -// $params = array_merge($params, array('account' => $app['current_account'])); -// -// $response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200); -// } elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) { -// $params = array_merge($params, array('account' => $app['current_account'])); -// -// $response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200); -// } elseif ($e instanceof \Bridge_Exception_ApiDisabled) { -// $params = array_merge($params, array('api' => $e->get_api())); -// -// $response = new Response($app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200); -// } else { -// $response = new Response($app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200); -// } -// -// $response->headers->set('Phrasea-StatusCode', 200); -// -// return $response; -// } -// }); - -// /** -// * Temporary fix for https://github.com/fabpot/Silex/issues/438 -// */ -// $app['dispatcher']->addListener(KernelEvents::RESPONSE, function(FilterResponseEvent $event){ -// if ($event->getResponse()->headers->has('Phrasea-StatusCode')) { -// $event->getResponse()->setStatusCode($event->getResponse()->headers->get('Phrasea-StatusCode')); -// $event->getResponse()->headers->remove('Phrasea-StatusCode'); -// } -// }); return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index 5c0b32eb5c..e1a2b571da 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -30,6 +30,17 @@ class Edit implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + + $response = $app['firewall'] + ->requireNotGuest() + ->requireRight('modifyrecord'); + + if ($response instanceof Response) { + return $response; + } + }); + $controllers->post('/', function(Application $app, Request $request) { $records = RecordsRequest::fromRequest($app, $request, true, array('canmodifrecord')); @@ -386,13 +397,11 @@ class Edit implements ControllerProviderInterface ->write_metas(); if ($statbits != '') { - $app['phraseanet.session'] - ->get_logger($record->get_databox()) + $app['phraseanet.logger']($record->get_databox()) ->log($record, \Session_Logger::EVENT_STATUS, '', ''); } if ($editDirty) { - $app['phraseanet.session'] - ->get_logger($record->get_databox()) + $app['phraseanet.logger']($record->get_databox()) ->log($record, \Session_Logger::EVENT_EDIT, '', ''); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php index b5ac621760..8d019bd662 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php @@ -41,12 +41,10 @@ class Printer implements ControllerProviderInterface $request = $app['request']; - $session = $app['phraseanet.session']; - $layout = $request->request->get('lay'); foreach ($printer->get_elements() as $record) { - $session->get_logger($record->get_databox()) + $app['phraseanet.logger']($record->get_databox()) ->log($record, \Session_Logger::EVENT_PRINT, $layout, ''); } $PDF = new PDFExport($app, $printer->get_elements(), $layout); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index 186c6c69fe..b2ceef538f 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -237,8 +237,7 @@ class Push implements ControllerProviderInterface $events_manager->trigger('__PUSH_DATAS__', $params); } - $app['phraseanet.session'] - ->get_logger($BasketElement->getRecord($app)->get_databox()) + $app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox()) ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_VALIDATE, $user_receiver->get_id(), ''); $app['EM']->flush(); @@ -413,8 +412,7 @@ class Push implements ControllerProviderInterface $app['EM']->merge($BasketElement); $app['EM']->persist($ValidationData); - $app['phraseanet.session'] - ->get_logger($BasketElement->getRecord($app)->get_databox()) + $app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox()) ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participant_user->get_id(), ''); $Participant->addValidationData($ValidationData); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index c984fcb186..0dacbbf783 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -27,6 +27,14 @@ class Query implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); + $controllers->post('/', function(Application $app, Request $request) { $appbox = $app['phraseanet.appbox']; @@ -165,7 +173,7 @@ class Query implements ControllerProviderInterface $prop = null; if ($search_engine->is_first_page()) { - $propals = $result->get_suggestions($app['phraseanet.session']->get_I18n()); + $propals = $result->get_suggestions($app['locale.I18n']); if (count($propals) > 0) { foreach ($propals as $prop_array) { if ($prop_array['value'] !== $query && $prop_array['hits'] > $result->get_count_total_results()) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index b4a104151e..f214e5ab79 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -30,6 +30,14 @@ class Root implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); + $controllers->get('/', function(Application $app) { \User_Adapter::updateClientInfos($app, 1); @@ -59,7 +67,7 @@ class Root implements ControllerProviderInterface $cssfile = $user->getPrefs('css'); - if ( ! $cssfile && isset($css['000000'])) { + if (!$cssfile && isset($css['000000'])) { $cssfile = '000000'; } @@ -71,9 +79,9 @@ class Root implements ControllerProviderInterface $queries_topics = ''; if ($registry->get('GV_client_render_topics') == 'popups') { - $queries_topics = \queries::dropdown_topics($app['phraseanet.session']->get_I18n()); + $queries_topics = \queries::dropdown_topics($app['locale.I18n']); } elseif ($registry->get('GV_client_render_topics') == 'tree') { - $queries_topics = \queries::tree_topics($app['phraseanet.session']->get_I18n()); + $queries_topics = \queries::tree_topics($app['locale.I18n']); } $sbas = $bas2sbas = array(); @@ -125,12 +133,12 @@ class Root implements ControllerProviderInterface $download = new \set_export($app, $request->request->get('lst', ''), (int) $request->request->get('ssel'), $request->request->get('story')); return $app['twig']->render('common/dialog_export.html.twig', array( - 'download' => $download, - 'ssttid' => (int) $request->request->get('ssel'), - 'lst' => $download->serialize_list(), - 'default_export_title' => $app['phraseanet.registry']->get('GV_default_export_title'), - 'choose_export_title' => $app['phraseanet.registry']->get('GV_choose_export_title') - )); + 'download' => $download, + 'ssttid' => (int) $request->request->get('ssel'), + 'lst' => $download->serialize_list(), + 'default_export_title' => $app['phraseanet.registry']->get('GV_default_export_title'), + 'choose_export_title' => $app['phraseanet.registry']->get('GV_choose_export_title') + )); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php index 1a81d5c288..140322357a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -32,7 +32,6 @@ class TOU implements ControllerProviderInterface try { $user = $app['phraseanet.user']; - $session = $app['phraseanet.session']; $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); @@ -41,7 +40,7 @@ class TOU implements ControllerProviderInterface ); $user->ACL()->revoke_unused_sbas_rights(); - $session->logout(); + $app->closeAccount(); $ret = array('success' => true, 'message' => ''); } catch (\Exception $e) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php index 94b09decc7..4280695670 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Controller\Prod; +use Symfony\Component\HttpFoundation\Request; use Silex\Application; use Silex\ControllerProviderInterface; @@ -26,6 +27,14 @@ class Tooltip implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); + $controllers->post('/basket/{basket_id}/', $this->call('displayBasket')) ->assert('basket_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php b/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php index bbe4d6c20b..a70cfa715d 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UserPreferences.php @@ -27,6 +27,14 @@ class UserPreferences implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); + $controllers->post('/save/', $this->call('savePreference')); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php index 8a569f0818..4c61ea97bb 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php @@ -29,6 +29,14 @@ class WorkZone implements ControllerProviderInterface { $controllers = $app['controllers_factory']; + $controllers->before(function(Request $request) use ($app) { + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); + $controllers->get('/', $this->call('displayWorkzone')); $controllers->get('/Browse/', $this->call('browse')); diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index 0aa900933e..d425ce327c 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -31,8 +31,12 @@ class Account implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function() use ($app) { - return $app['firewall']->requireAuthentication($app); - }); + $response = $app['firewall']->requireAuthentication(); + + if($response instanceof Response) { + return $response; + } + }); /** * Get a new account @@ -449,7 +453,7 @@ class Account implements ControllerProviderInterface public function accountAuthorizedApps(Application $app, Request $request) { return $app['twig']->render('account/authorized_apps.html.twig', array( - "apps" => \API_OAuth2_Application::load_app_by_user($app, $app['phraseanet.user']), + "applications" => \API_OAuth2_Application::load_app_by_user($app, $app['phraseanet.user']), )); } @@ -462,7 +466,46 @@ class Account implements ControllerProviderInterface */ public function accountSessionsAccess(Application $app, Request $request) { - return new Response($app['twig']->render('account/sessions.html.twig')); + + $dql = 'SELECT s FROM Entities\Session s + WHERE s.usr_id = :usr_id + ORDER BY s.created DESC'; + + $query = $app['EM']->createQuery($dql); + $query->setParameters(array('usr_id'=>$app['session']->get('usr_id'))); + $sessions = $query->getResult(); + +// $sql = 'SELECT session_id, lastaccess, ip, platform, browser, screen +// , created_on, browser_version, token +// FROM cache WHERE usr_id = :usr_id'; +// +// +// $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); +// $stmt->execute(array(':usr_id' => $this->get_usr_id())); +// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); +// $stmt->closeCursor(); +// +// $geonames = new geonames(); +// +// foreach ($rs as $k => $row) { +// $datas = $geonames->find_geoname_from_ip($row['ip'], $this->app); +// +// if ($datas['city']) { +// $infos = $datas['city'] . ' (' . $datas['country'] . ')'; +// } elseif ($datas['fips']) { +// $infos = $datas['fips'] . ' (' . $datas['country'] . ')'; +// } elseif ($datas['country']) { +// $infos = $datas['country']; +// } else { +// $infos = ''; +// } +// $rs[$k]['session_id'] = (int) $rs[$k]['session_id']; +// $rs[$k]['ip_infos'] = $infos; +// $rs[$k]['created_on'] = new \DateTime($row['created_on']);; +// $rs[$k]['lastaccess'] = new \DateTime($row['lastaccess']); +// } + + return new Response($app['twig']->render('account/sessions.html.twig', array('sessions'=>$sessions))); } /** @@ -497,7 +540,6 @@ class Account implements ControllerProviderInterface } return new Response($app['twig']->render('account/account.html.twig', array( - 'geonames' => new \geonames(), 'user' => $user, 'notice' => $notice, 'evt_mngr' => $evtMngr, diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php index 14f07009df..611e36432c 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php @@ -341,7 +341,7 @@ class Developers implements ControllerProviderInterface public function listApps(Application $app, Request $request) { return $app['twig']->render('developers/applications.html.twig', array( - "apps" => \API_OAuth2_Application::load_dev_app_by_user( + "applications" => \API_OAuth2_Application::load_dev_app_by_user( $app, $app['phraseanet.user'] ))); } @@ -383,7 +383,7 @@ class Developers implements ControllerProviderInterface $token = $client->get_user_account($user)->get_token()->get_value(); return $app['twig']->render('developers/application.html.twig', array( - "app" => $client, + "application" => $client, "user" => $user, "token" => $token )); diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index ad2dbf3cbe..1d7c78b34e 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Controller\Root; +use Alchemy\Phrasea\Application as PhraseaApplication; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; @@ -30,10 +31,12 @@ class Login implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - if ($app['phraseanet.registry']->get('GV_maintenance')) { - return $app->redirect("/login/?redirect=" . $request->request->get('redirect') . "&error=maintenance"); - } - }); + if ($app['phraseanet.registry']->get('GV_maintenance')) { + return $app->redirect("/login/?redirect=" . $request->request->get('redirect') . "&error=maintenance"); + } + }); + + /** * Login @@ -50,21 +53,20 @@ class Login implements ControllerProviderInterface */ $controllers->get('/', $this->call('login')) ->before(function(Request $request) use ($app) { + if ($app->isAuthenticated()) { + return $app->redirect('/' . $request->query->get('redirect', 'prod') . '/'); + } + if (null !== $request->query->get('postlog')) { // if isset postlog parameter, set cookie and log out current user // then post login operation like getting baskets from an invit session // could be done by Session_handler authentication process - $app['phraseanet.session']->set_postlog(); + $response = new RedirectResponse("/login/logout/?redirect=" . $request->query->get('redirect', 'prod')); + $response->headers->setCookie(new \Symfony\Component\HttpFoundation\Cookie('postlog', 1)); - return $app->redirect("/login/logout/?redirect=" . $request->query->get('redirect', 'prod')); - } - - - if ($app->isAuthenticated()) { - - return $app->redirect('/' . $request->query->get('redirect', 'prod') . '/'); + return $response; } }) ->bind('homepage'); @@ -83,11 +85,6 @@ class Login implements ControllerProviderInterface * return : HTML Response */ $controllers->post('/authenticate/', $this->call('authenticate')) - ->before(function() use ($app) { - if ($app->isAuthenticated()) { - return $app->redirect('/prod/'); - } - }) ->bind('login_authenticate'); /** @@ -483,9 +480,8 @@ class Login implements ControllerProviderInterface 'parms' => $request->query->all(), 'needed' => $needed, 'arrayVerif' => $arrayVerif, - 'geonames' => new \geonames(), 'demandes' => $request->query->get('demand', array()), - 'lng' => \Session_Handler::get_locale() + 'lng' => $app['locale'] ))); } @@ -655,20 +651,25 @@ class Login implements ControllerProviderInterface * @param Request $request The current request * @return RedirectResponse */ - public function logout(Application $app, Request $request) + public function logout(PhraseaApplication $app, Request $request) { $appRedirect = $request->query->get("app"); - try { - $session = $app['phraseanet.session']; + /** + * Move to middleware + if ( ! $this->is_authenticated()) { + return; + } + */ + $app->closeAccount(); - $session->logout(); - $session->remove_cookies(); - } catch (\Exception $e) { - return $app->redirect("/" . ($appRedirect ? $appRedirect : 'prod')); - } + $response = new RedirectResponse("/login/?logged_out=user" . ($appRedirect ? sprintf("&redirect=/%s", $appRedirect) : "")); - return $app->redirect("/login/?logged_out=user" . ($appRedirect ? sprintf("&redirect=/%s", $appRedirect) : "")); + $response->headers->removeCookie('persistent'); + $response->headers->removeCookie('last_act'); + $response->headers->removeCookie('postlog'); + + return $response; } /** @@ -795,7 +796,7 @@ class Login implements ControllerProviderInterface public function authenticate(Application $app, Request $request) { $appbox = $app['phraseanet.appbox']; - $session = $app['phraseanet.session']; + $conn = $appbox->get_connection(); $registry = $app['phraseanet.registry']; $is_guest = false; @@ -810,8 +811,6 @@ class Login implements ControllerProviderInterface * @todo dispatch an event that can be used to tweak the authentication * (LDAP....) */ - // $app['dispatcher']->dispatch(); - try { if ($is_guest) { $auth = new \Session_Authentication_Guest($app); @@ -837,7 +836,132 @@ class Login implements ControllerProviderInterface $auth->set_captcha_challenge($captcha); } - $session->authenticate($auth); + + $sql = "SELECT session_id FROM cache + WHERE (lastaccess < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND token IS NOT NULL) + OR (lastaccess < DATE_SUB(NOW(), INTERVAL 30 MINUTE) AND token IS NULL)"; + + $stmt = $conn->prepare($sql); + $stmt->execute(); + $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) { + phrasea_close_session($row['session_id']); + } + + $date = new \DateTime('+' . (int) $app['phraseanet.registry']->get('GV_validation_reminder') . ' days'); + + foreach ($app['EM'] + ->getRepository('\Entities\ValidationParticipant') + ->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) { + + /* @var $participant \Entities\ValidationParticipant */ + + $validationSession = $participant->getSession(); + $participantId = $participant->getUsrId(); + $basketId = $validationSession->getBasket()->getId(); + + try { + $token = \random::getValidationToken($this->app, $participantId, $basketId); + } catch (\Exception_NotFound $e) { + continue; + } + + $app['events-manager']->trigger('__VALIDATION_REMINDER__', array( + 'to' => $participantId, + 'ssel_id' => $basketId, + 'from' => $validationSession->getInitiatorId(), + 'validate_id' => $validationSession->getId(), + 'url' => $app['phraseanet.registry']->get('GV_ServerName') . 'lightbox/validate/' . $basketId . '/?LOG=' . $token + )); + } + + + /** + * IMPORTANT + */ + $auth->prelog(); + + if ($app->isAuthenticated() && $app['session']->get('usr_id') == $auth->get_user()->get_id()) { + return $app->redirect('/' . $request->request->get('redirect', 'prod')); + } + + $user = $auth->signOn(); + + + /** + * TODO NEUTRON save user locale + */ + /** + * TODO NEUTRON move this to phrasea + */ + $user->ACL()->inject_rights(); + + if ($request->cookies->has('postlog') && $request->cookies->get('postlog') == '1') { + if (!$user->is_guest() && $request->cookies->has('invite-usr_id')) { + if ($user->get_id() != $inviteUsrId = $request->cookies->get('invite-usr_id')) { + + $repo = $app['EM']->getRepository('Entities\Basket'); + $baskets = $repo->findBy(array('usr_id' => $inviteUsrId)); + + foreach ($baskets as $basket) { + $basket->setUsrId($user->get_id()); + $app['EM']->persist($basket); + } + } + } + } + + $app->openAccount($auth); + + /** + * IMPORTANT + */ + $auth->postlog(); + + if ($app['browser']->isMobile()) { + $response = new RedirectResponse("/lightbox/"); + } elseif ($request->request->get('redirect')) { + $response = new RedirectResponse('/' . $request->request->get('redirect')); + } elseif (true !== $app['browser']->isNewGeneration()) { + $response = new RedirectResponse('/client/'); + } else { + $response = new RedirectResponse('/prod/'); + } + + $response->headers->removeCookie('postlog'); + + $session = $app['EM']->find('Entities\Session', $app['session']->get('session_id')); + + if ($request->request->get('remember-me') == '1') { + $nonce = \random::generatePassword(16); + $string = $app['browser']->getBrowser() . '_' . $app['browser']->getPlatform(); + + $token = \User_Adapter::salt_password($app, $string, $nonce); + + $session->setToken($token) + ->setNonce($nonce); + $cookie = new Cookie('persistent', $token); + $response->headers->setCookie($cookie); + } + + $width = $height = null; + if ($app['request']->cookies->has('screen')) { + $data = explode('x', $this['request']->cookies->get('screen')); + $width = $data[0]; + $height = $data[1]; + } + $session->setIpAddress($request->getClientIp()) + ->setScreenHeight($height) + ->setScreenWidth($width); + + $app['EM']->persist($session); + $app['EM']->flush(); + + $response->headers->removeCookie('last_act'); + + return $response; } catch (\Exception_Session_StorageClosed $e) { return $app->redirect("/login/?redirect=" . $request->request->get('redirect') . "&error=session"); } catch (\Exception_Session_RequireCaptcha $e) { @@ -861,16 +985,6 @@ class Login implements ControllerProviderInterface } catch (\Exception $e) { return $app->redirect("/login/?redirect=" . $request->request->get('redirect') . "&error=" . _('An error occured')); } - - if ($app['browser']->isMobile()) { - return $app->redirect("/lightbox/"); - } elseif ($request->request->get('redirect')) { - return $app->redirect($request->request->get('redirect')); - } elseif (true !== $app['browser']->isNewGeneration()) { - return $app->redirect('/client/'); - } else { - return $app->redirect('/prod/'); - } } else { return $app->redirect("/login/"); } diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php index 31c28c4c1f..ea2c8e8787 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php +++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php @@ -81,7 +81,7 @@ class RSSFeeds implements ControllerProviderInterface $controllers->get('/feed/{id}/{format}/', function(Application $app, $id, $format) use ($display_feed) { $feed = new \Feed_Adapter($app, $id); - if ( ! $feed->is_public()) { + if (!$feed->is_public()) { return new Response('Forbidden', 403); } @@ -94,12 +94,9 @@ class RSSFeeds implements ControllerProviderInterface })->assert('id', '\d+')->assert('format', '(rss|atom)'); $controllers->get('/userfeed/{token}/{id}/{format}/', function(Application $app, $token, $id, $format) use ($display_feed) { - try { - $token = new \Feed_Token($app, $token, $id); - $feed = $token->get_feed(); - } catch (\Exception_FeedNotFound $e) { - return new Response('Not Found', 404); - } + $token = new \Feed_Token($app, $token, $id); + $feed = $token->get_feed(); + $request = $app['request']; $page = (int) $request->query->get('page'); @@ -109,12 +106,8 @@ class RSSFeeds implements ControllerProviderInterface })->assert('id', '\d+')->assert('format', '(rss|atom)'); $controllers->get('/userfeed/aggregated/{token}/{format}/', function(Application $app, $token, $format) use ($display_feed) { - try { - $token = new \Feed_TokenAggregate($app, $token); - $feed = $token->get_feed(); - } catch (\Exception_FeedNotFound $e) { - return new Response('', 404); - } + $token = new \Feed_TokenAggregate($app, $token); + $feed = $token->get_feed(); $request = $app['request']; diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php index 5826cc45dc..32a50d888d 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php @@ -46,7 +46,7 @@ class Installer implements ControllerProviderInterface $extension_constraints = \setup::check_php_extension(); $opcode_constraints = \setup::check_cache_opcode(); $php_conf_constraints = \setup::check_php_configuration(); - $locales_constraints = \setup::check_system_locales(); + $locales_constraints = \setup::check_system_locales($app); $constraints_coll = array( 'php_constraint' => $php_constraint @@ -80,7 +80,7 @@ class Installer implements ControllerProviderInterface return $app['twig']->render( '/setup/index.html.twig' , array_merge($constraints_coll, array( - 'locale' => \Session_Handler::get_locale() + 'locale' => $app['locale'] , 'available_locales' => $app->getAvailableLanguages() , 'version_number' => $app['phraseanet.version']->getNumber() , 'version_name' => $app['phraseanet.version']->getName() @@ -91,7 +91,7 @@ class Installer implements ControllerProviderInterface public function getInstallForm(Application $app, Request $request) { - \phrasea::use_i18n(\Session_Handler::get_locale()); + \phrasea::use_i18n($app['locale']); $ld_path = array(__DIR__ . '/../../../../../templates/web'); $loader = new \Twig_Loader_Filesystem($ld_path); @@ -106,7 +106,7 @@ class Installer implements ControllerProviderInterface $extension_constraints = \setup::check_php_extension(); $opcode_constraints = \setup::check_cache_opcode(); $php_conf_constraints = \setup::check_php_configuration(); - $locales_constraints = \setup::check_system_locales(); + $locales_constraints = \setup::check_system_locales($app); $constraints_coll = array( 'php_constraint' => $php_constraint @@ -133,7 +133,7 @@ class Installer implements ControllerProviderInterface return $twig->render( '/setup/step2.html.twig' , array( - 'locale' => \Session_Handler::get_locale() + 'locale' => $app['locale'] , 'available_locales' => $app->getAvailableLanguages() , 'available_templates' => \appbox::list_databox_templates() , 'version_number' => $app['phraseanet.version']->getNumber() @@ -150,7 +150,7 @@ class Installer implements ControllerProviderInterface public function doInstall(Application $app, Request $request) { set_time_limit(360); - \phrasea::use_i18n(\Session_Handler::get_locale()); + \phrasea::use_i18n($app['locale']); $servername = $request->getScheme() . '://' . $request->getHttpHost() . '/'; @@ -234,7 +234,7 @@ class Installer implements ControllerProviderInterface $auth = new \Session_Authentication_None($user); - $app['phraseanet.session']->authenticate($auth); + $app->openAccount($auth); if ($databox_name && !\p4string::hasAccent($databox_name)) { $template = new \SplFileInfo(__DIR__ . '/../../../../conf.d/data_templates/' . $request->request->get('db_template') . '.xml'); diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php b/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php index 403f4f4792..4f5aa50237 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php @@ -33,7 +33,7 @@ class Upgrader implements ControllerProviderInterface return $app['twig']->render( '/setup/upgrader.html.twig' , array( - 'locale' => \Session_Handler::get_locale() + 'locale' => $app['locale'] , 'upgrade_status' => $upgrade_status , 'available_locales' => $app->getAvailableLanguages() , 'bad_users' => \User_Adapter::get_wrong_email_users($app) diff --git a/templates/web/account/account.html.twig b/templates/web/account/account.html.twig index 5c18f4de41..ff9d0d9173 100644 --- a/templates/web/account/account.html.twig +++ b/templates/web/account/account.html.twig @@ -90,7 +90,7 @@
- +

diff --git a/templates/web/account/authorized_apps.html.twig b/templates/web/account/authorized_apps.html.twig index d740ee772b..a0e36d18f9 100644 --- a/templates/web/account/authorized_apps.html.twig +++ b/templates/web/account/authorized_apps.html.twig @@ -53,23 +53,23 @@ $(document).ready(function(){

{% trans 'Vous avez autorise ces applications a acceder a votre compte' %}

- {% if apps|length > 0 %} + {% if applications|length > 0 %}