From a17f5fa950a01da60b849dcabdeaac46d48d2b62 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 10 Feb 2012 12:46:05 +0100 Subject: [PATCH] Moved terms Of Use as a dedicated controller --- config/nginx.rewrite.rules | 1 + lib/Alchemy/Phrasea/Application/Prod.php | 1 + lib/Alchemy/Phrasea/Controller/Prod/TOU.php | 70 +++++++++++++++++++++ lib/Alchemy/Phrasea/Core.php | 6 +- lib/classes/databox/cgu.class.php | 48 +------------- www/.htaccess | 1 + www/prod/page0.js | 13 ++-- www/prod/prodFeedBack.php | 4 -- 8 files changed, 86 insertions(+), 58 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Controller/Prod/TOU.php diff --git a/config/nginx.rewrite.rules b/config/nginx.rewrite.rules index 36ece7295c..6ab4f0c1f1 100644 --- a/config/nginx.rewrite.rules +++ b/config/nginx.rewrite.rules @@ -29,6 +29,7 @@ rewrite ^/prod/baskets/.*$ /prod/router.php last; rewrite ^/prod/story/.*$ /prod/router.php last; rewrite ^/prod/WorkZone/.*$ /prod/router.php last; rewrite ^/prod/language/.*$ /prod/router.php last; +rewrite ^/prod/TOU/.*$ /prod/router.php last; rewrite ^/prod/UserPreferences/.*$ /prod/router.php last; rewrite ^/prod/$ /prod/router.php last; diff --git a/lib/Alchemy/Phrasea/Application/Prod.php b/lib/Alchemy/Phrasea/Application/Prod.php index 98e09c6240..81b9fbe68e 100644 --- a/lib/Alchemy/Phrasea/Application/Prod.php +++ b/lib/Alchemy/Phrasea/Application/Prod.php @@ -50,6 +50,7 @@ return call_user_func(function() $app->mount('/bridge/', new Controller\Bridge()); $app->mount('/push/', new Controller\Push()); $app->mount('/printer/', new Controller\Printer()); + $app->mount('/TOU/', new Controller\TOU()); $app->mount('/feeds', new Controller\Feed()); $app->mount('/tooltip', new Controller\Tooltip()); $app->mount('/language', new Controller\Language()); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php new file mode 100644 index 0000000000..24a0706fe9 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -0,0 +1,70 @@ +post('/deny/{sbas_id}/', function(Application $app, Request $request, $sbas_id) + { + $ret = array('success' => false, 'message' => ''); + + try + { + $user = $app['Core']->getAuthenticatedUser(); + $session = \Session_Handler::getInstance(\appbox::get_instance()); + + $databox = \databox::get_instance((int) $sbas_id); + + $user->ACL()->revoke_access_from_bases( + $user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) + ); + $user->ACL()->revoke_unused_sbas_rights(); + + $session->logout(); + + $ret = array('success' => true, 'message' => ''); + } + catch (\Exception $e) + { + + } + + $Serializer = $app['Core']['Serializer']; + $datas = $Serializer->serialize($ret, 'json'); + + return new Response($datas, 200, array('Content-Type' => 'application/json')); + }); + + return $controllers; + } + +} diff --git a/lib/Alchemy/Phrasea/Core.php b/lib/Alchemy/Phrasea/Core.php index e3a0fd71eb..8c5581c90b 100644 --- a/lib/Alchemy/Phrasea/Core.php +++ b/lib/Alchemy/Phrasea/Core.php @@ -377,16 +377,16 @@ class Core extends \Pimple public static function initAutoloads($cacheAutoload = false) { require_once __DIR__ . '/Loader/Autoloader.php'; - + if ($cacheAutoload === true) { try { require_once __DIR__ . '/Loader/CacheAutoloader.php'; - + $prefix = 'class_'; $namespace = md5(__DIR__); - + $loader = new Loader\CacheAutoloader($prefix, $namespace); } catch (\Exception $e) diff --git a/lib/classes/databox/cgu.class.php b/lib/classes/databox/cgu.class.php index 1c701dd382..3b286b3230 100644 --- a/lib/classes/databox/cgu.class.php +++ b/lib/classes/databox/cgu.class.php @@ -31,8 +31,9 @@ class databox_cgu foreach ($terms as $name => $term) { if (trim($term['terms']) == '') + { continue; - + } $out .= '