{% extends "PackagistWebBundle::layout.html.twig" %}

{% import "PackagistWebBundle::macros.html.twig" as macros %}

{% block head_additions %}
    {% if user.hasRole('ROLE_SPAMMER') %}
        <meta name="robots" content="noindex, nofollow">
    {% endif %}
{% endblock %}

{% block content %}
{% set isActualUser = app.user and app.user.username is same as(user.username) %}
<h2 class="title">
    {{ user.username }}
    <small>
        {% if is_granted('ROLE_ANTISPAM') and user.hasRole('ROLE_SPAMMER') %}
            [SPAMMER]
        {% endif %}
        {{ 'user.member_since'|trans }}: {{ user.createdAt|date('M d, Y') }}
        {%- if is_granted('ROLE_ADMIN') %}
            <a href="mailto:{{ user.email }}">{{ user.email }}</a>
        {%- endif %}
        {%- if deleteForm is defined and (is_granted('ROLE_ADMIN') or isActualUser) %}
            <form class="delete action" action="{{ path('user_delete', {name: user.username}) }}" method="POST">
                {{ form_widget(deleteForm._token) }}
                <input class="btn btn-danger" type="submit" value="Delete Account Permanently" onclick="return confirm('Are you sure? There is no way back..');" />
            </form>
        {%- endif %}
        {%- if is_granted('ROLE_ANTISPAM') %}
            <form class="delete action" action="{{ path('mark_spammer', {name: user.username}) }}" method="POST">
                {{ form_widget(spammerForm._token) }}
                <input class="btn btn-danger" type="submit" value="Mark as Spammer" />
            </form>
        {%- endif %}
    </small>
</h2>

<section class="row">
    <section class="col-md-12">
        {% embed "PackagistWebBundle:web:list.html.twig" with {noLayout: 'true', showAutoUpdateWarning: isActualUser} %}
            {% block content_title %}
                <h3 class="font-normal profile-title">{{ 'user.packages'|trans({ '%username%':user.username }) }}</h3>
            {% endblock %}
        {% endembed %}
    </section>
</section>
{% endblock %}
