diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index ab5842ab14..8e179e63ac 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -682,6 +682,17 @@ class Application extends SilexApplication return false; } + public function isGuestAllowed() + { + $usrId = \User_Adapter::get_usr_id_from_login($this, 'invite'); + + if (!$usrId) { + return false; + } + + return count(\User_Adapter::getInstance($usrId, $this)->ACL()->get_granted_base()) > 0; + } + /** * Returns an an array of available collection for offline queries * diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index bdbf98dab6..e4d3342025 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -704,7 +704,6 @@ class Login implements ControllerProviderInterface 'unlock_usr_id' => $app->getUnlockAccountData(), 'login' => new \login(), 'feeds' => $feeds, - 'guest_allowed' => \phrasea::guest_allowed($app), 'form' => $form->createView(), )); } @@ -732,7 +731,7 @@ class Login implements ControllerProviderInterface public function authenticateAsGuest(PhraseaApplication $app, Request $request) { - if (!\phrasea::guest_allowed($app)) { + if (!$app->isGuestAllowed()) { $app->abort(403, _('Phraseanet guest-access is disabled')); } diff --git a/lib/classes/phrasea.php b/lib/classes/phrasea.php index 2388c1075d..618a62a856 100644 --- a/lib/classes/phrasea.php +++ b/lib/classes/phrasea.php @@ -87,17 +87,6 @@ class phrasea return self::$_sbas_params; } - public static function guest_allowed(Application $app) - { - $usr_id = User_Adapter::get_usr_id_from_login($app, 'invite'); - if (!$usr_id) { - return false; - } - $user = User_Adapter::getInstance($usr_id, $app); - - return count($user->ACL()->get_granted_base()) > 0; - } - public static function use_i18n($locale, $textdomain = 'phraseanet') { $codeset = "UTF-8"; diff --git a/templates/web/login/include/guest-access-block.html.twig b/templates/web/login/include/guest-access-block.html.twig index 9d775ca4cd..60f4edfaf2 100644 --- a/templates/web/login/include/guest-access-block.html.twig +++ b/templates/web/login/include/guest-access-block.html.twig @@ -1,4 +1,4 @@ -{% if guest_allowed %} +{% if app.isGuestAllowed() %}