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