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
10e32f5c
Commit
10e32f5c
authored
Oct 10, 2014
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix + made account editing actions responsive
parent
105ca2d9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
routes/user.php
routes/user.php
+5
-9
templates/user/edit.latte
templates/user/edit.latte
+18
-1
util.php
util.php
+10
-0
No files found.
routes/user.php
View file @
10e32f5c
...
@@ -5,14 +5,9 @@ use Instante\Bootstrap3Renderer\BootstrapRenderer;
...
@@ -5,14 +5,9 @@ use Instante\Bootstrap3Renderer\BootstrapRenderer;
use
Nette\Security\Passwords
;
use
Nette\Security\Passwords
;
function
find_user
(
$id
)
{
function
find_user
(
$id
)
{
global
$app
,
$db
,
$user
;
global
$app
,
$db
;
if
(
!
$user
->
isLoggedIn
())
$app
->
redirect
(
ROOT_URL
.
'/login'
);
if
(
$user
->
getId
()
!=
$id
&&
!
in_array
(
'admin'
,
$user
->
getRoles
()))
$app
->
halt
(
403
,
_
(
'No access to this user'
));
require_user_access
(
$id
);
$dbuser
=
$db
->
table
(
'user'
)
->
get
(
$id
);
$dbuser
=
$db
->
table
(
'user'
)
->
get
(
$id
);
if
(
!
$dbuser
)
if
(
!
$dbuser
)
...
@@ -51,8 +46,9 @@ $app->get('/user/:id', function ($id) use ($app, $db) {
...
@@ -51,8 +46,9 @@ $app->get('/user/:id', function ($id) use ($app, $db) {
});
});
$app
->
get
(
'/user/:id/edit'
,
function
(
$id
)
use
(
$app
)
{
$app
->
get
(
'/user/:id/edit'
,
function
(
$id
)
use
(
$app
)
{
$form
=
edit_user_form
(
find_user
(
$id
));
$dbuser
=
find_user
(
$id
);
$app
->
render
(
'user/edit'
,
compact
(
'form'
));
$form
=
edit_user_form
(
$dbuser
);
$app
->
render
(
'user/edit'
,
compact
(
'dbuser'
,
'form'
));
});
});
$app
->
put
(
'/user/:id'
,
function
(
$id
)
use
(
$app
)
{
$app
->
put
(
'/user/:id'
,
function
(
$id
)
use
(
$app
)
{
$dbuser
=
find_user
(
$id
);
$dbuser
=
find_user
(
$id
);
...
...
templates/user/edit.latte
View file @
10e32f5c
...
@@ -2,5 +2,22 @@
...
@@ -2,5 +2,22 @@
{block content}
{block content}
<h2 class="page-header">{_'Edit account'}</h2>
<h2 class="page-header">{_'Edit account'}</h2>
{$form}
{form $form}
{form errors}
{form controls}
<div class="form-group">
<div class="form-actions col-sm-offset-2 col-sm-10">
<div class="btn-group actions actions-responsive">
<a href="user/{$dbuser->id}" class="btn btn-default" title="{_'Cancel'}">
<span class="glyphicon glyphicon-remove"></span>
<span class="text">{_'Cancel'}</span>
</a>
<button type="submit" name="send" class="btn btn-primary" title="{_'Save'}">
<span class="glyphicon glyphicon-ok"></span>
<span class="text">{_'Save'}</span>
</button>
</div>
</div>
</div>
{/form}
{/block}
{/block}
util.php
View file @
10e32f5c
...
@@ -45,6 +45,16 @@ function set_accept_locale($supported_languages=null) {
...
@@ -45,6 +45,16 @@ function set_accept_locale($supported_languages=null) {
return
null
;
return
null
;
}
}
function
require_user_access
(
$user_id
)
{
global
$user
,
$app
;
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'
));
}
function
find_match
(
$id
)
{
function
find_match
(
$id
)
{
global
$app
,
$db
,
$user
;
global
$app
,
$db
,
$user
;
$match
=
$db
->
table
(
'match'
)
->
get
(
$id
);
$match
=
$db
->
table
(
'match'
)
->
get
(
$id
);
...
...
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