Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
ba88fe7a
Commit
ba88fe7a
authored
Oct 14, 2014
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added users overview page for admins
parent
6544335c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
4 deletions
+59
-4
locale/nl_NL/LC_MESSAGES/archery.po
locale/nl_NL/LC_MESSAGES/archery.po
+18
-0
routes/user.php
routes/user.php
+6
-0
templates/layout.latte
templates/layout.latte
+1
-0
templates/user/list.latte
templates/user/list.latte
+22
-0
util.php
util.php
+12
-4
No files found.
locale/nl_NL/LC_MESSAGES/archery.po
View file @
ba88fe7a
...
...
@@ -200,3 +200,21 @@ msgstr "Toon/verberg kleuren"
msgid "User not found"
msgstr "Gebruiker niet gevonden"
msgid "Insufficient permissions"
msgstr "Onvoldoende gemachtigd"
msgid "Users"
msgstr "Gebruikers"
msgid "Id"
msgstr "Id"
msgid "Role"
msgstr "Rol"
msgid "admin"
msgstr "administrator"
msgid "member"
msgstr "gebruiker"
routes/user.php
View file @
ba88fe7a
...
...
@@ -166,3 +166,9 @@ $app->get('/user/:id/plot', function ($id) use ($app, $db, $user) {
$app
->
render
(
'user/plot'
,
compact
(
'dbuser'
,
'form'
,
'matches'
));
});
$app
->
get
(
'/user'
,
function
()
use
(
$app
,
$db
)
{
require_admin_access
();
$users
=
$db
->
table
(
'user'
)
->
order
(
'id'
);
$app
->
render
(
'user/list'
,
compact
(
'users'
));
});
templates/layout.latte
View file @
ba88fe7a
...
...
@@ -2,6 +2,7 @@
['matches', _('Matches')],
["user/{$user->getId()}", _('Profile')],
["user/{$user->getId()}/plot", _('Progress graph')],
$user->isInRole('admin') ? ['user', _('Users')],
['logout', _('Logout')],
] : [
['login', _('Login')],
...
...
templates/user/list.latte
0 → 100644
View file @
ba88fe7a
{extends '../layout.latte'}
{block content}
<h2 class="page-header">{_'Users'}</h2>
<table id="results" class="table table-hover matches">
<thead>
<tr>
<th>{_'Id'}</th>
<th>{_'Username'}</th>
<th>{_'Role'}</th>
</tr>
</thead>
<tbody>
<tr n:foreach="$users as $user" data-href="user/{$user->id}">
<td>{$user->id}</td>
<td>{$user->username}</td>
<td>{_$user->role}</td>
</tr>
</tbody>
</table>
{/block}
util.php
View file @
ba88fe7a
...
...
@@ -51,8 +51,18 @@ function require_user_access($user_id) {
if
(
!
$user
->
isLoggedIn
())
$app
->
redirect
(
ROOT_URL
.
'/login'
);
if
(
$user
->
getId
()
!=
$user_id
&&
!
in_array
(
'admin'
,
$user
->
getRoles
()))
$app
->
halt
(
403
,
_
(
'No access to this user'
));
if
(
$user
->
getId
()
!=
$user_id
&&
!
$user
->
isInRole
(
'admin'
))
$app
->
halt
(
403
,
_
(
'Insufficient permissions'
));
}
function
require_admin_access
()
{
global
$user
,
$app
;
if
(
!
$user
->
isLoggedIn
())
$app
->
redirect
(
ROOT_URL
.
'/login'
);
if
(
!
$user
->
isInRole
(
'admin'
))
$app
->
halt
(
403
,
_
(
'Insufficient permissions'
));
}
function
find_match
(
$id
)
{
...
...
@@ -99,8 +109,6 @@ class UserHelper {
private
$user
;
public
function
__construct
(
IRow
$dbuser
)
{
global
$db
;
$this
->
db
=
$db
;
$this
->
user
=
$dbuser
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment