Commit 10e32f5c authored by Taddeus Kroes's avatar Taddeus Kroes

Bugfix + made account editing actions responsive

parent 105ca2d9
......@@ -5,14 +5,9 @@ use Instante\Bootstrap3Renderer\BootstrapRenderer;
use Nette\Security\Passwords;
function find_user($id) {
global $app, $db, $user;
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'));
global $app, $db;
require_user_access($id);
$dbuser = $db->table('user')->get($id);
if (!$dbuser)
......@@ -51,8 +46,9 @@ $app->get('/user/:id', function ($id) use ($app, $db) {
});
$app->get('/user/:id/edit', function ($id) use ($app) {
$form = edit_user_form(find_user($id));
$app->render('user/edit', compact('form'));
$dbuser = find_user($id);
$form = edit_user_form($dbuser);
$app->render('user/edit', compact('dbuser', 'form'));
});
$app->put('/user/:id', function ($id) use ($app) {
$dbuser = find_user($id);
......
......@@ -2,5 +2,22 @@
{block content}
<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}
......@@ -45,6 +45,16 @@ function set_accept_locale($supported_languages=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) {
global $app, $db, $user;
$match = $db->table('match')->get($id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment