mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Move static::guest_allowed method to Application
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
@@ -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'));
|
||||
}
|
||||
|
||||
|
@@ -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";
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{% if guest_allowed %}
|
||||
{% if app.isGuestAllowed() %}
|
||||
<div class="well-large sidebar-block">
|
||||
<div class="row-fluid">
|
||||
<div class="span12 text-center">
|
||||
|
@@ -110,8 +110,8 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include "login/include/register-link-block.html.twig" with {"login" : login, "last_item" : app['registration.enabled'] and not guest_allowed} %}
|
||||
{% include "login/include/guest-access-block.html.twig" with {"guest_allowed" : guest_allowed, "last_item" : guest_allowed} %}
|
||||
{% include "login/include/register-link-block.html.twig" %}
|
||||
{% include "login/include/guest-access-block.html.twig" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block left_content %}
|
||||
|
Reference in New Issue
Block a user