Unverified Commit 85e74a57 authored by Sebastian Castro's avatar Sebastian Castro
Browse files

UserSpace Conditional display menu depending on config

parent ceb0357f
......@@ -4,6 +4,7 @@ namespace App\Controller;
use App\Document\Coordinates;
use App\Document\InteractionType;
use App\Services\ConfigurationService;
use App\Form\UserProfileType;
use Doctrine\ODM\MongoDB\DocumentManager;
use Geocoder\ProviderAggregator;
......@@ -13,9 +14,15 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
class UserController extends GoGoController
{
public function userSpaceAction()
public function userSpaceAction(ConfigurationService $confService)
{
return $this->render('user/user-space.html.twig');
if ($confService->isUserAllowed('add') || $confService->isUserAllowed('edit') ||
$confService->isUserAllowed('vote') || $confService->isUserAllowed('report')) {
return $this->render('user/user-space.html.twig');
} else {
return $this->redirectToRoute('gogo_user_profile');
}
}
public function contributionsAction(DocumentManager $dm)
......
......@@ -3,6 +3,7 @@
namespace App\Twig;
use App\Helper\SaasHelper;
use App\Services\ConfigurationService;
use Doctrine\ODM\MongoDB\DocumentManager;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
......@@ -10,9 +11,10 @@ use Twig\TwigFunction;
class AppExtension extends AbstractExtension
{
public function __construct(DocumentManager $dm)
public function __construct(DocumentManager $dm, ConfigurationService $configService)
{
$this->dm = $dm;
$this->configService = $configService;
}
public function getFilters()
......@@ -39,6 +41,7 @@ class AppExtension extends AbstractExtension
new TwigFunction('is_root_project', [$this, 'isRootProject']),
new TwigFunction('new_msgs_count', [$this, 'getNewMessagesCount']),
new TwigFunction('errors_count', [$this, 'getErrorsCount']),
new TwigFunction('is_user_allowed', [$this, 'isUserAllowed']),
];
}
......@@ -58,4 +61,9 @@ class AppExtension extends AbstractExtension
{
return count($this->dm->getRepository('App\Document\GoGoLog')->findBy(['level' => 'error', 'hidden' => false]));
}
public function isUserAllowed($featureName)
{
return $this->configService->isUserAllowed($featureName);
}
}
......@@ -3,26 +3,44 @@
{# BODY CONTENT #}
{% block body_content %}
{% block body_user_before_content %}
{% endblock %}
<i class="gogo-icon-menu menu-user-button" onclick="showMenu()"></i>
<div id="menu-overlay" onclick="hideMenu()"></div>
<div id="menu-user" class="menu-user side-nav">
<ul>
<li class="title">Menu</li>
<a href="{{ path('gogo_user_profile') }}"> <li><i class="gogo-icon-filters-1"></i>Mes Paramètres</li></a>
<a href="{{ path('gogo_user_contributions') }}"><li><i class="gogo-icon-edit"></i>Mes contributions</li></a>
<a href="{{ path('gogo_user_votes') }}"> <li><i class="gogo-icon-vote"></i>Mes votes</li></a>
<a href="{{ path('gogo_user_reports') }}"> <li><i class="gogo-icon-exclamation-1"></i>Mes signalements</li></a>
</ul>
</div>
<section>
{% block body_user_content %}
{% block body_user_before_content %}
{% endblock %}
</section>
<i class="gogo-icon-menu menu-user-button" onclick="showMenu()"></i>
<div id="menu-overlay" onclick="hideMenu()"></div>
{% if is_user_allowed('add') or is_user_allowed('edit') or is_user_allowed('vote') or is_user_allowed('report') %}
<div id="menu-user" class="menu-user side-nav">
<ul>
<li class="title">Menu</li>
<a href="{{ path('gogo_user_profile') }}">
<li><i class="gogo-icon-filters-1"></i>Mes Paramètres</li>
</a>
{% if is_user_allowed('add') or is_user_allowed('edit') %}
<a href="{{ path('gogo_user_contributions') }}"><li><i class="gogo-icon-edit"></i>Mes contributions</li></a>
{% endif %}
{% if is_user_allowed('vote') %}
<a href="{{ path('gogo_user_votes') }}">
<li><i class="gogo-icon-vote"></i>Mes votes</li>
</a>
{% endif %}
{% if is_user_allowed('report') %}
<a href="{{ path('gogo_user_reports') }}">
<li><i class="gogo-icon-exclamation-1"></i>Mes signalements</li>
</a>
{% endif %}
</ul>
</div>
{% endif %}
<section>
{% block body_user_content %}
{% endblock %}
</section>
{% endblock %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment