diff --git a/classes/admin.php b/classes/admin.php index 6809b73d..7fc80826 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -273,6 +273,11 @@ class Admin $obj->merge($post); $obj->file($file); + $data[$type] = $obj; + } elseif (preg_match('|users/|', $type)) { + $obj = User::load(preg_replace('|users/|', '', $type)); + $obj->merge($post); + $data[$type] = $obj; } else { throw new \RuntimeException("Data type '{$type}' doesn't exist!"); diff --git a/themes/grav/templates/partials/nav.html.twig b/themes/grav/templates/partials/nav.html.twig index 2645c0e4..f35da397 100644 --- a/themes/grav/templates/partials/nav.html.twig +++ b/themes/grav/templates/partials/nav.html.twig @@ -7,7 +7,7 @@
-

{{ admin.user.fullname }}

+

{{ admin.user.fullname }}

{{ admin.user.title }}
diff --git a/themes/grav/templates/partials/users-details.html.twig b/themes/grav/templates/partials/users-details.html.twig new file mode 100644 index 00000000..fbaa9d0b --- /dev/null +++ b/themes/grav/templates/partials/users-details.html.twig @@ -0,0 +1,17 @@ +{% if user.exists %} +
+ +

{{ user.fullname }}{% if user.title %} ({{ user.title }}){% endif %}

+
+{% else %} +

Create new user

+{% endif %} + +{% include 'partials/blueprints.html.twig' with { data: user, blueprints: user.blueprints } %} + +{% if user.exists and admin.user.username != user.username %} +
+ + Remove User +
+{% endif %} diff --git a/themes/grav/templates/partials/users-list.html.twig b/themes/grav/templates/partials/users-list.html.twig new file mode 100644 index 00000000..a4b40b7d --- /dev/null +++ b/themes/grav/templates/partials/users-list.html.twig @@ -0,0 +1,6 @@ +
+ {% for user in admin.users %} +
+
+ {% endfor %} +
diff --git a/themes/grav/templates/users.html.twig b/themes/grav/templates/users.html.twig index 25a632d5..7112e541 100644 --- a/themes/grav/templates/users.html.twig +++ b/themes/grav/templates/users.html.twig @@ -1,14 +1,32 @@ {% extends 'partials/base.html.twig' %} +{% if admin.route %} +{% set user = admin.data('users/' ~ admin.route) %} +{% endif %} + +{% block titlebar %} + {% if not admin.route %} +
+ +
+

Users

+ {% else %} +
+ +
+

User: {{ user.username|e }}

+ {% endif %} +{% endblock %} {% block content %} - -
-

- Users -

- +
{% include 'partials/messages.html.twig' %} + + {% if not admin.route %} + {% include 'partials/users-list.html.twig' %} + {% else %} + {% include 'partials/users-details.html.twig' %} + {% endif %}
{% endblock %}