post('/deny/{sbas_id}/', $this->call('denyTermsOfUse')) ->bind('deny_tou') ->before(function(Request $request) use ($app) { $app['firewall']->requireAuthentication(); }); /** * Display Terms of use * * name : get_tou * * description : Display Terms of use * * method : GET * * parameters : none * * return : HTML Response */ $controllers->get('/', $this->call('displayTermsOfUse')) ->bind('get_tou'); return $controllers; } /** * Deny database terms of use * * @param Application $app * @param Request $request * @param integer $sbas_id * @return JsonResponse */ public function denyTermsOfUse(Application $app, Request $request, $sbas_id) { $ret = array('success' => false, 'message' => ''); try { $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $app['authentication']->getUser()->ACL()->revoke_access_from_bases( array_keys($app['authentication']->getUser()->ACL()->get_granted_base(array(), array($databox->get_sbas_id()))) ); $app['authentication']->getUser()->ACL()->revoke_unused_sbas_rights(); $app['authentication']->closeAccount(); $ret['success'] = true; } catch (\Exception $e) { } return $app->json($ret); } /** * Display database terms of use * * @param Application $app * @param Request $request * @return Response */ public function displayTermsOfUse(Application $app, Request $request) { $toDisplay = $request->query->get('to_display', array()); $data = array(); foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { if (count($toDisplay) > 0 && !in_array($databox->get_sbas_id(), $toDisplay)) { continue; } $cgus = $databox->get_cgus(); if (!isset($cgus[$app['locale']])) { continue; } $data[$databox->get_viewname()] = $cgus[$app['locale']]['value']; } return new Response($app['twig']->render('/prod/TOU.html.twig', array( 'TOUs' => $data, 'local_title' => _('Terms of use') ))); } /** * Prefix the method to call with the controller class name * * @param string $method The method to call * @return string */ private function call($method) { return sprintf('%s::%s', __CLASS__, $method); } }