diff options
Diffstat (limited to 'app/Template')
48 files changed, 299 insertions, 214 deletions
diff --git a/app/Template/activity/project.php b/app/Template/activity/project.php index bc585212..34be06f5 100644 --- a/app/Template/activity/project.php +++ b/app/Template/activity/project.php @@ -19,7 +19,7 @@ <i class="fa fa-calendar fa-fw"></i> <?= $this->url->link(t('Back to the calendar'), 'calendar', 'show', array('project_id' => $project['id'])) ?> </li> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <li> <i class="fa fa-cog fa-fw"></i> <?= $this->url->link(t('Project settings'), 'project', 'show', array('project_id' => $project['id'])) ?> diff --git a/app/Template/analytic/layout.php b/app/Template/analytic/layout.php index fd2090ae..3bb6ff6e 100644 --- a/app/Template/analytic/layout.php +++ b/app/Template/analytic/layout.php @@ -19,7 +19,7 @@ <i class="fa fa-calendar fa-fw"></i> <?= $this->url->link(t('Back to the calendar'), 'calendar', 'show', array('project_id' => $project['id'])) ?> </li> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <li> <i class="fa fa-cog fa-fw"></i> <?= $this->url->link(t('Project settings'), 'project', 'show', array('project_id' => $project['id'])) ?> diff --git a/app/Template/app/layout.php b/app/Template/app/layout.php index 4f82121e..ad1d5a9e 100644 --- a/app/Template/app/layout.php +++ b/app/Template/app/layout.php @@ -1,7 +1,7 @@ <section id="main"> <div class="page-header page-header-mobile"> <ul> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('project', 'create')): ?> <li> <i class="fa fa-plus fa-fw"></i> <?= $this->url->link(t('New project'), 'project', 'create') ?> @@ -9,7 +9,7 @@ <?php endif ?> <li> <i class="fa fa-lock fa-fw"></i> - <?= $this->url->link(t('New private project'), 'project', 'create', array('private' => 1)) ?> + <?= $this->url->link(t('New private project'), 'project', 'createPrivate') ?> </li> <li> <i class="fa fa-search fa-fw"></i> @@ -19,7 +19,7 @@ <i class="fa fa-folder fa-fw"></i> <?= $this->url->link(t('Project management'), 'project', 'index') ?> </li> - <?php if ($this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('user', 'index')): ?> <li> <i class="fa fa-user fa-fw"></i> <?= $this->url->link(t('User management'), 'user', 'index') ?> diff --git a/app/Template/app/projects.php b/app/Template/app/projects.php index cf22707b..f9267e39 100644 --- a/app/Template/app/projects.php +++ b/app/Template/app/projects.php @@ -22,7 +22,7 @@ <?php endif ?> </td> <td> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <?= $this->url->link('<i class="fa fa-sliders fa-fw"></i>', 'gantt', 'project', array('project_id' => $project['id']), false, 'dashboard-table-link', t('Gantt chart')) ?> <?php endif ?> diff --git a/app/Template/board/popover_assignee.php b/app/Template/board/popover_assignee.php index 4af19cf7..f395113c 100644 --- a/app/Template/board/popover_assignee.php +++ b/app/Template/board/popover_assignee.php @@ -1,7 +1,7 @@ <section id="main"> <section> <h3><?= t('Change assignee for the task "%s"', $values['title']) ?></h3> - <form method="post" action="<?= $this->url->href('board', 'updateAssignee', array('task_id' => $values['id'], 'project_id' => $values['project_id'])) ?>"> + <form method="post" action="<?= $this->url->href('BoardPopover', 'updateAssignee', array('task_id' => $values['id'], 'project_id' => $values['project_id'])) ?>"> <?= $this->form->csrf() ?> diff --git a/app/Template/board/popover_category.php b/app/Template/board/popover_category.php index f391f492..8c2a273d 100644 --- a/app/Template/board/popover_category.php +++ b/app/Template/board/popover_category.php @@ -1,7 +1,7 @@ <section id="main"> <section> <h3><?= t('Change category for the task "%s"', $values['title']) ?></h3> - <form method="post" action="<?= $this->url->href('board', 'updateCategory', array('task_id' => $values['id'], 'project_id' => $values['project_id'])) ?>"> + <form method="post" action="<?= $this->url->href('BoardPopover', 'updateCategory', array('task_id' => $values['id'], 'project_id' => $values['project_id'])) ?>"> <?= $this->form->csrf() ?> diff --git a/app/Template/board/table_column.php b/app/Template/board/table_column.php index b6a38872..10bcfa08 100644 --- a/app/Template/board/table_column.php +++ b/app/Template/board/table_column.php @@ -12,7 +12,7 @@ <!-- column in expanded mode --> <div class="board-column-expanded"> - <?php if (! $not_editable): ?> + <?php if (! $not_editable && $this->user->hasProjectAccess('taskcreation', 'create', $column['project_id'])): ?> <div class="board-add-icon"> <?= $this->url->link('+', 'taskcreation', 'create', array('project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']), false, 'popover', t('Add a new task')) ?> </div> diff --git a/app/Template/board/table_swimlane.php b/app/Template/board/table_swimlane.php index dd38fc97..44607859 100644 --- a/app/Template/board/table_swimlane.php +++ b/app/Template/board/table_swimlane.php @@ -14,7 +14,7 @@ <span title="<?= t('Description') ?>" class="tooltip" - data-href="<?= $this->url->href('board', 'swimlane', array('swimlane_id' => $swimlane['id'], 'project_id' => $project['id'])) ?>"> + data-href="<?= $this->url->href('BoardTooltip', 'swimlane', array('swimlane_id' => $swimlane['id'], 'project_id' => $project['id'])) ?>"> <i class="fa fa-info-circle"></i> </span> <?php endif ?> diff --git a/app/Template/board/task_footer.php b/app/Template/board/task_footer.php index d486b638..e29384dc 100644 --- a/app/Template/board/task_footer.php +++ b/app/Template/board/task_footer.php @@ -27,31 +27,31 @@ <?php endif ?> <?php if ($task['recurrence_status'] == \Kanboard\Model\Task::RECURRING_STATUS_PENDING): ?> - <span title="<?= t('Recurrence') ?>" class="tooltip" data-href="<?= $this->url->href('board', 'recurrence', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-refresh fa-rotate-90"></i></span> + <span title="<?= t('Recurrence') ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'recurrence', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-refresh fa-rotate-90"></i></span> <?php endif ?> <?php if ($task['recurrence_status'] == \Kanboard\Model\Task::RECURRING_STATUS_PROCESSED): ?> - <span title="<?= t('Recurrence') ?>" class="tooltip" data-href="<?= $this->url->href('board', 'recurrence', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-refresh fa-rotate-90 fa-inverse"></i></span> + <span title="<?= t('Recurrence') ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'recurrence', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-refresh fa-rotate-90 fa-inverse"></i></span> <?php endif ?> <?php if (! empty($task['nb_links'])): ?> - <span title="<?= t('Links') ?>" class="tooltip" data-href="<?= $this->url->href('board', 'tasklinks', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-code-fork"></i> <?= $task['nb_links'] ?></span> + <span title="<?= t('Links') ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'tasklinks', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-code-fork"></i> <?= $task['nb_links'] ?></span> <?php endif ?> <?php if (! empty($task['nb_subtasks'])): ?> - <span title="<?= t('Sub-Tasks') ?>" class="tooltip" data-href="<?= $this->url->href('board', 'subtasks', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-bars"></i> <?= round($task['nb_completed_subtasks']/$task['nb_subtasks']*100, 0).'%' ?></span> + <span title="<?= t('Sub-Tasks') ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'subtasks', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-bars"></i> <?= round($task['nb_completed_subtasks']/$task['nb_subtasks']*100, 0).'%' ?></span> <?php endif ?> <?php if (! empty($task['nb_files'])): ?> - <span title="<?= t('Attachments') ?>" class="tooltip" data-href="<?= $this->url->href('board', 'attachments', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-paperclip"></i> <?= $task['nb_files'] ?></span> + <span title="<?= t('Attachments') ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'attachments', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-paperclip"></i> <?= $task['nb_files'] ?></span> <?php endif ?> <?php if (! empty($task['nb_comments'])): ?> - <span title="<?= $task['nb_comments'] == 1 ? t('%d comment', $task['nb_comments']) : t('%d comments', $task['nb_comments']) ?>" class="tooltip" data-href="<?= $this->url->href('board', 'comments', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-comment-o"></i> <?= $task['nb_comments'] ?></span> + <span title="<?= $task['nb_comments'] == 1 ? t('%d comment', $task['nb_comments']) : t('%d comments', $task['nb_comments']) ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'comments', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"><i class="fa fa-comment-o"></i> <?= $task['nb_comments'] ?></span> <?php endif ?> <?php if (! empty($task['description'])): ?> - <span title="<?= t('Description') ?>" class="tooltip" data-href="<?= $this->url->href('board', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"> + <span title="<?= t('Description') ?>" class="tooltip" data-href="<?= $this->url->href('BoardTooltip', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"> <i class="fa fa-file-text-o"></i> </span> <?php endif ?> diff --git a/app/Template/board/task_menu.php b/app/Template/board/task_menu.php index 3eb35705..b5ed125d 100644 --- a/app/Template/board/task_menu.php +++ b/app/Template/board/task_menu.php @@ -1,13 +1,13 @@ <span class="dropdown"> <a href="#" class="dropdown-menu"><?= '#'.$task['id'] ?></a> <ul> - <li><i class="fa fa-user fa-fw"></i> <?= $this->url->link(t('Change assignee'), 'board', 'changeAssignee', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> - <li><i class="fa fa-tag fa-fw"></i> <?= $this->url->link(t('Change category'), 'board', 'changeCategory', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> + <li><i class="fa fa-user fa-fw"></i> <?= $this->url->link(t('Change assignee'), 'BoardPopover', 'changeAssignee', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> + <li><i class="fa fa-tag fa-fw"></i> <?= $this->url->link(t('Change category'), 'BoardPopover', 'changeCategory', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> <li><i class="fa fa-align-left fa-fw"></i> <?= $this->url->link(t('Change description'), 'taskmodification', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> <li><i class="fa fa-pencil-square-o fa-fw"></i> <?= $this->url->link(t('Edit this task'), 'taskmodification', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> <li><i class="fa fa-comment-o fa-fw"></i> <?= $this->url->link(t('Add a comment'), 'comment', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> <li><i class="fa fa-code-fork fa-fw"></i> <?= $this->url->link(t('Add a link'), 'tasklink', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> - <li><i class="fa fa-camera fa-fw"></i> <?= $this->url->link(t('Add a screenshot'), 'board', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> + <li><i class="fa fa-camera fa-fw"></i> <?= $this->url->link(t('Add a screenshot'), 'BoardPopover', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> <?php if ($task['is_active'] == 1): ?> <li><i class="fa fa-close fa-fw"></i> <?= $this->url->link(t('Close this task'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?></li> <?php else: ?> diff --git a/app/Template/board/task_private.php b/app/Template/board/task_private.php index da993fdd..a5d05e49 100644 --- a/app/Template/board/task_private.php +++ b/app/Template/board/task_private.php @@ -1,6 +1,6 @@ <div class=" task-board - <?= $task['is_active'] == 1 ? 'draggable-item task-board-status-open '.($task['date_modification'] > (time() - $board_highlight_period) ? 'task-board-recent' : '') : 'task-board-status-closed' ?> + <?= $task['is_active'] == 1 ? ($this->user->hasProjectAccess('board', 'save', $task['project_id']) ? 'draggable-item ' : '').'task-board-status-open '.($task['date_modification'] > (time() - $board_highlight_period) ? 'task-board-recent' : '') : 'task-board-status-closed' ?> color-<?= $task['color_id'] ?>" data-task-id="<?= $task['id'] ?>" data-owner-id="<?= $task['owner_id'] ?>" @@ -12,7 +12,11 @@ <?php if ($this->board->isCollapsed($task['project_id'])): ?> <div class="task-board-collapsed"> - <?= $this->render('board/task_menu', array('task' => $task)) ?> + <?php if ($this->user->hasProjectAccess('taskmodification', 'edit', $task['project_id'])): ?> + <?= $this->render('board/task_menu', array('task' => $task)) ?> + <?php else: ?> + <strong><?= '#'.$task['id'] ?></strong> + <?php endif ?> <?php if (! empty($task['assignee_username'])): ?> <span title="<?= $this->e($task['assignee_name'] ?: $task['assignee_username']) ?>"> @@ -23,7 +27,11 @@ </div> <?php else: ?> <div class="task-board-expanded"> - <?= $this->render('board/task_menu', array('task' => $task)) ?> + <?php if ($this->user->hasProjectAccess('taskmodification', 'edit', $task['project_id'])): ?> + <?= $this->render('board/task_menu', array('task' => $task)) ?> + <?php else: ?> + <strong><?= '#'.$task['id'] ?></strong> + <?php endif ?> <?php if ($task['reference']): ?> <span class="task-board-reference" title="<?= t('Reference') ?>"> diff --git a/app/Template/calendar/show.php b/app/Template/calendar/show.php index 0406414c..d74e945e 100644 --- a/app/Template/calendar/show.php +++ b/app/Template/calendar/show.php @@ -5,7 +5,7 @@ )) ?> <div id="calendar" - data-save-url="<?= $this->url->href('calendar', 'save') ?>" + data-save-url="<?= $this->url->href('calendar', 'save', array('project_id' => $project['id'])) ?>" data-check-url="<?= $this->url->href('calendar', 'project', array('project_id' => $project['id'])) ?>" data-check-interval="<?= $check_interval ?>" > diff --git a/app/Template/custom_filter/add.php b/app/Template/custom_filter/add.php index 61df148c..b0778b8e 100644 --- a/app/Template/custom_filter/add.php +++ b/app/Template/custom_filter/add.php @@ -12,7 +12,7 @@ <?= $this->form->label(t('Filter'), 'filter') ?> <?= $this->form->text('filter', $values, $errors, array('required', 'maxlength="100"')) ?> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <?= $this->form->checkbox('is_shared', t('Share with all project members'), 1) ?> <?php endif ?> diff --git a/app/Template/custom_filter/edit.php b/app/Template/custom_filter/edit.php index 9d296b84..683d2802 100644 --- a/app/Template/custom_filter/edit.php +++ b/app/Template/custom_filter/edit.php @@ -16,7 +16,7 @@ <?= $this->form->label(t('Filter'), 'filter') ?> <?= $this->form->text('filter', $values, $errors, array('required', 'maxlength="100"')) ?> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <?= $this->form->checkbox('is_shared', t('Share with all project members'), 1, $values['is_shared'] == 1) ?> <?php else: ?> <?= $this->form->hidden('is_shared', $values) ?> diff --git a/app/Template/custom_filter/index.php b/app/Template/custom_filter/index.php index c857e206..507e091b 100644 --- a/app/Template/custom_filter/index.php +++ b/app/Template/custom_filter/index.php @@ -32,7 +32,7 @@ </td> <td><?= $this->e($filter['owner_name'] ?: $filter['owner_username']) ?></td> <td> - <?php if ($filter['user_id'] == $this->user->getId() || $this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($filter['user_id'] == $this->user->getId() || $this->user->hasProjectAccess('customfilter', 'edit', $project['id'])): ?> <ul> <li><?= $this->url->link(t('Remove'), 'customfilter', 'remove', array('project_id' => $filter['project_id'], 'filter_id' => $filter['id']), true) ?></li> <li><?= $this->url->link(t('Edit'), 'customfilter', 'edit', array('project_id' => $filter['project_id'], 'filter_id' => $filter['id'])) ?></li> diff --git a/app/Template/gantt/projects.php b/app/Template/gantt/projects.php index 50e244a5..46d2af91 100644 --- a/app/Template/gantt/projects.php +++ b/app/Template/gantt/projects.php @@ -1,7 +1,7 @@ <section id="main"> <div class="page-header"> <ul> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('project', 'create')): ?> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New project'), 'project', 'create') ?></li> <?php endif ?> <li> @@ -10,7 +10,7 @@ <li> <i class="fa fa-folder fa-fw"></i><?= $this->url->link(t('Projects list'), 'project', 'index') ?> </li> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('projectuser', 'managers')): ?> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('Users overview'), 'projectuser', 'managers') ?></li> <?php endif ?> </ul> diff --git a/app/Template/group/dissociate.php b/app/Template/group/dissociate.php index 2b0b1af4..e1c60764 100644 --- a/app/Template/group/dissociate.php +++ b/app/Template/group/dissociate.php @@ -1,11 +1,9 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> <ul> <li><i class="fa fa-users fa-fw"></i><?= $this->url->link(t('View all groups'), 'group', 'index') ?></li> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('View group members'), 'group', 'users', array('group_id' => $group['id'])) ?></li> </ul> - <?php endif ?> </div> <div class="confirm"> <p class="alert alert-info"><?= t('Do you really want to remove the user "%s" from the group "%s"?', $user['name'] ?: $user['username'], $group['name']) ?></p> diff --git a/app/Template/group/index.php b/app/Template/group/index.php index 24de02a0..4aea0873 100644 --- a/app/Template/group/index.php +++ b/app/Template/group/index.php @@ -1,11 +1,9 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> <ul> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('All users'), 'user', 'index') ?></li> <li><i class="fa fa-user-plus fa-fw"></i><?= $this->url->link(t('New group'), 'group', 'create') ?></li> </ul> - <?php endif ?> </div> <?php if ($paginator->isEmpty()): ?> <p class="alert"><?= t('There is no group.') ?></p> @@ -31,7 +29,7 @@ <td> <ul> <li><?= $this->url->link(t('Add group member'), 'group', 'associate', array('group_id' => $group['id'])) ?></li> - <li><?= $this->url->link(t('Users'), 'group', 'users', array('group_id' => $group['id'])) ?></li> + <li><?= $this->url->link(t('Members'), 'group', 'users', array('group_id' => $group['id'])) ?></li> <li><?= $this->url->link(t('Edit'), 'group', 'edit', array('group_id' => $group['id'])) ?></li> <li><?= $this->url->link(t('Remove'), 'group', 'confirm', array('group_id' => $group['id'])) ?></li> </ul> diff --git a/app/Template/group/remove.php b/app/Template/group/remove.php index 48da91d5..1cb007b1 100644 --- a/app/Template/group/remove.php +++ b/app/Template/group/remove.php @@ -1,11 +1,9 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> <ul> <li><i class="fa fa-users fa-fw"></i><?= $this->url->link(t('View all groups'), 'group', 'index') ?></li> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('View group members'), 'group', 'users', array('group_id' => $group['id'])) ?></li> </ul> - <?php endif ?> </div> <div class="confirm"> <p class="alert alert-info"><?= t('Do you really want to remove this group: "%s"?', $group['name']) ?></p> diff --git a/app/Template/group/users.php b/app/Template/group/users.php index 56ad82cf..f79cb9ad 100644 --- a/app/Template/group/users.php +++ b/app/Template/group/users.php @@ -1,11 +1,9 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> <ul> <li><i class="fa fa-users fa-fw"></i><?= $this->url->link(t('View all groups'), 'group', 'index') ?></li> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('Add group member'), 'group', 'associate', array('group_id' => $group['id'])) ?></li> </ul> - <?php endif ?> </div> <?php if ($paginator->isEmpty()): ?> <p class="alert"><?= t('There is no user in this group.') ?></p> diff --git a/app/Template/layout.php b/app/Template/layout.php index 20582952..0c81aac2 100644 --- a/app/Template/layout.php +++ b/app/Template/layout.php @@ -36,7 +36,7 @@ </head> <body data-status-url="<?= $this->url->href('app', 'status') ?>" data-login-url="<?= $this->url->href('auth', 'login') ?>" - data-markdown-preview-url="<?= $this->url->href('app', 'preview') ?>" + data-markdown-preview-url="<?= $this->url->href('TaskHelper', 'preview') ?>" data-timezone="<?= $this->app->getTimezone() ?>" data-js-lang="<?= $this->app->jsLang() ?>"> diff --git a/app/Template/project/dropdown.php b/app/Template/project/dropdown.php index 1eb87b0e..9ef7cfb4 100644 --- a/app/Template/project/dropdown.php +++ b/app/Template/project/dropdown.php @@ -2,10 +2,13 @@ <i class="fa fa-dashboard fa-fw"></i> <?= $this->url->link(t('Activity'), 'activity', 'project', array('project_id' => $project['id'])) ?> </li> + +<?php if ($this->user->hasProjectAccess('customfilter', 'index', $project['id'])): ?> <li> <i class="fa fa-filter fa-fw"></i> <?= $this->url->link(t('Custom filters'), 'customfilter', 'index', array('project_id' => $project['id'])) ?> </li> +<?php endif ?> <?php if ($project['is_public']): ?> <li> @@ -15,15 +18,21 @@ <?= $this->hook->render('template:project:dropdown', array('project' => $project)) ?> -<?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> +<?php if ($this->user->hasProjectAccess('analytic', 'tasks', $project['id'])): ?> <li> <i class="fa fa-line-chart fa-fw"></i> <?= $this->url->link(t('Analytics'), 'analytic', 'tasks', array('project_id' => $project['id'])) ?> </li> +<?php endif ?> + +<?php if ($this->user->hasProjectAccess('export', 'tasks', $project['id'])): ?> <li> <i class="fa fa-download fa-fw"></i> <?= $this->url->link(t('Exports'), 'export', 'tasks', array('project_id' => $project['id'])) ?> </li> +<?php endif ?> + +<?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <li> <i class="fa fa-cog fa-fw"></i> <?= $this->url->link(t('Settings'), 'project', 'show', array('project_id' => $project['id'])) ?> diff --git a/app/Template/project/edit.php b/app/Template/project/edit.php index 8dcbb88f..188107d1 100644 --- a/app/Template/project/edit.php +++ b/app/Template/project/edit.php @@ -19,7 +19,7 @@ <?= $this->form->label(t('End date'), 'end_date') ?> <?= $this->form->text('end_date', $values, $errors, array('maxlength="10"'), 'form-date') ?> - <?php if ($this->user->isAdmin() || $this->user->isProjectAdministrationAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'create', $project['id'])): ?> <?= $this->form->checkbox('is_private', t('Private project'), 1, $project['is_private'] == 1) ?> <?php endif ?> diff --git a/app/Template/project/filters.php b/app/Template/project/filters.php index 9e126291..0dbb52c9 100644 --- a/app/Template/project/filters.php +++ b/app/Template/project/filters.php @@ -48,7 +48,7 @@ <i class="fa fa-list fa-fw"></i> <?= $this->url->link(t('List'), 'listing', 'show', array('project_id' => $project['id'], 'search' => $filters['search']), false, 'view-listing', t('Keyboard shortcut: "%s"', 'v l')) ?> </li> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('gantt', 'project', $project['id'])): ?> <li <?= $filters['controller'] === 'gantt' ? 'class="active"' : '' ?>> <i class="fa fa-sliders fa-fw"></i> <?= $this->url->link(t('Gantt'), 'gantt', 'project', array('project_id' => $project['id'], 'search' => $filters['search']), false, 'view-gantt', t('Keyboard shortcut: "%s"', 'v g')) ?> diff --git a/app/Template/project/index.php b/app/Template/project/index.php index 4b62a27f..c7d74f8b 100644 --- a/app/Template/project/index.php +++ b/app/Template/project/index.php @@ -1,12 +1,14 @@ <section id="main"> <div class="page-header"> <ul> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('project', 'create')): ?> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New project'), 'project', 'create') ?></li> <?php endif ?> - <li><i class="fa fa-lock fa-fw"></i><?= $this->url->link(t('New private project'), 'project', 'create', array('private' => 1)) ?></li> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <li><i class="fa fa-lock fa-fw"></i><?= $this->url->link(t('New private project'), 'project', 'createPrivate') ?></li> + <?php if ($this->user->hasAccess('projectuser', 'managers')): ?> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('Users overview'), 'projectuser', 'managers') ?></li> + <?php endif ?> + <?php if ($this->user->hasAccess('gantt', 'projects')): ?> <li><i class="fa fa-sliders fa-fw"></i><?= $this->url->link(t('Projects Gantt chart'), 'gantt', 'projects') ?></li> <?php endif ?> </ul> @@ -21,7 +23,7 @@ <th class="column-15"><?= $paginator->order(t('Project'), 'name') ?></th> <th class="column-8"><?= $paginator->order(t('Start date'), 'start_date') ?></th> <th class="column-8"><?= $paginator->order(t('End date'), 'end_date') ?></th> - <?php if ($this->user->isAdmin() || $this->user->isProjectAdmin()): ?> + <?php if ($this->user->hasAccess('projectuser', 'managers')): ?> <th class="column-12"><?= t('Managers') ?></th> <th class="column-12"><?= t('Members') ?></th> <?php endif ?> @@ -64,25 +66,17 @@ <td> <?= $project['end_date'] ?> </td> - <?php if ($this->user->isAdmin() || $this->user->isProjectAdmin()): ?> - <td> - <ul class="no-bullet"> - <?php foreach ($project['managers'] as $user_id => $user_name): ?> - <li><?= $this->url->link($this->e($user_name), 'projectuser', 'opens', array('user_id' => $user_id)) ?></li> - <?php endforeach ?> - </ul> - </td> - <td> - <?php if ($project['is_everybody_allowed'] == 1): ?> - <?= t('Everybody') ?> - <?php else: ?> - <ul class="no-bullet"> - <?php foreach ($project['members'] as $user_id => $user_name): ?> - <li><?= $this->url->link($this->e($user_name), 'projectuser', 'opens', array('user_id' => $user_id)) ?></li> - <?php endforeach ?> - </ul> - <?php endif ?> - </td> + <?php if ($this->user->hasAccess('projectuser', 'managers')): ?> + <td> + <?= $this->render('project/roles', array('roles' => $project, 'role' => \Kanboard\Core\Security\Role::PROJECT_MANAGER)) ?> + </td> + <td> + <?php if ($project['is_everybody_allowed'] == 1): ?> + <?= t('Everybody') ?> + <?php else: ?> + <?= $this->render('project/roles', array('roles' => $project, 'role' => \Kanboard\Core\Security\Role::PROJECT_MEMBER)) ?> + <?php endif ?> + </td> <?php endif ?> <td class="dashboard-project-stats"> <?php foreach ($project['columns'] as $column): ?> diff --git a/app/Template/project/roles.php b/app/Template/project/roles.php new file mode 100644 index 00000000..d4cd43cb --- /dev/null +++ b/app/Template/project/roles.php @@ -0,0 +1,7 @@ +<?php if (! empty($roles[$role])): ?> + <ul class="no-bullet"> + <?php foreach ($roles[$role] as $user_id => $user_name): ?> + <li><?= $this->url->link($this->e($user_name), 'projectuser', 'opens', array('user_id' => $user_id)) ?></li> + <?php endforeach ?> + </ul> +<?php endif ?>
\ No newline at end of file diff --git a/app/Template/project/sidebar.php b/app/Template/project/sidebar.php index fb5dd3bd..b436c9e8 100644 --- a/app/Template/project/sidebar.php +++ b/app/Template/project/sidebar.php @@ -8,7 +8,7 @@ <?= $this->url->link(t('Custom filters'), 'customfilter', 'index', array('project_id' => $project['id'])) ?> </li> - <?php if ($this->user->isProjectManagementAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $project['id'])): ?> <li <?= $this->app->getRouterController() === 'project' && $this->app->getRouterAction() === 'share' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Public access'), 'project', 'share', array('project_id' => $project['id'])) ?> </li> @@ -30,9 +30,9 @@ <li <?= $this->app->getRouterController() === 'category' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Categories'), 'category', 'index', array('project_id' => $project['id'])) ?> </li> - <?php if ($this->user->isAdmin() || $project['is_private'] == 0): ?> - <li <?= $this->app->getRouterController() === 'project' && $this->app->getRouterAction() === 'users' ? 'class="active"' : '' ?>> - <?= $this->url->link(t('Users'), 'project', 'users', array('project_id' => $project['id'])) ?> + <?php if ($project['is_private'] == 0): ?> + <li <?= $this->app->getRouterController() === 'project' && $this->app->getRouterAction() === 'permissions' ? 'class="active"' : '' ?>> + <?= $this->url->link(t('Permissions'), 'ProjectPermission', 'index', array('project_id' => $project['id'])) ?> </li> <?php endif ?> <li <?= $this->app->getRouterController() === 'action' ? 'class="active"' : '' ?>> @@ -51,7 +51,7 @@ <li <?= $this->app->getRouterController() === 'taskImport' && $this->app->getRouterAction() === 'step1' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Import'), 'taskImport', 'step1', array('project_id' => $project['id'])) ?> </li> - <?php if ($this->user->isProjectAdministrationAllowed($project['id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'remove', $project['id'])): ?> <li <?= $this->app->getRouterController() === 'project' && $this->app->getRouterAction() === 'remove' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Remove'), 'project', 'remove', array('project_id' => $project['id'])) ?> </li> diff --git a/app/Template/project/users.php b/app/Template/project/users.php deleted file mode 100644 index 8863a1e4..00000000 --- a/app/Template/project/users.php +++ /dev/null @@ -1,82 +0,0 @@ -<div class="page-header"> - <h2><?= t('List of authorized users') ?></h2> -</div> - -<?php if ($project['is_everybody_allowed']): ?> - <div class="alert"><?= t('Everybody have access to this project.') ?></div> -<?php else: ?> - - <?php if (empty($users['allowed'])): ?> - <div class="alert alert-error"><?= t('Nobody have access to this project.') ?></div> - <?php else: ?> - <table> - <tr> - <th><?= t('User') ?></th> - <th><?= t('Role for this project') ?></th> - <?php if ($project['is_private'] == 0): ?> - <th><?= t('Actions') ?></th> - <?php endif ?> - </tr> - <?php foreach ($users['allowed'] as $user_id => $username): ?> - <tr> - <td><?= $this->e($username) ?></td> - <td><?= isset($users['managers'][$user_id]) ? t('Project manager') : t('Project member') ?></td> - <?php if ($project['is_private'] == 0): ?> - <td> - <ul> - <li><?= $this->url->link(t('Revoke'), 'project', 'revoke', array('project_id' => $project['id'], 'user_id' => $user_id), true) ?></li> - <li> - <?php if (isset($users['managers'][$user_id])): ?> - <?= $this->url->link(t('Set project member'), 'project', 'role', array('project_id' => $project['id'], 'user_id' => $user_id, 'is_owner' => 0), true) ?> - <?php else: ?> - <?= $this->url->link(t('Set project manager'), 'project', 'role', array('project_id' => $project['id'], 'user_id' => $user_id, 'is_owner' => 1), true) ?> - <?php endif ?> - </li> - </ul> - </td> - <?php endif ?> - </tr> - <?php endforeach ?> - </table> - <?php endif ?> - - <?php if ($project['is_private'] == 0 && ! empty($users['not_allowed'])): ?> - <hr/> - <form method="post" action="<?= $this->url->href('project', 'allow', array('project_id' => $project['id'])) ?>" autocomplete="off"> - - <?= $this->form->csrf() ?> - - <?= $this->form->hidden('project_id', array('project_id' => $project['id'])) ?> - - <?= $this->form->label(t('User'), 'user_id') ?> - <?= $this->form->select('user_id', $users['not_allowed'], array(), array(), array('data-notfound="'.t('No results match:').'"'), 'chosen-select') ?><br/> - - <div class="form-actions"> - <input type="submit" value="<?= t('Allow this user') ?>" class="btn btn-blue"/> - </div> - </form> - <?php endif ?> - -<?php endif ?> - -<?php if ($project['is_private'] == 0): ?> -<hr/> -<form method="post" action="<?= $this->url->href('project', 'allowEverybody', array('project_id' => $project['id'])) ?>"> - <?= $this->form->csrf() ?> - - <?= $this->form->hidden('id', array('id' => $project['id'])) ?> - <?= $this->form->checkbox('is_everybody_allowed', t('Allow everybody to access to this project'), 1, $project['is_everybody_allowed']) ?> - - <div class="form-actions"> - <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> - </div> -</form> -<?php endif ?> - -<div class="alert alert-info"> - <ul> - <li><?= t('A project manager can change the settings of the project and have more privileges than a standard user.') ?></li> - <li><?= t('Don\'t forget that administrators have access to everything.') ?></li> - <li><?= $this->url->doc(t('Help with project permissions'), 'project-permissions') ?></li> - </ul> -</div> diff --git a/app/Template/project_permission/index.php b/app/Template/project_permission/index.php new file mode 100644 index 00000000..5f0edc2b --- /dev/null +++ b/app/Template/project_permission/index.php @@ -0,0 +1,141 @@ +<div class="page-header"> + <h2><?= t('Allowed Users') ?></h2> +</div> + +<?php if ($project['is_everybody_allowed']): ?> + <div class="alert"><?= t('Everybody have access to this project.') ?></div> +<?php else: ?> + + <?php if (empty($users)): ?> + <div class="alert"><?= t('No user have been allowed specifically.') ?></div> + <?php else: ?> + <table> + <tr> + <th class="column-50"><?= t('User') ?></th> + <th><?= t('Role') ?></th> + <?php if ($project['is_private'] == 0): ?> + <th class="column-15"><?= t('Actions') ?></th> + <?php endif ?> + </tr> + <?php foreach ($users as $user): ?> + <tr> + <td><?= $this->e($user['name'] ?: $user['username']) ?></td> + <td> + <?= $this->form->select( + 'role-'.$user['id'], + $roles, + array('role-'.$user['id'] => $user['role']), + array(), + array('data-url="'.$this->url->href('ProjectPermission', 'changeUserRole', array('project_id' => $project['id'])).'"', 'data-id="'.$user['id'].'"'), + 'project-change-role' + ) ?> + </td> + <td> + <?= $this->url->link(t('Remove'), 'ProjectPermission', 'removeUser', array('project_id' => $project['id'], 'user_id' => $user['id']), true) ?> + </td> + </tr> + <?php endforeach ?> + </table> + <?php endif ?> + + <?php if ($project['is_private'] == 0): ?> + <div class="listing"> + <form method="post" action="<?= $this->url->href('ProjectPermission', 'addUser', array('project_id' => $project['id'])) ?>" autocomplete="off" class="form-inline"> + <?= $this->form->csrf() ?> + <?= $this->form->hidden('project_id', array('project_id' => $project['id'])) ?> + <?= $this->form->hidden('user_id', $values) ?> + + <?= $this->form->label(t('Name'), 'name') ?> + <?= $this->form->text('name', $values, $errors, array( + 'required', + 'placeholder="'.t('Enter user name...').'"', + 'title="'.t('Enter user name...').'"', + 'data-dst-field="user_id"', + 'data-search-url="'.$this->url->href('UserHelper', 'autocomplete').'"', + ), + 'autocomplete') ?> + + <?= $this->form->select('role', $roles, $values, $errors) ?> + + <input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/> + </form> + </div> + <?php endif ?> + + <div class="page-header"> + <h2><?= t('Allowed Groups') ?></h2> + </div> + + <?php if (empty($groups)): ?> + <div class="alert"><?= t('No group have been allowed specifically.') ?></div> + <?php else: ?> + <table> + <tr> + <th class="column-50"><?= t('Group') ?></th> + <th><?= t('Role') ?></th> + <?php if ($project['is_private'] == 0): ?> + <th class="column-15"><?= t('Actions') ?></th> + <?php endif ?> + </tr> + <?php foreach ($groups as $group): ?> + <tr> + <td><?= $this->e($group['name']) ?></td> + <td> + <?= $this->form->select( + 'role-'.$group['id'], + $roles, + array('role-'.$group['id'] => $group['role']), + array(), + array('data-url="'.$this->url->href('ProjectPermission', 'changeGroupRole', array('project_id' => $project['id'])).'"', 'data-id="'.$group['id'].'"'), + 'project-change-role' + ) ?> + </td> + <td> + <?= $this->url->link(t('Remove'), 'ProjectPermission', 'removeGroup', array('project_id' => $project['id'], 'group_id' => $group['id']), true) ?> + </td> + </tr> + <?php endforeach ?> + </table> + <?php endif ?> + + <?php if ($project['is_private'] == 0): ?> + <div class="listing"> + <form method="post" action="<?= $this->url->href('ProjectPermission', 'addGroup', array('project_id' => $project['id'])) ?>" autocomplete="off" class="form-inline"> + <?= $this->form->csrf() ?> + <?= $this->form->hidden('project_id', array('project_id' => $project['id'])) ?> + <?= $this->form->hidden('group_id', $values) ?> + <?= $this->form->hidden('external_id', $values) ?> + + <?= $this->form->label(t('Group Name'), 'name') ?> + <?= $this->form->text('name', $values, $errors, array( + 'required', + 'placeholder="'.t('Enter group name...').'"', + 'title="'.t('Enter group name...').'"', + 'data-dst-field="group_id"', + 'data-dst-extra-field="external_id"', + 'data-search-url="'.$this->url->href('GroupHelper', 'autocomplete').'"', + ), + 'autocomplete') ?> + + <?= $this->form->select('role', $roles, $values, $errors) ?> + + <input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/> + </form> + </div> + <?php endif ?> + +<?php endif ?> + +<?php if ($project['is_private'] == 0): ?> +<hr/> +<form method="post" action="<?= $this->url->href('ProjectPermission', 'allowEverybody', array('project_id' => $project['id'])) ?>"> + <?= $this->form->csrf() ?> + + <?= $this->form->hidden('id', array('id' => $project['id'])) ?> + <?= $this->form->checkbox('is_everybody_allowed', t('Allow everybody to access to this project'), 1, $project['is_everybody_allowed']) ?> + + <div class="form-actions"> + <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> + </div> +</form> +<?php endif ?> diff --git a/app/Template/project_user/layout.php b/app/Template/project_user/layout.php index 4cf732d6..3a569da4 100644 --- a/app/Template/project_user/layout.php +++ b/app/Template/project_user/layout.php @@ -1,7 +1,7 @@ <section id="main"> <div class="page-header"> <ul> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('project', 'create')): ?> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New project'), 'project', 'create') ?></li> <?php endif ?> <li> @@ -12,7 +12,7 @@ <i class="fa fa-folder fa-fw"></i> <?= $this->url->link(t('Projects list'), 'project', 'index') ?> </li> - <?php if ($this->user->isProjectAdmin() || $this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('gantt', 'projects')): ?> <li> <i class="fa fa-sliders fa-fw"></i> <?= $this->url->link(t('Projects Gantt chart'), 'gantt', 'projects') ?> diff --git a/app/Template/subtask/show.php b/app/Template/subtask/show.php index dc851642..f48484cc 100644 --- a/app/Template/subtask/show.php +++ b/app/Template/subtask/show.php @@ -1,10 +1,11 @@ <div id="subtasks" class="task-show-section"> - <div class="page-header"> - <h2><?= t('Sub-Tasks') ?></h2> - </div> <?php if (! empty($subtasks)): ?> + <div class="page-header"> + <h2><?= t('Sub-Tasks') ?></h2> + </div> + <?php $first_position = $subtasks[0]['position']; ?> <?php $last_position = $subtasks[count($subtasks) - 1]['position']; ?> <table class="subtasks-table"> @@ -86,7 +87,13 @@ </table> <?php endif ?> - <?php if (! isset($not_editable)): ?> + <?php if (! isset($not_editable) && $this->user->hasProjectAccess('subtask', 'save', $task['project_id'])): ?> + + <?php if (empty($subtasks)): ?> + <div class="page-header"> + <h2><?= t('Sub-Tasks') ?></h2> + </div> + <?php endif ?> <form method="post" action="<?= $this->url->href('subtask', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off"> <?= $this->form->csrf() ?> <?= $this->form->hidden('task_id', array('task_id' => $task['id'])) ?> diff --git a/app/Template/task/layout.php b/app/Template/task/layout.php index 6b6e827a..0ceb9706 100644 --- a/app/Template/task/layout.php +++ b/app/Template/task/layout.php @@ -9,7 +9,7 @@ <i class="fa fa-calendar fa-fw"></i> <?= $this->url->link(t('Back to the calendar'), 'calendar', 'show', array('project_id' => $task['project_id'])) ?> </li> - <?php if ($this->user->isProjectManagementAllowed($task['project_id'])): ?> + <?php if ($this->user->hasProjectAccess('project', 'edit', $task['project_id'])): ?> <li> <i class="fa fa-cog fa-fw"></i> <?= $this->url->link(t('Project settings'), 'project', 'show', array('project_id' => $task['project_id'])) ?> diff --git a/app/Template/task/show.php b/app/Template/task/show.php index 68d63c58..713c2b3a 100644 --- a/app/Template/task/show.php +++ b/app/Template/task/show.php @@ -6,7 +6,10 @@ 'recurrence_basedate_list' => $this->task->recurrenceBasedates(), )) ?> -<?= $this->render('task_modification/edit_time', array('task' => $task, 'values' => $values, 'date_format' => $date_format, 'date_formats' => $date_formats)) ?> +<?php if ($this->user->hasProjectAccess('taskmodification', 'edit', $project['id'])): ?> + <?= $this->render('task_modification/edit_time', array('task' => $task, 'values' => $values, 'date_format' => $date_format, 'date_formats' => $date_formats)) ?> +<?php endif ?> + <?= $this->render('task/description', array('task' => $task)) ?> <?= $this->render('tasklink/show', array('task' => $task, 'links' => $links, 'link_label_list' => $link_label_list)) ?> <?= $this->render('subtask/show', array('task' => $task, 'subtasks' => $subtasks, 'project' => $project, 'users_list' => isset($users_list) ? $users_list : array())) ?> diff --git a/app/Template/task/sidebar.php b/app/Template/task/sidebar.php index 9ee1e7df..d994aad3 100644 --- a/app/Template/task/sidebar.php +++ b/app/Template/task/sidebar.php @@ -21,6 +21,7 @@ <?= $this->hook->render('template:task:sidebar:information') ?> </ul> + <?php if ($this->user->hasProjectAccess('taskmodification', 'edit', $task['project_id'])): ?> <h2><?= t('Actions') ?></h2> <ul> <li <?= $this->app->getRouterController() === 'taskmodification' && $this->app->getRouterAction() === 'edit' ? 'class="active"' : '' ?>> @@ -71,6 +72,7 @@ <?= $this->hook->render('template:task:sidebar:actions') ?> </ul> + <?php endif ?> <div class="sidebar-collapse"><a href="#" title="<?= t('Hide sidebar') ?>"><i class="fa fa-chevron-left"></i></a></div> <div class="sidebar-expand" style="display: none"><a href="#" title="<?= t('Expand sidebar') ?>"><i class="fa fa-chevron-right"></i></a></div> </div> diff --git a/app/Template/tasklink/create.php b/app/Template/tasklink/create.php index 749f2968..2832bdc7 100644 --- a/app/Template/tasklink/create.php +++ b/app/Template/tasklink/create.php @@ -21,9 +21,9 @@ 'placeholder="'.t('Start to type task title...').'"', 'title="'.t('Start to type task title...').'"', 'data-dst-field="opposite_task_id"', - 'data-search-url="'.$this->url->href('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"', + 'data-search-url="'.$this->url->href('TaskHelper', 'autocomplete', array('exclude_task_id' => $task['id'])).'"', ), - 'task-autocomplete') ?> + 'autocomplete') ?> <div class="form-actions"> <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> diff --git a/app/Template/tasklink/edit.php b/app/Template/tasklink/edit.php index 73b43277..896f84c0 100644 --- a/app/Template/tasklink/edit.php +++ b/app/Template/tasklink/edit.php @@ -22,9 +22,9 @@ 'placeholder="'.t('Start to type task title...').'"', 'title="'.t('Start to type task title...').'"', 'data-dst-field="opposite_task_id"', - 'data-search-url="'.$this->url->href('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"', + 'data-search-url="'.$this->url->href('TaskHelper', 'autocomplete', array('exclude_task_id' => $task['id'])).'"', ), - 'task-autocomplete') ?> + 'autocomplete') ?> <div class="form-actions"> <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> diff --git a/app/Template/tasklink/show.php b/app/Template/tasklink/show.php index 97a3a767..b66ec087 100644 --- a/app/Template/tasklink/show.php +++ b/app/Template/tasklink/show.php @@ -95,9 +95,9 @@ 'placeholder="'.t('Start to type task title...').'"', 'title="'.t('Start to type task title...').'"', 'data-dst-field="opposite_task_id"', - 'data-search-url="'.$this->url->href('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"', + 'data-search-url="'.$this->url->href('TaskHelper', 'autocomplete', array('exclude_task_id' => $task['id'])).'"', ), - 'task-autocomplete') ?> + 'autocomplete') ?> <input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/> </form> diff --git a/app/Template/twofactor/index.php b/app/Template/twofactor/index.php index 36b92653..4c4ca088 100644 --- a/app/Template/twofactor/index.php +++ b/app/Template/twofactor/index.php @@ -15,10 +15,16 @@ <?php if ($user['twofactor_activated'] == 1): ?> <div class="listing"> <p><?= t('Secret key: ') ?><strong><?= $this->e($user['twofactor_secret']) ?></strong> (base32)</p> - <p><br/><img src="<?= $qrcode_url ?>"/><br/><br/></p> + + <?php if (! empty($qrcode_url)): ?> + <p><br/><img src="<?= $qrcode_url ?>"/><br/><br/></p> + <?php endif ?> + <p> - <?= t('This QR code contains the key URI: ') ?><strong><?= $this->e($key_url) ?></strong> - <br/><br/> + <?php if (! empty($key_url)): ?> + <?= t('This QR code contains the key URI: ') ?><strong><?= $this->e($key_url) ?></strong> + <br/><br/> + <?php endif ?> <?= t('Save the secret key in your TOTP software (by example Google Authenticator or FreeOTP).') ?> </p> </div> diff --git a/app/Template/user/create_local.php b/app/Template/user/create_local.php index 6e6ca6ac..38bd7836 100644 --- a/app/Template/user/create_local.php +++ b/app/Template/user/create_local.php @@ -12,34 +12,35 @@ <div class="form-column"> <?= $this->form->label(t('Username'), 'username') ?> - <?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?><br/> + <?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?> <?= $this->form->label(t('Name'), 'name') ?> - <?= $this->form->text('name', $values, $errors) ?><br/> + <?= $this->form->text('name', $values, $errors) ?> <?= $this->form->label(t('Email'), 'email') ?> - <?= $this->form->email('email', $values, $errors) ?><br/> + <?= $this->form->email('email', $values, $errors) ?> <?= $this->form->label(t('Password'), 'password') ?> - <?= $this->form->password('password', $values, $errors, array('required')) ?><br/> + <?= $this->form->password('password', $values, $errors, array('required')) ?> <?= $this->form->label(t('Confirmation'), 'confirmation') ?> - <?= $this->form->password('confirmation', $values, $errors, array('required')) ?><br/> + <?= $this->form->password('confirmation', $values, $errors, array('required')) ?> </div> <div class="form-column"> <?= $this->form->label(t('Add project member'), 'project_id') ?> - <?= $this->form->select('project_id', $projects, $values, $errors) ?><br/> + <?= $this->form->select('project_id', $projects, $values, $errors) ?> <?= $this->form->label(t('Timezone'), 'timezone') ?> - <?= $this->form->select('timezone', $timezones, $values, $errors) ?><br/> + <?= $this->form->select('timezone', $timezones, $values, $errors) ?> <?= $this->form->label(t('Language'), 'language') ?> - <?= $this->form->select('language', $languages, $values, $errors) ?><br/> + <?= $this->form->select('language', $languages, $values, $errors) ?> + + <?= $this->form->label(t('Role'), 'role') ?> + <?= $this->form->select('role', $roles, $values, $errors) ?> <?= $this->form->checkbox('notifications_enabled', t('Enable email notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> - <?= $this->form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> - <?= $this->form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1 ? true : false) ?> </div> <div class="form-actions"> diff --git a/app/Template/user/create_remote.php b/app/Template/user/create_remote.php index 49d1548c..1cc560cd 100644 --- a/app/Template/user/create_remote.php +++ b/app/Template/user/create_remote.php @@ -12,37 +12,38 @@ <div class="form-column"> <?= $this->form->label(t('Username'), 'username') ?> - <?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?><br/> + <?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?> <?= $this->form->label(t('Name'), 'name') ?> - <?= $this->form->text('name', $values, $errors) ?><br/> + <?= $this->form->text('name', $values, $errors) ?> <?= $this->form->label(t('Email'), 'email') ?> - <?= $this->form->email('email', $values, $errors) ?><br/> + <?= $this->form->email('email', $values, $errors) ?> <?= $this->form->label(t('Google Id'), 'google_id') ?> - <?= $this->form->text('google_id', $values, $errors) ?><br/> + <?= $this->form->text('google_id', $values, $errors) ?> <?= $this->form->label(t('Github Id'), 'github_id') ?> - <?= $this->form->text('github_id', $values, $errors) ?><br/> + <?= $this->form->text('github_id', $values, $errors) ?> <?= $this->form->label(t('Gitlab Id'), 'gitlab_id') ?> - <?= $this->form->text('gitlab_id', $values, $errors) ?><br/> + <?= $this->form->text('gitlab_id', $values, $errors) ?> </div> <div class="form-column"> <?= $this->form->label(t('Add project member'), 'project_id') ?> - <?= $this->form->select('project_id', $projects, $values, $errors) ?><br/> + <?= $this->form->select('project_id', $projects, $values, $errors) ?> <?= $this->form->label(t('Timezone'), 'timezone') ?> - <?= $this->form->select('timezone', $timezones, $values, $errors) ?><br/> + <?= $this->form->select('timezone', $timezones, $values, $errors) ?> <?= $this->form->label(t('Language'), 'language') ?> - <?= $this->form->select('language', $languages, $values, $errors) ?><br/> + <?= $this->form->select('language', $languages, $values, $errors) ?> + + <?= $this->form->label(t('Role'), 'role') ?> + <?= $this->form->select('role', $roles, $values, $errors) ?> <?= $this->form->checkbox('notifications_enabled', t('Enable email notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> - <?= $this->form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> - <?= $this->form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1 ? true : false) ?> <?= $this->form->checkbox('disable_login_form', t('Disallow login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?> </div> diff --git a/app/Template/user/edit.php b/app/Template/user/edit.php index cd10b2ab..1a7fb430 100644 --- a/app/Template/user/edit.php +++ b/app/Template/user/edit.php @@ -8,23 +8,23 @@ <?= $this->form->hidden('id', $values) ?> <?= $this->form->label(t('Username'), 'username') ?> - <?= $this->form->text('username', $values, $errors, array('required', $values['is_ldap_user'] == 1 ? 'readonly' : '', 'maxlength="50"')) ?><br/> + <?= $this->form->text('username', $values, $errors, array('required', $values['is_ldap_user'] == 1 ? 'readonly' : '', 'maxlength="50"')) ?> <?= $this->form->label(t('Name'), 'name') ?> - <?= $this->form->text('name', $values, $errors) ?><br/> + <?= $this->form->text('name', $values, $errors) ?> <?= $this->form->label(t('Email'), 'email') ?> - <?= $this->form->email('email', $values, $errors) ?><br/> + <?= $this->form->email('email', $values, $errors) ?> <?= $this->form->label(t('Timezone'), 'timezone') ?> - <?= $this->form->select('timezone', $timezones, $values, $errors) ?><br/> + <?= $this->form->select('timezone', $timezones, $values, $errors) ?> <?= $this->form->label(t('Language'), 'language') ?> - <?= $this->form->select('language', $languages, $values, $errors) ?><br/> + <?= $this->form->select('language', $languages, $values, $errors) ?> <?php if ($this->user->isAdmin()): ?> - <?= $this->form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1) ?> - <?= $this->form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1) ?> + <?= $this->form->label(t('Role'), 'role') ?> + <?= $this->form->select('role', $roles, $values, $errors) ?> <?php endif ?> <div class="form-actions"> diff --git a/app/Template/user/external.php b/app/Template/user/external.php index 7a42f38e..8b1d3c46 100644 --- a/app/Template/user/external.php +++ b/app/Template/user/external.php @@ -10,7 +10,7 @@ <?php if (empty($user['google_id'])): ?> <?= $this->url->link(t('Link my Google Account'), 'oauth', 'google', array(), true) ?> <?php else: ?> - <?= $this->url->link(t('Unlink my Google Account'), 'oauth', 'unlink', array('backend' => 'google'), true) ?> + <?= $this->url->link(t('Unlink my Google Account'), 'oauth', 'unlink', array('backend' => 'Google'), true) ?> <?php endif ?> <?php else: ?> <?= empty($user['google_id']) ? t('No account linked.') : t('Account linked.') ?> @@ -26,7 +26,7 @@ <?php if (empty($user['github_id'])): ?> <?= $this->url->link(t('Link my Github Account'), 'oauth', 'github', array(), true) ?> <?php else: ?> - <?= $this->url->link(t('Unlink my Github Account'), 'oauth', 'unlink', array('backend' => 'github'), true) ?> + <?= $this->url->link(t('Unlink my Github Account'), 'oauth', 'unlink', array('backend' => 'Github'), true) ?> <?php endif ?> <?php else: ?> <?= empty($user['github_id']) ? t('No account linked.') : t('Account linked.') ?> @@ -42,7 +42,7 @@ <?php if (empty($user['gitlab_id'])): ?> <?= $this->url->link(t('Link my Gitlab Account'), 'oauth', 'gitlab', array(), true) ?> <?php else: ?> - <?= $this->url->link(t('Unlink my Gitlab Account'), 'oauth', 'unlink', array('backend' => 'gitlab'), true) ?> + <?= $this->url->link(t('Unlink my Gitlab Account'), 'oauth', 'unlink', array('backend' => 'Gitlab'), true) ?> <?php endif ?> <?php else: ?> <?= empty($user['gitlab_id']) ? t('No account linked.') : t('Account linked.') ?> diff --git a/app/Template/user/index.php b/app/Template/user/index.php index 7c6ecc1e..cb7416d6 100644 --- a/app/Template/user/index.php +++ b/app/Template/user/index.php @@ -1,6 +1,6 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('user', 'create')): ?> <ul> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New local user'), 'user', 'create') ?></li> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New remote user'), 'user', 'create', array('remote' => 1)) ?></li> @@ -18,8 +18,7 @@ <th><?= $paginator->order(t('Username'), 'username') ?></th> <th><?= $paginator->order(t('Name'), 'name') ?></th> <th><?= $paginator->order(t('Email'), 'email') ?></th> - <th><?= $paginator->order(t('Administrator'), 'is_admin') ?></th> - <th><?= $paginator->order(t('Project Administrator'), 'is_project_admin') ?></th> + <th><?= $paginator->order(t('Role'), 'role') ?></th> <th><?= $paginator->order(t('Two factor authentication'), 'twofactor_activated') ?></th> <th><?= $paginator->order(t('Notifications'), 'notifications_enabled') ?></th> <th><?= $paginator->order(t('Account type'), 'is_ldap_user') ?></th> @@ -39,10 +38,7 @@ <a href="mailto:<?= $this->e($user['email']) ?>"><?= $this->e($user['email']) ?></a> </td> <td> - <?= $user['is_admin'] ? t('Yes') : t('No') ?> - </td> - <td> - <?= $user['is_project_admin'] ? t('Yes') : t('No') ?> + <?= $this->user->getRoleName($user['role']) ?> </td> <td> <?= $user['twofactor_activated'] ? t('Yes') : t('No') ?> diff --git a/app/Template/user/layout.php b/app/Template/user/layout.php index a27f359b..1e456348 100644 --- a/app/Template/user/layout.php +++ b/app/Template/user/layout.php @@ -1,6 +1,6 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('user', 'create')): ?> <ul> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('All users'), 'user', 'index') ?></li> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New local user'), 'user', 'create') ?></li> diff --git a/app/Template/user/sessions.php b/app/Template/user/sessions.php index eabf3672..7a66c5ad 100644 --- a/app/Template/user/sessions.php +++ b/app/Template/user/sessions.php @@ -19,7 +19,7 @@ <td><?= dt('%B %e, %Y at %k:%M %p', $session['expiration']) ?></td> <td><?= $this->e($session['ip']) ?></td> <td><?= $this->e($session['user_agent']) ?></td> - <td><?= $this->url->link(t('Remove'), 'user', 'removeSession', array('user_id' => $user['id'], 'id' => $session['id']), true) ?></td> + <td><?= $this->url->link(t('Remove'), 'User', 'removeSession', array('user_id' => $user['id'], 'id' => $session['id']), true) ?></td> </tr> <?php endforeach ?> </table> diff --git a/app/Template/user/show.php b/app/Template/user/show.php index 220ad87e..89c6b36b 100644 --- a/app/Template/user/show.php +++ b/app/Template/user/show.php @@ -11,7 +11,7 @@ <h2><?= t('Security') ?></h2> </div> <ul class="listing"> - <li><?= t('Group:') ?> <strong><?= $user['is_admin'] ? t('Administrator') : ($user['is_project_admin'] ? t('Project Administrator') : t('Regular user')) ?></strong></li> + <li><?= t('Role:') ?> <strong><?= $this->user->getRoleName($user['role']) ?></strong></li> <li><?= t('Account type:') ?> <strong><?= $user['is_ldap_user'] ? t('Remote') : t('Local') ?></strong></li> <li><?= $user['twofactor_activated'] == 1 ? t('Two factor authentication enabled') : t('Two factor authentication disabled') ?></li> </ul> diff --git a/app/Template/user/sidebar.php b/app/Template/user/sidebar.php index 167c8054..011994b9 100644 --- a/app/Template/user/sidebar.php +++ b/app/Template/user/sidebar.php @@ -41,7 +41,7 @@ <li <?= $this->app->getRouterController() === 'twofactor' && $this->app->getRouterAction() === 'index' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Two factor authentication'), 'twofactor', 'index', array('user_id' => $user['id'])) ?> </li> - <?php elseif ($this->user->isAdmin() && $user['twofactor_activated'] == 1): ?> + <?php elseif ($this->user->hasAccess('twofactor', 'disable') && $user['twofactor_activated'] == 1): ?> <li <?= $this->app->getRouterController() === 'twofactor' && $this->app->getRouterAction() === 'disable' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Two factor authentication'), 'twofactor', 'disable', array('user_id' => $user['id'])) ?> </li> @@ -61,7 +61,7 @@ </li> <?php endif ?> - <?php if ($this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('user', 'authentication')): ?> <li <?= $this->app->getRouterController() === 'user' && $this->app->getRouterAction() === 'authentication' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Edit Authentication'), 'user', 'authentication', array('user_id' => $user['id'])) ?> </li> @@ -69,7 +69,7 @@ <?= $this->hook->render('template:user:sidebar:actions', array('user' => $user)) ?> - <?php if ($this->user->isAdmin() && ! $this->user->isCurrentUser($user['id'])): ?> + <?php if ($this->user->hasAccess('user', 'remove') && ! $this->user->isCurrentUser($user['id'])): ?> <li <?= $this->app->getRouterController() === 'user' && $this->app->getRouterAction() === 'remove' ? 'class="active"' : '' ?>> <?= $this->url->link(t('Remove'), 'user', 'remove', array('user_id' => $user['id'])) ?> </li> diff --git a/app/Template/user_import/step1.php b/app/Template/user_import/step1.php index 7256bfa6..69643d6d 100644 --- a/app/Template/user_import/step1.php +++ b/app/Template/user_import/step1.php @@ -1,6 +1,6 @@ <section id="main"> <div class="page-header"> - <?php if ($this->user->isAdmin()): ?> + <?php if ($this->user->hasAccess('user', 'create')): ?> <ul> <li><i class="fa fa-user fa-fw"></i><?= $this->url->link(t('All users'), 'user', 'index') ?></li> <li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New local user'), 'user', 'create') ?></li> |