{% macro users(view) %} {% import "macros/widgets.html.twig" as widgets %} {% set actions = {'search': {'class': 'search-toggle visible-xs-inline'}} %} {% if view == 'index' %} {% set actions = actions|merge({'visibility': '#modal_user_admin'}) %} {% else %} {% set actions = actions|merge({'back': path('admin_user')}) %} {% endif %} {% set actions = actions|merge({'download': {'url': path('user_export'), 'class': 'toolbar-action'}}) %} {% if is_granted('create_user') %} {% set actions = actions|merge({'create': {'url': path('admin_user_create')}}) %} {% endif %} {% if view == 'index' %} {% set actions = actions|merge({'help': {'url': 'users.html'|docu_link, 'target': '_blank'}}) %} {% elseif view == 'permissions' %} {% set actions = actions|merge({'help': {'url': 'permissions.html'|docu_link, 'target': '_blank'}}) %} {% endif %} {% set actions = actions|merge({'help': {'url': 'users.html'|docu_link, 'target': '_blank'}}) %} {% set event = trigger('actions.users', {'actions': actions, 'view': view}) %} {{ widgets.page_actions(event.payload.actions) }} {% endmacro %} {% macro user_permissions(view) %} {% import "macros/widgets.html.twig" as widgets %} {% set actions = {} %} {% if view != 'index' and is_granted('role_permissions') %} {% set actions = actions|merge({'permissions': path('admin_user_permissions')}) %} {% endif %} {% if view != 'role' and is_granted('role_permissions') %} {% set actions = actions|merge({'create': {'url': path('admin_user_roles'), 'class': 'modal-ajax-form'}}) %} {% endif %} {% set actions = actions|merge({'help': {'url': 'permissions.html'|docu_link, 'target': '_blank'}}) %} {% set event = trigger('actions.user_permissions', {'actions': actions, 'view': view}) %} {{ widgets.page_actions(event.payload.actions) }} {% endmacro %} {% macro user(user, view, options) %} {% import "macros/widgets.html.twig" as widgets %} {% set actions = {} %} {% if user.id is not empty %} {% set view_other = is_granted('view_other_timesheet') %} {% if is_granted('view', user) %} {% set actions = actions|merge({'profile-stats': {'url': path('user_profile', {'username' : user.username})}}) %} {% endif %} {% if actions|length > 0 %} {% set actions = actions|merge({'divider': null}) %} {% endif %} {% set subActions = {} %} {% if is_granted('edit', user) %} {% set subActions = subActions|merge({'edit': path('user_profile_edit', {'username' : user.username})}) %} {% endif %} {% if is_granted('preferences', user) %} {% set subActions = subActions|merge({'settings': {'url': path('user_profile_preferences', {'username' : user.username})}}) %} {% endif %} {% if is_granted('password', user) %} {% set subActions = subActions|merge({'password': {'url': path('user_profile_password', {'username' : user.username}), 'title': ('profile.password'|trans)}}) %} {% endif %} {% if is_granted('api-token', user) %} {% set subActions = subActions|merge({'api-token': {'url': path('user_profile_api_token', {'username' : user.username}), 'title': ('profile.api-token'|trans)}}) %} {% endif %} {% if is_granted('teams', user) %} {% set subActions = subActions|merge({'teams': {'url': path('user_profile_teams', {'username' : user.username}), 'title': ('profile.teams'|trans)}}) %} {% endif %} {% if is_granted('roles', user) %} {% set subActions = subActions|merge({'roles': {'url': path('user_profile_roles', {'username' : user.username}), 'title': ('profile.roles'|trans)}}) %} {% endif %} {% if subActions|length > 0 %} {% set actions = actions|merge(subActions) %} {% set actions = actions|merge({'divider2': null}) %} {% endif %} {% if is_granted('view_reporting') %} {% if view_other or app.user.id == user.id %} {% set actions = actions|merge({'report': path('report_user_month', {'user': user.id})}) %} {% endif %} {% endif %} {% if view_other and user.enabled %} {% set actions = actions|merge({'timesheet': path('admin_timesheet', {'users': [user.id]})}) %} {% endif %} {% if view == 'index' and is_granted('delete', user) %} {% set actions = actions|merge({'trash': {'url': path('admin_user_delete', {'id': user.id}), 'class': 'modal-ajax-form'}}) %} {% endif %} {% endif %} {% if options.back is defined %} {% set actions = actions|merge({'back': options.back}) %} {% endif %} {% set event = trigger('actions.user', {'actions': actions, 'view': view, 'user': user}) %} {% if view == 'index' %} {{ widgets.table_actions(event.payload.actions) }} {% else %} {{ widgets.entity_actions(event.payload.actions) }} {% endif %} {% endmacro %}