Add helpers for the user session and fix bug edit_user admin checkbox
This commit is contained in:
@@ -2,6 +2,16 @@
|
||||
|
||||
namespace Helper;
|
||||
|
||||
function is_current_user($user_id)
|
||||
{
|
||||
return $_SESSION['user']['id'] == $user_id;
|
||||
}
|
||||
|
||||
function is_admin()
|
||||
{
|
||||
return $_SESSION['user']['is_admin'] == 1;
|
||||
}
|
||||
|
||||
function markdown($text)
|
||||
{
|
||||
require_once __DIR__.'/../vendor/Michelf/MarkdownExtra.inc.php';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<section id="main">
|
||||
<div class="page-header">
|
||||
<h2><?= t('Projects') ?><span id="page-counter"> (<?= $nb_projects ?>)</span></h2>
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<ul>
|
||||
<li><a href="?controller=project&action=create"><?= t('New project') ?></a></li>
|
||||
</ul>
|
||||
@@ -18,7 +18,7 @@
|
||||
<th><?= t('Tasks') ?></th>
|
||||
<th><?= t('Board') ?></th>
|
||||
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<th><?= t('Actions') ?></th>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
@@ -56,7 +56,7 @@
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</td>
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<ul>
|
||||
<li><a href="?controller=board&action=show&project_id=<?= $project['id'] ?>"><?= t('Back to the board') ?></a></li>
|
||||
<li><a href="?controller=project&action=index"><?= t('List of projects') ?></a></li>
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<li><a href="?controller=project&action=create"><?= t('New project') ?></a></li>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<?= Helper\form_label(t('Default Project'), 'default_project_id') ?>
|
||||
<?= Helper\form_select('default_project_id', $projects, $values, $errors) ?><br/>
|
||||
|
||||
<?php if ($values['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<?= Helper\form_checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?>
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<section id="main">
|
||||
<div class="page-header">
|
||||
<h2><?= t('Users') ?><span id="page-counter"> (<?= $nb_users ?>)</span></h2>
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<ul>
|
||||
<li><a href="?controller=user&action=create"><?= t('New user') ?></a></li>
|
||||
</ul>
|
||||
@@ -30,10 +30,10 @@
|
||||
<?= (isset($user['default_project_id']) && isset($projects[$user['default_project_id']])) ? $projects[$user['default_project_id']] : t('None'); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1 || $_SESSION['user']['id'] == $user['id']): ?>
|
||||
<?php if (Helper\is_admin() || Helper\is_current_user($user['id'])): ?>
|
||||
<a href="?controller=user&action=edit&user_id=<?= $user['id'] ?>"><?= t('edit') ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
|
||||
<?php if (Helper\is_admin()): ?>
|
||||
<?php if (count($users) > 1): ?>
|
||||
<?= t('or') ?>
|
||||
<a href="?controller=user&action=confirm&user_id=<?= $user['id'] ?>"><?= t('remove') ?></a>
|
||||
|
||||
Reference in New Issue
Block a user