From 4514bc1d4b4abff23902e46da76e70f13a3647eb Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 16 May 2016 20:55:21 -0400 Subject: Improve user controllers and views --- app/Controller/Oauth.php | 6 +- app/Controller/Twofactor.php | 4 +- app/Controller/User.php | 350 --------------------- app/Controller/UserAjaxController.php | 52 +++ app/Controller/UserCreationController.php | 4 +- app/Controller/UserHelper.php | 52 --- app/Controller/UserImportController.php | 2 +- app/Controller/UserListController.php | 32 ++ app/Controller/UserStatusController.php | 6 +- app/Controller/UserViewController.php | 330 +++++++++++++++++++ app/Core/Markdown.php | 2 +- app/Helper/LayoutHelper.php | 2 +- app/ServiceProvider/AuthenticationProvider.php | 5 +- app/ServiceProvider/RouteProvider.php | 26 +- app/Template/comment/create.php | 2 +- app/Template/comments/create.php | 2 +- app/Template/group/index.php | 2 +- app/Template/group/users.php | 4 +- app/Template/header.php | 6 +- app/Template/layout.php | 2 +- app/Template/project_permission/index.php | 2 +- app/Template/task/time_tracking_details.php | 4 +- app/Template/task/transitions.php | 4 +- app/Template/task_creation/show.php | 2 +- app/Template/task_internal_link/table.php | 4 +- .../task_modification/edit_description.php | 2 +- app/Template/twofactor/disable.php | 4 +- app/Template/user/authentication.php | 28 -- app/Template/user/dropdown.php | 27 -- app/Template/user/edit.php | 35 --- app/Template/user/external.php | 11 - app/Template/user/index.php | 66 ---- app/Template/user/integrations.php | 13 - app/Template/user/last.php | 24 -- app/Template/user/layout.php | 19 -- app/Template/user/notifications.php | 26 -- app/Template/user/password.php | 26 -- app/Template/user/password_reset.php | 26 -- app/Template/user/profile.php | 9 - app/Template/user/sessions.php | 26 -- app/Template/user/share.php | 18 -- app/Template/user/show.php | 40 --- app/Template/user/sidebar.php | 83 ----- app/Template/user/timesheet.php | 29 -- app/Template/user_creation/local.php | 2 +- app/Template/user_creation/remote.php | 2 +- app/Template/user_import/show.php | 2 +- app/Template/user_list/dropdown.php | 27 ++ app/Template/user_list/show.php | 66 ++++ app/Template/user_status/disable.php | 2 +- app/Template/user_status/enable.php | 2 +- app/Template/user_status/remove.php | 2 +- app/Template/user_view/authentication.php | 27 ++ app/Template/user_view/edit.php | 35 +++ app/Template/user_view/external.php | 11 + app/Template/user_view/integrations.php | 13 + app/Template/user_view/last.php | 24 ++ app/Template/user_view/layout.php | 19 ++ app/Template/user_view/notifications.php | 26 ++ app/Template/user_view/password.php | 26 ++ app/Template/user_view/password_reset.php | 26 ++ app/Template/user_view/profile.php | 9 + app/Template/user_view/sessions.php | 26 ++ app/Template/user_view/share.php | 15 + app/Template/user_view/show.php | 40 +++ app/Template/user_view/sidebar.php | 83 +++++ app/Template/user_view/timesheet.php | 29 ++ 67 files changed, 971 insertions(+), 962 deletions(-) delete mode 100644 app/Controller/User.php create mode 100644 app/Controller/UserAjaxController.php delete mode 100644 app/Controller/UserHelper.php create mode 100644 app/Controller/UserListController.php create mode 100644 app/Controller/UserViewController.php delete mode 100644 app/Template/user/authentication.php delete mode 100644 app/Template/user/dropdown.php delete mode 100644 app/Template/user/edit.php delete mode 100644 app/Template/user/external.php delete mode 100644 app/Template/user/index.php delete mode 100644 app/Template/user/integrations.php delete mode 100644 app/Template/user/last.php delete mode 100644 app/Template/user/layout.php delete mode 100644 app/Template/user/notifications.php delete mode 100644 app/Template/user/password.php delete mode 100644 app/Template/user/password_reset.php delete mode 100644 app/Template/user/profile.php delete mode 100644 app/Template/user/sessions.php delete mode 100644 app/Template/user/share.php delete mode 100644 app/Template/user/show.php delete mode 100644 app/Template/user/sidebar.php delete mode 100644 app/Template/user/timesheet.php create mode 100644 app/Template/user_list/dropdown.php create mode 100644 app/Template/user_list/show.php create mode 100644 app/Template/user_view/authentication.php create mode 100644 app/Template/user_view/edit.php create mode 100644 app/Template/user_view/external.php create mode 100644 app/Template/user_view/integrations.php create mode 100644 app/Template/user_view/last.php create mode 100644 app/Template/user_view/layout.php create mode 100644 app/Template/user_view/notifications.php create mode 100644 app/Template/user_view/password.php create mode 100644 app/Template/user_view/password_reset.php create mode 100644 app/Template/user_view/profile.php create mode 100644 app/Template/user_view/sessions.php create mode 100644 app/Template/user_view/share.php create mode 100644 app/Template/user_view/show.php create mode 100644 app/Template/user_view/sidebar.php create mode 100644 app/Template/user_view/timesheet.php diff --git a/app/Controller/Oauth.php b/app/Controller/Oauth.php index c38654be..04adf154 100644 --- a/app/Controller/Oauth.php +++ b/app/Controller/Oauth.php @@ -49,7 +49,7 @@ class Oauth extends BaseController $this->link($provider); } else { $this->flash->failure(t('The OAuth2 state parameter is invalid')); - $this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId()))); + $this->response->redirect($this->helper->url->to('UserViewController', 'external', array('user_id' => $this->userSession->getId()))); } } else { if ($hasValidState) { @@ -75,7 +75,7 @@ class Oauth extends BaseController $this->flash->success(t('Your external account is linked to your profile successfully.')); } - $this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId()))); + $this->response->redirect($this->helper->url->to('UserViewController', 'external', array('user_id' => $this->userSession->getId()))); } /** @@ -94,7 +94,7 @@ class Oauth extends BaseController $this->flash->failure(t('Unable to unlink your external account.')); } - $this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId()))); + $this->response->redirect($this->helper->url->to('UserViewController', 'external', array('user_id' => $this->userSession->getId()))); } /** diff --git a/app/Controller/Twofactor.php b/app/Controller/Twofactor.php index 2eb61594..118613b2 100644 --- a/app/Controller/Twofactor.php +++ b/app/Controller/Twofactor.php @@ -10,7 +10,7 @@ use Kanboard\Core\Controller\AccessForbiddenException; * @package controller * @author Frederic Guillot */ -class Twofactor extends User +class Twofactor extends UserViewController { /** * Only the current user can access to 2FA settings @@ -192,7 +192,7 @@ class Twofactor extends User 'twofactor_secret' => '', )); - return $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id']))); + return $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); } return $this->response->html($this->helper->layout->user('twofactor/disable', array( diff --git a/app/Controller/User.php b/app/Controller/User.php deleted file mode 100644 index 190acb61..00000000 --- a/app/Controller/User.php +++ /dev/null @@ -1,350 +0,0 @@ -paginator - ->setUrl('user', 'index') - ->setMax(30) - ->setOrder('username') - ->setQuery($this->user->getQuery()) - ->calculate(); - - $this->response->html($this->helper->layout->app('user/index', array( - 'title' => t('Users').' ('.$paginator->getTotal().')', - 'paginator' => $paginator, - ))); - } - - /** - * Public user profile - * - * @access public - * @throws PageNotFoundException - */ - public function profile() - { - $user = $this->user->getById($this->request->getIntegerParam('user_id')); - - if (empty($user)) { - throw new PageNotFoundException(); - } - - $this->response->html($this->helper->layout->app('user/profile', array( - 'title' => $user['name'] ?: $user['username'], - 'user' => $user, - ))); - } - - /** - * Display user information - * - * @access public - */ - public function show() - { - $user = $this->getUser(); - $this->response->html($this->helper->layout->user('user/show', array( - 'user' => $user, - 'timezones' => $this->timezone->getTimezones(true), - 'languages' => $this->language->getLanguages(true), - ))); - } - - /** - * Display timesheet - * - * @access public - */ - public function timesheet() - { - $user = $this->getUser(); - - $subtask_paginator = $this->paginator - ->setUrl('user', 'timesheet', array('user_id' => $user['id'], 'pagination' => 'subtasks')) - ->setMax(20) - ->setOrder('start') - ->setDirection('DESC') - ->setQuery($this->subtaskTimeTracking->getUserQuery($user['id'])) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); - - $this->response->html($this->helper->layout->user('user/timesheet', array( - 'subtask_paginator' => $subtask_paginator, - 'user' => $user, - ))); - } - - /** - * Display last password reset - * - * @access public - */ - public function passwordReset() - { - $user = $this->getUser(); - $this->response->html($this->helper->layout->user('user/password_reset', array( - 'tokens' => $this->passwordReset->getAll($user['id']), - 'user' => $user, - ))); - } - - /** - * Display last connections - * - * @access public - */ - public function last() - { - $user = $this->getUser(); - $this->response->html($this->helper->layout->user('user/last', array( - 'last_logins' => $this->lastLogin->getAll($user['id']), - 'user' => $user, - ))); - } - - /** - * Display user sessions - * - * @access public - */ - public function sessions() - { - $user = $this->getUser(); - $this->response->html($this->helper->layout->user('user/sessions', array( - 'sessions' => $this->rememberMeSession->getAll($user['id']), - 'user' => $user, - ))); - } - - /** - * Remove a "RememberMe" token - * - * @access public - */ - public function removeSession() - { - $this->checkCSRFParam(); - $user = $this->getUser(); - $this->rememberMeSession->remove($this->request->getIntegerParam('id')); - $this->response->redirect($this->helper->url->to('user', 'sessions', array('user_id' => $user['id']))); - } - - /** - * Display user notifications - * - * @access public - */ - public function notifications() - { - $user = $this->getUser(); - - if ($this->request->isPost()) { - $values = $this->request->getValues(); - $this->userNotification->saveSettings($user['id'], $values); - $this->flash->success(t('User updated successfully.')); - return $this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id']))); - } - - return $this->response->html($this->helper->layout->user('user/notifications', array( - 'projects' => $this->projectUserRole->getProjectsByUser($user['id'], array(ProjectModel::ACTIVE)), - 'notifications' => $this->userNotification->readSettings($user['id']), - 'types' => $this->userNotificationType->getTypes(), - 'filters' => $this->userNotificationFilter->getFilters(), - 'user' => $user, - ))); - } - - /** - * Display user integrations - * - * @access public - */ - public function integrations() - { - $user = $this->getUser(); - - if ($this->request->isPost()) { - $values = $this->request->getValues(); - $this->userMetadata->save($user['id'], $values); - $this->flash->success(t('User updated successfully.')); - $this->response->redirect($this->helper->url->to('user', 'integrations', array('user_id' => $user['id']))); - } - - $this->response->html($this->helper->layout->user('user/integrations', array( - 'user' => $user, - 'values' => $this->userMetadata->getAll($user['id']), - ))); - } - - /** - * Display external accounts - * - * @access public - */ - public function external() - { - $user = $this->getUser(); - $this->response->html($this->helper->layout->user('user/external', array( - 'last_logins' => $this->lastLogin->getAll($user['id']), - 'user' => $user, - ))); - } - - /** - * Public access management - * - * @access public - */ - public function share() - { - $user = $this->getUser(); - $switch = $this->request->getStringParam('switch'); - - if ($switch === 'enable' || $switch === 'disable') { - $this->checkCSRFParam(); - - if ($this->user->{$switch.'PublicAccess'}($user['id'])) { - $this->flash->success(t('User updated successfully.')); - } else { - $this->flash->failure(t('Unable to update this user.')); - } - - return $this->response->redirect($this->helper->url->to('user', 'share', array('user_id' => $user['id']))); - } - - return $this->response->html($this->helper->layout->user('user/share', array( - 'user' => $user, - 'title' => t('Public access'), - ))); - } - - /** - * Password modification - * - * @access public - */ - public function password() - { - $user = $this->getUser(); - $values = array('id' => $user['id']); - $errors = array(); - - if ($this->request->isPost()) { - $values = $this->request->getValues(); - list($valid, $errors) = $this->userValidator->validatePasswordModification($values); - - if ($valid) { - if ($this->user->update($values)) { - $this->flash->success(t('Password modified successfully.')); - } else { - $this->flash->failure(t('Unable to change the password.')); - } - - return $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id']))); - } - } - - return $this->response->html($this->helper->layout->user('user/password', array( - 'values' => $values, - 'errors' => $errors, - 'user' => $user, - ))); - } - - /** - * Display a form to edit a user - * - * @access public - */ - public function edit() - { - $user = $this->getUser(); - $values = $user; - $errors = array(); - - unset($values['password']); - - if ($this->request->isPost()) { - $values = $this->request->getValues(); - - if (! $this->userSession->isAdmin()) { - if (isset($values['role'])) { - unset($values['role']); - } - } - - list($valid, $errors) = $this->userValidator->validateModification($values); - - if ($valid) { - if ($this->user->update($values)) { - $this->flash->success(t('User updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your user.')); - } - - return $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id']))); - } - } - - return $this->response->html($this->helper->layout->user('user/edit', array( - 'values' => $values, - 'errors' => $errors, - 'user' => $user, - 'timezones' => $this->timezone->getTimezones(true), - 'languages' => $this->language->getLanguages(true), - 'roles' => $this->role->getApplicationRoles(), - ))); - } - - /** - * Display a form to edit authentication - * - * @access public - */ - public function authentication() - { - $user = $this->getUser(); - $values = $user; - $errors = array(); - - unset($values['password']); - - if ($this->request->isPost()) { - $values = $this->request->getValues() + array('disable_login_form' => 0, 'is_ldap_user' => 0); - list($valid, $errors) = $this->userValidator->validateModification($values); - - if ($valid) { - if ($this->user->update($values)) { - $this->flash->success(t('User updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your user.')); - } - - return $this->response->redirect($this->helper->url->to('user', 'authentication', array('user_id' => $user['id']))); - } - } - - return $this->response->html($this->helper->layout->user('user/authentication', array( - 'values' => $values, - 'errors' => $errors, - 'user' => $user, - ))); - } -} diff --git a/app/Controller/UserAjaxController.php b/app/Controller/UserAjaxController.php new file mode 100644 index 00000000..7b365667 --- /dev/null +++ b/app/Controller/UserAjaxController.php @@ -0,0 +1,52 @@ +request->getStringParam('term'); + $filter = $this->userQuery->withFilter(new UserNameFilter($search)); + $filter->getQuery()->asc(UserModel::TABLE.'.name')->asc(UserModel::TABLE.'.username'); + $this->response->json($filter->format(new UserAutoCompleteFormatter($this->container))); + } + + /** + * User mention auto-completion (Ajax) + * + * @access public + */ + public function mention() + { + $project_id = $this->request->getStringParam('project_id'); + $query = $this->request->getStringParam('q'); + $users = $this->projectPermission->findUsernames($project_id, $query); + $this->response->json($users); + } + + /** + * Check if the user is connected + * + * @access public + */ + public function status() + { + $this->response->text('OK'); + } +} diff --git a/app/Controller/UserCreationController.php b/app/Controller/UserCreationController.php index d1c554ae..49f9db54 100644 --- a/app/Controller/UserCreationController.php +++ b/app/Controller/UserCreationController.php @@ -74,10 +74,10 @@ class UserCreationController extends BaseController } $this->flash->success(t('User created successfully.')); - $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user_id))); + $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user_id))); } else { $this->flash->failure(t('Unable to create your user.')); - $this->response->redirect($this->helper->url->to('user', 'index')); + $this->response->redirect($this->helper->url->to('UserListController', 'show')); } } } diff --git a/app/Controller/UserHelper.php b/app/Controller/UserHelper.php deleted file mode 100644 index d5e0920d..00000000 --- a/app/Controller/UserHelper.php +++ /dev/null @@ -1,52 +0,0 @@ -request->getStringParam('term'); - $filter = $this->userQuery->withFilter(new UserNameFilter($search)); - $filter->getQuery()->asc(UserModel::TABLE.'.name')->asc(UserModel::TABLE.'.username'); - $this->response->json($filter->format(new UserAutoCompleteFormatter($this->container))); - } - - /** - * User mention auto-completion (Ajax) - * - * @access public - */ - public function mention() - { - $project_id = $this->request->getStringParam('project_id'); - $query = $this->request->getStringParam('q'); - $users = $this->projectPermission->findUsernames($project_id, $query); - $this->response->json($users); - } - - /** - * Check if the user is connected - * - * @access public - */ - public function status() - { - $this->response->text('OK'); - } -} diff --git a/app/Controller/UserImportController.php b/app/Controller/UserImportController.php index b3cb52d1..fec9a31d 100644 --- a/app/Controller/UserImportController.php +++ b/app/Controller/UserImportController.php @@ -43,7 +43,7 @@ class UserImportController extends BaseController $this->importFile($values, $filename); } - $this->response->redirect($this->helper->url->to('user', 'index')); + $this->response->redirect($this->helper->url->to('UserListController', 'show')); } /** diff --git a/app/Controller/UserListController.php b/app/Controller/UserListController.php new file mode 100644 index 00000000..685746fb --- /dev/null +++ b/app/Controller/UserListController.php @@ -0,0 +1,32 @@ +paginator + ->setUrl('UserListController', 'show') + ->setMax(30) + ->setOrder('username') + ->setQuery($this->user->getQuery()) + ->calculate(); + + $this->response->html($this->helper->layout->app('user_list/show', array( + 'title' => t('Users').' ('.$paginator->getTotal().')', + 'paginator' => $paginator, + ))); + } +} diff --git a/app/Controller/UserStatusController.php b/app/Controller/UserStatusController.php index 2b23505c..bc40a7dd 100644 --- a/app/Controller/UserStatusController.php +++ b/app/Controller/UserStatusController.php @@ -40,7 +40,7 @@ class UserStatusController extends BaseController $this->flash->failure(t('Unable to remove this user.')); } - $this->response->redirect($this->helper->url->to('user', 'index')); + $this->response->redirect($this->helper->url->to('UserListController', 'show')); } /** @@ -73,7 +73,7 @@ class UserStatusController extends BaseController $this->flash->failure(t('Unable to enable this user.')); } - $this->response->redirect($this->helper->url->to('user', 'index')); + $this->response->redirect($this->helper->url->to('UserListController', 'show')); } /** @@ -106,6 +106,6 @@ class UserStatusController extends BaseController $this->flash->failure(t('Unable to disable this user.')); } - $this->response->redirect($this->helper->url->to('user', 'index')); + $this->response->redirect($this->helper->url->to('UserListController', 'show')); } } diff --git a/app/Controller/UserViewController.php b/app/Controller/UserViewController.php new file mode 100644 index 00000000..dc03f419 --- /dev/null +++ b/app/Controller/UserViewController.php @@ -0,0 +1,330 @@ +user->getById($this->request->getIntegerParam('user_id')); + + if (empty($user)) { + throw new PageNotFoundException(); + } + + $this->response->html($this->helper->layout->app('user_view/profile', array( + 'title' => $user['name'] ?: $user['username'], + 'user' => $user, + ))); + } + + /** + * Display user information + * + * @access public + */ + public function show() + { + $user = $this->getUser(); + $this->response->html($this->helper->layout->user('user_view/show', array( + 'user' => $user, + 'timezones' => $this->timezone->getTimezones(true), + 'languages' => $this->language->getLanguages(true), + ))); + } + + /** + * Display timesheet + * + * @access public + */ + public function timesheet() + { + $user = $this->getUser(); + + $subtask_paginator = $this->paginator + ->setUrl('UserViewController', 'timesheet', array('user_id' => $user['id'], 'pagination' => 'subtasks')) + ->setMax(20) + ->setOrder('start') + ->setDirection('DESC') + ->setQuery($this->subtaskTimeTracking->getUserQuery($user['id'])) + ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); + + $this->response->html($this->helper->layout->user('user_view/timesheet', array( + 'subtask_paginator' => $subtask_paginator, + 'user' => $user, + ))); + } + + /** + * Display last password reset + * + * @access public + */ + public function passwordReset() + { + $user = $this->getUser(); + $this->response->html($this->helper->layout->user('user_view/password_reset', array( + 'tokens' => $this->passwordReset->getAll($user['id']), + 'user' => $user, + ))); + } + + /** + * Display last connections + * + * @access public + */ + public function lastLogin() + { + $user = $this->getUser(); + $this->response->html($this->helper->layout->user('user_view/last', array( + 'last_logins' => $this->lastLogin->getAll($user['id']), + 'user' => $user, + ))); + } + + /** + * Display user sessions + * + * @access public + */ + public function sessions() + { + $user = $this->getUser(); + $this->response->html($this->helper->layout->user('user_view/sessions', array( + 'sessions' => $this->rememberMeSession->getAll($user['id']), + 'user' => $user, + ))); + } + + /** + * Remove a "RememberMe" token + * + * @access public + */ + public function removeSession() + { + $this->checkCSRFParam(); + $user = $this->getUser(); + $this->rememberMeSession->remove($this->request->getIntegerParam('id')); + $this->response->redirect($this->helper->url->to('UserViewController', 'sessions', array('user_id' => $user['id']))); + } + + /** + * Display user notifications + * + * @access public + */ + public function notifications() + { + $user = $this->getUser(); + + if ($this->request->isPost()) { + $values = $this->request->getValues(); + $this->userNotification->saveSettings($user['id'], $values); + $this->flash->success(t('User updated successfully.')); + return $this->response->redirect($this->helper->url->to('UserViewController', 'notifications', array('user_id' => $user['id']))); + } + + return $this->response->html($this->helper->layout->user('user_view/notifications', array( + 'projects' => $this->projectUserRole->getProjectsByUser($user['id'], array(ProjectModel::ACTIVE)), + 'notifications' => $this->userNotification->readSettings($user['id']), + 'types' => $this->userNotificationType->getTypes(), + 'filters' => $this->userNotificationFilter->getFilters(), + 'user' => $user, + ))); + } + + /** + * Display user integrations + * + * @access public + */ + public function integrations() + { + $user = $this->getUser(); + + if ($this->request->isPost()) { + $values = $this->request->getValues(); + $this->userMetadata->save($user['id'], $values); + $this->flash->success(t('User updated successfully.')); + $this->response->redirect($this->helper->url->to('UserViewController', 'integrations', array('user_id' => $user['id']))); + } + + $this->response->html($this->helper->layout->user('user_view/integrations', array( + 'user' => $user, + 'values' => $this->userMetadata->getAll($user['id']), + ))); + } + + /** + * Display external accounts + * + * @access public + */ + public function external() + { + $user = $this->getUser(); + $this->response->html($this->helper->layout->user('user_view/external', array( + 'last_logins' => $this->lastLogin->getAll($user['id']), + 'user' => $user, + ))); + } + + /** + * Public access management + * + * @access public + */ + public function share() + { + $user = $this->getUser(); + $switch = $this->request->getStringParam('switch'); + + if ($switch === 'enable' || $switch === 'disable') { + $this->checkCSRFParam(); + + if ($this->user->{$switch.'PublicAccess'}($user['id'])) { + $this->flash->success(t('User updated successfully.')); + } else { + $this->flash->failure(t('Unable to update this user.')); + } + + return $this->response->redirect($this->helper->url->to('UserViewController', 'share', array('user_id' => $user['id']))); + } + + return $this->response->html($this->helper->layout->user('user_view/share', array( + 'user' => $user, + 'title' => t('Public access'), + ))); + } + + /** + * Password modification + * + * @access public + */ + public function password() + { + $user = $this->getUser(); + $values = array('id' => $user['id']); + $errors = array(); + + if ($this->request->isPost()) { + $values = $this->request->getValues(); + list($valid, $errors) = $this->userValidator->validatePasswordModification($values); + + if ($valid) { + if ($this->user->update($values)) { + $this->flash->success(t('Password modified successfully.')); + } else { + $this->flash->failure(t('Unable to change the password.')); + } + + return $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); + } + } + + return $this->response->html($this->helper->layout->user('user_view/password', array( + 'values' => $values, + 'errors' => $errors, + 'user' => $user, + ))); + } + + /** + * Display a form to edit a user + * + * @access public + */ + public function edit() + { + $user = $this->getUser(); + $values = $user; + $errors = array(); + + unset($values['password']); + + if ($this->request->isPost()) { + $values = $this->request->getValues(); + + if (! $this->userSession->isAdmin()) { + if (isset($values['role'])) { + unset($values['role']); + } + } + + list($valid, $errors) = $this->userValidator->validateModification($values); + + if ($valid) { + if ($this->user->update($values)) { + $this->flash->success(t('User updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your user.')); + } + + return $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); + } + } + + return $this->response->html($this->helper->layout->user('user_view/edit', array( + 'values' => $values, + 'errors' => $errors, + 'user' => $user, + 'timezones' => $this->timezone->getTimezones(true), + 'languages' => $this->language->getLanguages(true), + 'roles' => $this->role->getApplicationRoles(), + ))); + } + + /** + * Display a form to edit authentication + * + * @access public + */ + public function authentication() + { + $user = $this->getUser(); + $values = $user; + $errors = array(); + + unset($values['password']); + + if ($this->request->isPost()) { + $values = $this->request->getValues() + array('disable_login_form' => 0, 'is_ldap_user' => 0); + list($valid, $errors) = $this->userValidator->validateModification($values); + + if ($valid) { + if ($this->user->update($values)) { + $this->flash->success(t('User updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your user.')); + } + + return $this->response->redirect($this->helper->url->to('UserViewController', 'authentication', array('user_id' => $user['id']))); + } + } + + return $this->response->html($this->helper->layout->user('user_view/authentication', array( + 'values' => $values, + 'errors' => $errors, + 'user' => $user, + ))); + } +} diff --git a/app/Core/Markdown.php b/app/Core/Markdown.php index 8275c752..0e7b6425 100644 --- a/app/Core/Markdown.php +++ b/app/Core/Markdown.php @@ -90,7 +90,7 @@ class Markdown extends Parsedown $user_id = $this->container['user']->getIdByUsername($matches[1]); if (! empty($user_id)) { - $url = $this->container['helper']->url->href('user', 'profile', array('user_id' => $user_id)); + $url = $this->container['helper']->url->href('UserViewController', 'profile', array('user_id' => $user_id)); return array( 'extent' => strlen($matches[0]), diff --git a/app/Helper/LayoutHelper.php b/app/Helper/LayoutHelper.php index 39defc88..75cd178a 100644 --- a/app/Helper/LayoutHelper.php +++ b/app/Helper/LayoutHelper.php @@ -47,7 +47,7 @@ class LayoutHelper extends Base $params['title'] = '#'.$params['user']['id'].' '.($params['user']['name'] ?: $params['user']['username']); } - return $this->subLayout('user/layout', 'user/sidebar', $template, $params); + return $this->subLayout('user_view/layout', 'user_view/sidebar', $template, $params); } /** diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php index 5540bf88..fbc10abf 100644 --- a/app/ServiceProvider/AuthenticationProvider.php +++ b/app/ServiceProvider/AuthenticationProvider.php @@ -100,7 +100,7 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('TaskExternalLink', '*', Role::PROJECT_MEMBER); $acl->add('Taskmodification', '*', Role::PROJECT_MEMBER); $acl->add('Taskstatus', '*', Role::PROJECT_MEMBER); - $acl->add('UserHelper', array('mention'), Role::PROJECT_MEMBER); + $acl->add('UserAjaxController', array('mention'), Role::PROJECT_MEMBER); return $acl; } @@ -141,8 +141,9 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('Twofactor', 'disable', Role::APP_ADMIN); $acl->add('UserImportController', '*', Role::APP_ADMIN); $acl->add('UserCreationController', '*', Role::APP_ADMIN); - $acl->add('User', array('index', 'authentication'), Role::APP_ADMIN); + $acl->add('UserListController', '*', Role::APP_ADMIN); $acl->add('UserStatusController', '*', Role::APP_ADMIN); + $acl->add('UserViewController', array('authentication'), Role::APP_ADMIN); return $acl; } diff --git a/app/ServiceProvider/RouteProvider.php b/app/ServiceProvider/RouteProvider.php index a6d6abef..359bd220 100644 --- a/app/ServiceProvider/RouteProvider.php +++ b/app/ServiceProvider/RouteProvider.php @@ -144,19 +144,19 @@ class RouteProvider implements ServiceProviderInterface $container['route']->addRoute('ical/user/:token', 'ical', 'user'); // Users - $container['route']->addRoute('users', 'user', 'index'); - $container['route']->addRoute('user/profile/:user_id', 'user', 'profile'); - $container['route']->addRoute('user/show/:user_id', 'user', 'show'); - $container['route']->addRoute('user/show/:user_id/timesheet', 'user', 'timesheet'); - $container['route']->addRoute('user/show/:user_id/last-logins', 'user', 'last'); - $container['route']->addRoute('user/show/:user_id/sessions', 'user', 'sessions'); - $container['route']->addRoute('user/:user_id/edit', 'user', 'edit'); - $container['route']->addRoute('user/:user_id/password', 'user', 'password'); - $container['route']->addRoute('user/:user_id/share', 'user', 'share'); - $container['route']->addRoute('user/:user_id/notifications', 'user', 'notifications'); - $container['route']->addRoute('user/:user_id/accounts', 'user', 'external'); - $container['route']->addRoute('user/:user_id/integrations', 'user', 'integrations'); - $container['route']->addRoute('user/:user_id/authentication', 'user', 'authentication'); + $container['route']->addRoute('users', 'UserListController', 'show'); + $container['route']->addRoute('user/profile/:user_id', 'UserViewController', 'profile'); + $container['route']->addRoute('user/show/:user_id', 'UserViewController', 'show'); + $container['route']->addRoute('user/show/:user_id/timesheet', 'UserViewController', 'timesheet'); + $container['route']->addRoute('user/show/:user_id/last-logins', 'UserViewController', 'lastLogin'); + $container['route']->addRoute('user/show/:user_id/sessions', 'UserViewController', 'sessions'); + $container['route']->addRoute('user/:user_id/edit', 'UserViewController', 'edit'); + $container['route']->addRoute('user/:user_id/password', 'UserViewController', 'password'); + $container['route']->addRoute('user/:user_id/share', 'UserViewController', 'share'); + $container['route']->addRoute('user/:user_id/notifications', 'UserViewController', 'notifications'); + $container['route']->addRoute('user/:user_id/accounts', 'UserViewController', 'external'); + $container['route']->addRoute('user/:user_id/integrations', 'UserViewController', 'integrations'); + $container['route']->addRoute('user/:user_id/authentication', 'UserViewController', 'authentication'); $container['route']->addRoute('user/:user_id/2fa', 'twofactor', 'index'); $container['route']->addRoute('user/:user_id/avatar', 'AvatarFile', 'show'); diff --git a/app/Template/comment/create.php b/app/Template/comment/create.php index b6c27ae0..fa7c0ca6 100644 --- a/app/Template/comment/create.php +++ b/app/Template/comment/create.php @@ -15,7 +15,7 @@ 'autofocus', 'required', 'placeholder="'.t('Leave a comment').'"', - 'data-mention-search-url="'.$this->url->href('UserHelper', 'mention', array('project_id' => $task['project_id'])).'"', + 'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $task['project_id'])).'"', ), 'markdown-editor' ) ?> diff --git a/app/Template/comments/create.php b/app/Template/comments/create.php index a638d3b8..633f4392 100644 --- a/app/Template/comments/create.php +++ b/app/Template/comments/create.php @@ -12,7 +12,7 @@ 'data-markdown-editor-disable-toolbar="true"', 'required', 'placeholder="'.t('Leave a comment').'"', - 'data-mention-search-url="'.$this->url->href('UserHelper', 'mention', array('project_id' => $task['project_id'])).'"', + 'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $task['project_id'])).'"', ), 'markdown-editor' ) ?> diff --git a/app/Template/group/index.php b/app/Template/group/index.php index 74e074c3..1062e18c 100644 --- a/app/Template/group/index.php +++ b/app/Template/group/index.php @@ -1,7 +1,7 @@
diff --git a/app/Template/group/users.php b/app/Template/group/users.php index 0f802146..a4895ab7 100644 --- a/app/Template/group/users.php +++ b/app/Template/group/users.php @@ -19,10 +19,10 @@ getCollection() as $user): ?> - url->link('#'.$user['id'], 'user', 'show', array('user_id' => $user['id'])) ?> + url->link('#'.$user['id'], 'UserViewController', 'show', array('user_id' => $user['id'])) ?> - url->link($this->text->e($user['username']), 'user', 'show', array('user_id' => $user['id'])) ?> + url->link($this->text->e($user['username']), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> text->e($user['name']) ?> diff --git a/app/Template/header.php b/app/Template/header.php index bac026d3..23906a9e 100644 --- a/app/Template/header.php +++ b/app/Template/header.php @@ -67,16 +67,16 @@
  • - url->link(t('My profile'), 'user', 'show', array('user_id' => $this->user->getId())) ?> + url->link(t('My profile'), 'UserViewController', 'show', array('user_id' => $this->user->getId())) ?>
  • url->link(t('Projects management'), 'project', 'index') ?>
  • - user->hasAccess('user', 'index')): ?> + user->hasAccess('UserListController', 'show')): ?>
  • - url->link(t('Users management'), 'user', 'index') ?> + url->link(t('Users management'), 'UserListController', 'show') ?>
  • diff --git a/app/Template/layout.php b/app/Template/layout.php index 701b297d..ff29e18f 100644 --- a/app/Template/layout.php +++ b/app/Template/layout.php @@ -44,7 +44,7 @@ hook->render('template:layout:head') ?> - diff --git a/app/Template/task/time_tracking_details.php b/app/Template/task/time_tracking_details.php index c51b8f5a..d86273c5 100644 --- a/app/Template/task/time_tracking_details.php +++ b/app/Template/task/time_tracking_details.php @@ -18,7 +18,7 @@ getCollection() as $record): ?> - url->link($this->text->e($record['user_fullname'] ?: $record['username']), 'user', 'show', array('user_id' => $record['user_id'])) ?> + url->link($this->text->e($record['user_fullname'] ?: $record['username']), 'UserViewController', 'show', array('user_id' => $record['user_id'])) ?> dt->datetime($record['start']) ?> dt->datetime($record['end']) ?> @@ -28,4 +28,4 @@ - \ No newline at end of file + diff --git a/app/Template/task/transitions.php b/app/Template/task/transitions.php index 83040177..9e04c4e1 100644 --- a/app/Template/task/transitions.php +++ b/app/Template/task/transitions.php @@ -22,9 +22,9 @@ dt->datetime($transition['date']) ?> text->e($transition['src_column']) ?> text->e($transition['dst_column']) ?> - url->link($this->text->e($transition['name'] ?: $transition['username']), 'user', 'show', array('user_id' => $transition['user_id'])) ?> + url->link($this->text->e($transition['name'] ?: $transition['username']), 'UserViewController', 'show', array('user_id' => $transition['user_id'])) ?> dt->duration($transition['time_spent']) ?> - \ No newline at end of file + diff --git a/app/Template/task_creation/show.php b/app/Template/task_creation/show.php index d3991177..cecf459d 100644 --- a/app/Template/task_creation/show.php +++ b/app/Template/task_creation/show.php @@ -18,7 +18,7 @@ array( 'placeholder="'.t('Leave a description').'"', 'tabindex="2"', - 'data-mention-search-url="'.$this->url->href('UserHelper', 'mention', array('project_id' => $values['project_id'])).'"' + 'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $values['project_id'])).'"' ), 'markdown-editor' ) ?> diff --git a/app/Template/task_internal_link/table.php b/app/Template/task_internal_link/table.php index 8f25b29b..57a3536c 100644 --- a/app/Template/task_internal_link/table.php +++ b/app/Template/task_internal_link/table.php @@ -52,7 +52,7 @@ - url->link($this->text->e($link['task_assignee_name'] ?: $link['task_assignee_username']), 'user', 'show', array('user_id' => $link['task_assignee_id'])) ?> + url->link($this->text->e($link['task_assignee_name'] ?: $link['task_assignee_username']), 'UserViewController', 'show', array('user_id' => $link['task_assignee_id'])) ?> text->e($link['task_assignee_name'] ?: $link['task_assignee_username']) ?> @@ -82,4 +82,4 @@ - \ No newline at end of file + diff --git a/app/Template/task_modification/edit_description.php b/app/Template/task_modification/edit_description.php index 8c149f4f..801b4005 100644 --- a/app/Template/task_modification/edit_description.php +++ b/app/Template/task_modification/edit_description.php @@ -14,7 +14,7 @@ array( 'autofocus', 'placeholder="'.t('Leave a description').'"', - 'data-mention-search-url="'.$this->url->href('UserHelper', 'mention', array('project_id' => $task['project_id'])).'"' + 'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $task['project_id'])).'"' ), 'markdown-editor' ) ?> diff --git a/app/Template/twofactor/disable.php b/app/Template/twofactor/disable.php index 36be4ef9..bdbe1233 100644 --- a/app/Template/twofactor/disable.php +++ b/app/Template/twofactor/disable.php @@ -9,6 +9,6 @@
    url->link(t('Yes'), 'twofactor', 'disable', array('user_id' => $user['id'], 'disable' => 'yes'), true, 'btn btn-red') ?> - url->link(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?> + url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?>
    - \ No newline at end of file + diff --git a/app/Template/user/authentication.php b/app/Template/user/authentication.php deleted file mode 100644 index 6cfd4e57..00000000 --- a/app/Template/user/authentication.php +++ /dev/null @@ -1,28 +0,0 @@ - -
    - - form->csrf() ?> - - form->hidden('id', $values) ?> - form->hidden('username', $values) ?> - - hook->render('template:user:authentication:form', array('values' => $values, 'errors' => $errors, 'user' => $user)) ?> - - form->checkbox('is_ldap_user', t('Remote user'), 1, isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1) ?> - form->checkbox('disable_login_form', t('Disallow login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?> - -
    - - - url->link(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?> -
    - -
    -
      -
    • -
    • -
    -
    -
    \ No newline at end of file diff --git a/app/Template/user/dropdown.php b/app/Template/user/dropdown.php deleted file mode 100644 index 086bf01b..00000000 --- a/app/Template/user/dropdown.php +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/app/Template/user/edit.php b/app/Template/user/edit.php deleted file mode 100644 index 7b51eb73..00000000 --- a/app/Template/user/edit.php +++ /dev/null @@ -1,35 +0,0 @@ - -
    - - form->csrf() ?> - - form->hidden('id', $values) ?> - - form->label(t('Username'), 'username') ?> - form->text('username', $values, $errors, array('required', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 ? 'readonly' : '', 'maxlength="50"')) ?> - - form->label(t('Name'), 'name') ?> - form->text('name', $values, $errors) ?> - - form->label(t('Email'), 'email') ?> - form->email('email', $values, $errors) ?> - - form->label(t('Timezone'), 'timezone') ?> - form->select('timezone', $timezones, $values, $errors) ?> - - form->label(t('Language'), 'language') ?> - form->select('language', $languages, $values, $errors) ?> - - user->isAdmin()): ?> - form->label(t('Role'), 'role') ?> - form->select('role', $roles, $values, $errors) ?> - - -
    - - - url->link(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?> -
    -
    \ No newline at end of file diff --git a/app/Template/user/external.php b/app/Template/user/external.php deleted file mode 100644 index 22c25af2..00000000 --- a/app/Template/user/external.php +++ /dev/null @@ -1,11 +0,0 @@ - - -hook->render('template:user:external', array('user' => $user)) ?> - - -

    - - - diff --git a/app/Template/user/index.php b/app/Template/user/index.php deleted file mode 100644 index 15923e84..00000000 --- a/app/Template/user/index.php +++ /dev/null @@ -1,66 +0,0 @@ -
    - - isEmpty()): ?> -

    - - - - - - - - - - - - - - getCollection() as $user): ?> - - - - - - - - - - - - -
    order(t('Id'), 'id') ?>order(t('Username'), 'username') ?>order(t('Name'), 'name') ?>order(t('Email'), 'email') ?>order(t('Role'), 'role') ?>order(t('Two Factor'), 'twofactor_activated') ?>order(t('Account type'), 'is_ldap_user') ?>order(t('Status'), 'is_active') ?>
    - - - url->link($this->text->e($user['username']), 'user', 'show', array('user_id' => $user['id'])) ?> - - text->e($user['name']) ?> - - text->e($user['email']) ?> - - user->getRoleName($user['role']) ?> - - - - - - - - - - - - render('user/dropdown', array('user' => $user)) ?> -
    - - - -
    diff --git a/app/Template/user/integrations.php b/app/Template/user/integrations.php deleted file mode 100644 index ef9d8e71..00000000 --- a/app/Template/user/integrations.php +++ /dev/null @@ -1,13 +0,0 @@ - - -
    - form->csrf() ?> - hook->render('template:user:integrations', array('values' => $values)) ?> - - - -

    - -
    diff --git a/app/Template/user/last.php b/app/Template/user/last.php deleted file mode 100644 index 3de4d5e2..00000000 --- a/app/Template/user/last.php +++ /dev/null @@ -1,24 +0,0 @@ - - - -

    - - - - - - - - - - - - - - - - -
    dt->datetime($login['date_creation']) ?>text->e($login['auth_type']) ?>text->e($login['ip']) ?>text->e($login['user_agent']) ?>
    - \ No newline at end of file diff --git a/app/Template/user/layout.php b/app/Template/user/layout.php deleted file mode 100644 index 2c4bb7be..00000000 --- a/app/Template/user/layout.php +++ /dev/null @@ -1,19 +0,0 @@ -
    - - -
    diff --git a/app/Template/user/notifications.php b/app/Template/user/notifications.php deleted file mode 100644 index 6e1a0004..00000000 --- a/app/Template/user/notifications.php +++ /dev/null @@ -1,26 +0,0 @@ - - -
    - form->csrf() ?> - -

    - form->checkboxes('notification_types', $types, $notifications) ?> - -
    -

    - form->radios('notifications_filter', $filters, $notifications) ?> - -
    - -

    - form->checkboxes('notification_projects', $projects, $notifications) ?> - - -
    - - - url->link(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?> -
    -
    \ No newline at end of file diff --git a/app/Template/user/password.php b/app/Template/user/password.php deleted file mode 100644 index ea6e997d..00000000 --- a/app/Template/user/password.php +++ /dev/null @@ -1,26 +0,0 @@ - - -
    - - form->hidden('id', $values) ?> - form->csrf() ?> - -
    - form->label(t('Current password for the user "%s"', $this->user->getFullname()), 'current_password') ?> - form->password('current_password', $values, $errors) ?> -
    - - form->label(t('New password for the user "%s"', $this->user->getFullname($user)), 'password') ?> - form->password('password', $values, $errors) ?> - - form->label(t('Confirmation'), 'confirmation') ?> - form->password('confirmation', $values, $errors) ?> - -
    - - - url->link(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?> -
    -
    diff --git a/app/Template/user/password_reset.php b/app/Template/user/password_reset.php deleted file mode 100644 index 1371ce11..00000000 --- a/app/Template/user/password_reset.php +++ /dev/null @@ -1,26 +0,0 @@ - - - -

    - - - - - - - - - - - - - - - - - - -
    dt->datetime($token['date_creation']) ?>dt->datetime($token['date_expiration']) ?>text->e($token['ip']) ?>text->e($token['user_agent']) ?>
    - \ No newline at end of file diff --git a/app/Template/user/profile.php b/app/Template/user/profile.php deleted file mode 100644 index 9c9d3282..00000000 --- a/app/Template/user/profile.php +++ /dev/null @@ -1,9 +0,0 @@ -
    -
    - avatar->render($user['id'], $user['username'], $user['name'], $user['email'], $user['avatar_path']) ?> -
      -
    • text->e($user['username']) ?>
    • -
    • text->e($user['name']) ?: t('None') ?>
    • -
    • text->e($user['email']) ?: t('None') ?>
    • -
    -
    \ No newline at end of file diff --git a/app/Template/user/sessions.php b/app/Template/user/sessions.php deleted file mode 100644 index d7fe895d..00000000 --- a/app/Template/user/sessions.php +++ /dev/null @@ -1,26 +0,0 @@ - - - -

    - - - - - - - - - - - - - - - - - - -
    dt->datetime($session['date_creation']) ?>dt->datetime($session['expiration']) ?>text->e($session['ip']) ?>text->e($session['user_agent']) ?>url->link(t('Remove'), 'User', 'removeSession', array('user_id' => $user['id'], 'id' => $session['id']), true) ?>
    - diff --git a/app/Template/user/share.php b/app/Template/user/share.php deleted file mode 100644 index 56dc8675..00000000 --- a/app/Template/user/share.php +++ /dev/null @@ -1,18 +0,0 @@ - - - - -
    -
      -
    • url->link(t('RSS feed'), 'feed', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • -
    • url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • -
    -
    - - url->link(t('Disable public access'), 'user', 'share', array('user_id' => $user['id'], 'switch' => 'disable'), true, 'btn btn-red') ?> - - - url->link(t('Enable public access'), 'user', 'share', array('user_id' => $user['id'], 'switch' => 'enable'), true, 'btn btn-blue') ?> - diff --git a/app/Template/user/show.php b/app/Template/user/show.php deleted file mode 100644 index df0affb8..00000000 --- a/app/Template/user/show.php +++ /dev/null @@ -1,40 +0,0 @@ - -
      -
    • text->e($user['username']) ?>
    • -
    • text->e($user['name']) ?: t('None') ?>
    • -
    • text->e($user['email']) ?: t('None') ?>
    • -
    • -
    - - -
      -
    • user->getRoleName($user['role']) ?>
    • -
    • -
    • -
    - - -
      -
    • text->in($user['timezone'], $timezones) ?>
    • -
    • text->in($user['language'], $languages) ?>
    • -
    • -
    - - - - -
    -
      -
    • url->link(t('RSS feed'), 'feed', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • -
    • url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • -
    -
    - diff --git a/app/Template/user/sidebar.php b/app/Template/user/sidebar.php deleted file mode 100644 index 9da43ced..00000000 --- a/app/Template/user/sidebar.php +++ /dev/null @@ -1,83 +0,0 @@ - diff --git a/app/Template/user/timesheet.php b/app/Template/user/timesheet.php deleted file mode 100644 index 92ebafb5..00000000 --- a/app/Template/user/timesheet.php +++ /dev/null @@ -1,29 +0,0 @@ - - -

    -isEmpty()): ?> -

    - - - - - - - - - - getCollection() as $record): ?> - - - - - - - - -
    order(t('Task'), 'task_title') ?>order(t('Subtask'), 'subtask_title') ?>order(t('Start'), 'start') ?>order(t('End'), 'end') ?>order(t('Time spent'), 'time_spent') ?>
    url->link($this->text->e($record['task_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?>url->link($this->text->e($record['subtask_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?>dt->datetime($record['start']) ?>dt->datetime($record['end']) ?>
    - - - \ No newline at end of file diff --git a/app/Template/user_creation/local.php b/app/Template/user_creation/local.php index a83074e8..4c224cec 100644 --- a/app/Template/user_creation/local.php +++ b/app/Template/user_creation/local.php @@ -40,6 +40,6 @@
    - url->link(t('cancel'), 'user', 'index', array(), false, 'close-popover') ?> + url->link(t('cancel'), 'UserListController', 'show', array(), false, 'close-popover') ?>
    diff --git a/app/Template/user_creation/remote.php b/app/Template/user_creation/remote.php index 5266fce8..dc4981a4 100644 --- a/app/Template/user_creation/remote.php +++ b/app/Template/user_creation/remote.php @@ -39,7 +39,7 @@
    - url->link(t('cancel'), 'user', 'index', array(), false, 'close-popover') ?> + url->link(t('cancel'), 'UserListController', 'show', array(), false, 'close-popover') ?>
    diff --git a/app/Template/user_import/show.php b/app/Template/user_import/show.php index 54a66237..663f107e 100644 --- a/app/Template/user_import/show.php +++ b/app/Template/user_import/show.php @@ -36,6 +36,6 @@
    - url->link(t('cancel'), 'user', 'index', array(), false, 'close-popover') ?> + url->link(t('cancel'), 'UserListController', 'show', array(), false, 'close-popover') ?>
    diff --git a/app/Template/user_list/dropdown.php b/app/Template/user_list/dropdown.php new file mode 100644 index 00000000..9e90c230 --- /dev/null +++ b/app/Template/user_list/dropdown.php @@ -0,0 +1,27 @@ + diff --git a/app/Template/user_list/show.php b/app/Template/user_list/show.php new file mode 100644 index 00000000..b2bd9377 --- /dev/null +++ b/app/Template/user_list/show.php @@ -0,0 +1,66 @@ +
    + + isEmpty()): ?> +

    + + + + + + + + + + + + + + getCollection() as $user): ?> + + + + + + + + + + + + +
    order(t('Id'), 'id') ?>order(t('Username'), 'username') ?>order(t('Name'), 'name') ?>order(t('Email'), 'email') ?>order(t('Role'), 'role') ?>order(t('Two Factor'), 'twofactor_activated') ?>order(t('Account type'), 'is_ldap_user') ?>order(t('Status'), 'is_active') ?>
    + + + url->link($this->text->e($user['username']), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> + + text->e($user['name']) ?> + + text->e($user['email']) ?> + + user->getRoleName($user['role']) ?> + + + + + + + + + + + + render('user_list/dropdown', array('user' => $user)) ?> +
    + + + +
    diff --git a/app/Template/user_status/disable.php b/app/Template/user_status/disable.php index b551b3b8..d30b0c20 100644 --- a/app/Template/user_status/disable.php +++ b/app/Template/user_status/disable.php @@ -8,6 +8,6 @@
    url->link(t('Yes'), 'UserStatusController', 'disable', array('user_id' => $user['id']), true, 'btn btn-red') ?> - url->link(t('cancel'), 'user', 'index', array(), false, 'close-popover') ?> + url->link(t('cancel'), 'UserListController', 'show', array(), false, 'close-popover') ?>
    diff --git a/app/Template/user_status/enable.php b/app/Template/user_status/enable.php index fe527047..29d25eee 100644 --- a/app/Template/user_status/enable.php +++ b/app/Template/user_status/enable.php @@ -8,6 +8,6 @@
    url->link(t('Yes'), 'UserStatusController', 'enable', array('user_id' => $user['id']), true, 'btn btn-red') ?> - url->link(t('cancel'), 'user', 'index', array(), false, 'close-popover') ?> + url->link(t('cancel'), 'UserListController', 'show', array(), false, 'close-popover') ?>
    diff --git a/app/Template/user_status/remove.php b/app/Template/user_status/remove.php index c8458092..2b8f2df5 100644 --- a/app/Template/user_status/remove.php +++ b/app/Template/user_status/remove.php @@ -8,6 +8,6 @@
    url->link(t('Yes'), 'UserStatusController', 'remove', array('user_id' => $user['id']), true, 'btn btn-red') ?> - url->link(t('cancel'), 'user', 'index', array(), false, 'close-popover') ?> + url->link(t('cancel'), 'UserListController', 'show', array(), false, 'close-popover') ?>
    diff --git a/app/Template/user_view/authentication.php b/app/Template/user_view/authentication.php new file mode 100644 index 00000000..44643388 --- /dev/null +++ b/app/Template/user_view/authentication.php @@ -0,0 +1,27 @@ + +
    + form->csrf() ?> + + form->hidden('id', $values) ?> + form->hidden('username', $values) ?> + + hook->render('template:user:authentication:form', array('values' => $values, 'errors' => $errors, 'user' => $user)) ?> + + form->checkbox('is_ldap_user', t('Remote user'), 1, isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1) ?> + form->checkbox('disable_login_form', t('Disallow login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?> + +
    + + + url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> +
    + +
    +
      +
    • +
    • +
    +
    +
    diff --git a/app/Template/user_view/edit.php b/app/Template/user_view/edit.php new file mode 100644 index 00000000..18947905 --- /dev/null +++ b/app/Template/user_view/edit.php @@ -0,0 +1,35 @@ + +
    + + form->csrf() ?> + + form->hidden('id', $values) ?> + + form->label(t('Username'), 'username') ?> + form->text('username', $values, $errors, array('required', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 ? 'readonly' : '', 'maxlength="50"')) ?> + + form->label(t('Name'), 'name') ?> + form->text('name', $values, $errors) ?> + + form->label(t('Email'), 'email') ?> + form->email('email', $values, $errors) ?> + + form->label(t('Timezone'), 'timezone') ?> + form->select('timezone', $timezones, $values, $errors) ?> + + form->label(t('Language'), 'language') ?> + form->select('language', $languages, $values, $errors) ?> + + user->isAdmin()): ?> + form->label(t('Role'), 'role') ?> + form->select('role', $roles, $values, $errors) ?> + + +
    + + + url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> +
    +
    diff --git a/app/Template/user_view/external.php b/app/Template/user_view/external.php new file mode 100644 index 00000000..22c25af2 --- /dev/null +++ b/app/Template/user_view/external.php @@ -0,0 +1,11 @@ + + +hook->render('template:user:external', array('user' => $user)) ?> + + +

    + + + diff --git a/app/Template/user_view/integrations.php b/app/Template/user_view/integrations.php new file mode 100644 index 00000000..4a237346 --- /dev/null +++ b/app/Template/user_view/integrations.php @@ -0,0 +1,13 @@ + + +
    + form->csrf() ?> + hook->render('template:user:integrations', array('values' => $values)) ?> + + + +

    + +
    diff --git a/app/Template/user_view/last.php b/app/Template/user_view/last.php new file mode 100644 index 00000000..3de4d5e2 --- /dev/null +++ b/app/Template/user_view/last.php @@ -0,0 +1,24 @@ + + + +

    + + + + + + + + + + + + + + + + +
    dt->datetime($login['date_creation']) ?>text->e($login['auth_type']) ?>text->e($login['ip']) ?>text->e($login['user_agent']) ?>
    + \ No newline at end of file diff --git a/app/Template/user_view/layout.php b/app/Template/user_view/layout.php new file mode 100644 index 00000000..c3604b99 --- /dev/null +++ b/app/Template/user_view/layout.php @@ -0,0 +1,19 @@ +
    + + +
    diff --git a/app/Template/user_view/notifications.php b/app/Template/user_view/notifications.php new file mode 100644 index 00000000..84ca1282 --- /dev/null +++ b/app/Template/user_view/notifications.php @@ -0,0 +1,26 @@ + + +
    + form->csrf() ?> + +

    + form->checkboxes('notification_types', $types, $notifications) ?> + +
    +

    + form->radios('notifications_filter', $filters, $notifications) ?> + +
    + +

    + form->checkboxes('notification_projects', $projects, $notifications) ?> + + +
    + + + url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> +
    +
    diff --git a/app/Template/user_view/password.php b/app/Template/user_view/password.php new file mode 100644 index 00000000..32ff9d5c --- /dev/null +++ b/app/Template/user_view/password.php @@ -0,0 +1,26 @@ + + +
    + + form->hidden('id', $values) ?> + form->csrf() ?> + +
    + form->label(t('Current password for the user "%s"', $this->user->getFullname()), 'current_password') ?> + form->password('current_password', $values, $errors) ?> +
    + + form->label(t('New password for the user "%s"', $this->user->getFullname($user)), 'password') ?> + form->password('password', $values, $errors) ?> + + form->label(t('Confirmation'), 'confirmation') ?> + form->password('confirmation', $values, $errors) ?> + +
    + + + url->link(t('cancel'), 'UserViewController', 'show', array('user_id' => $user['id'])) ?> +
    +
    diff --git a/app/Template/user_view/password_reset.php b/app/Template/user_view/password_reset.php new file mode 100644 index 00000000..1371ce11 --- /dev/null +++ b/app/Template/user_view/password_reset.php @@ -0,0 +1,26 @@ + + + +

    + + + + + + + + + + + + + + + + + + +
    dt->datetime($token['date_creation']) ?>dt->datetime($token['date_expiration']) ?>text->e($token['ip']) ?>text->e($token['user_agent']) ?>
    + \ No newline at end of file diff --git a/app/Template/user_view/profile.php b/app/Template/user_view/profile.php new file mode 100644 index 00000000..9c9d3282 --- /dev/null +++ b/app/Template/user_view/profile.php @@ -0,0 +1,9 @@ +
    +
    + avatar->render($user['id'], $user['username'], $user['name'], $user['email'], $user['avatar_path']) ?> +
      +
    • text->e($user['username']) ?>
    • +
    • text->e($user['name']) ?: t('None') ?>
    • +
    • text->e($user['email']) ?: t('None') ?>
    • +
    +
    \ No newline at end of file diff --git a/app/Template/user_view/sessions.php b/app/Template/user_view/sessions.php new file mode 100644 index 00000000..eda3ef7f --- /dev/null +++ b/app/Template/user_view/sessions.php @@ -0,0 +1,26 @@ + + + +

    + + + + + + + + + + + + + + + + + + +
    dt->datetime($session['date_creation']) ?>dt->datetime($session['expiration']) ?>text->e($session['ip']) ?>text->e($session['user_agent']) ?>url->link(t('Remove'), 'UserViewController', 'removeSession', array('user_id' => $user['id'], 'id' => $session['id']), true) ?>
    + diff --git a/app/Template/user_view/share.php b/app/Template/user_view/share.php new file mode 100644 index 00000000..9ef150e8 --- /dev/null +++ b/app/Template/user_view/share.php @@ -0,0 +1,15 @@ + + + +
    +
      +
    • url->link(t('RSS feed'), 'feed', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • +
    • url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • +
    +
    + url->link(t('Disable public access'), 'UserViewController', 'share', array('user_id' => $user['id'], 'switch' => 'disable'), true, 'btn btn-red') ?> + + url->link(t('Enable public access'), 'UserViewController', 'share', array('user_id' => $user['id'], 'switch' => 'enable'), true, 'btn btn-blue') ?> + diff --git a/app/Template/user_view/show.php b/app/Template/user_view/show.php new file mode 100644 index 00000000..df0affb8 --- /dev/null +++ b/app/Template/user_view/show.php @@ -0,0 +1,40 @@ + +
      +
    • text->e($user['username']) ?>
    • +
    • text->e($user['name']) ?: t('None') ?>
    • +
    • text->e($user['email']) ?: t('None') ?>
    • +
    • +
    + + +
      +
    • user->getRoleName($user['role']) ?>
    • +
    • +
    • +
    + + +
      +
    • text->in($user['timezone'], $timezones) ?>
    • +
    • text->in($user['language'], $languages) ?>
    • +
    • +
    + + + + +
    +
      +
    • url->link(t('RSS feed'), 'feed', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • +
    • url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?>
    • +
    +
    + diff --git a/app/Template/user_view/sidebar.php b/app/Template/user_view/sidebar.php new file mode 100644 index 00000000..9a25df16 --- /dev/null +++ b/app/Template/user_view/sidebar.php @@ -0,0 +1,83 @@ + diff --git a/app/Template/user_view/timesheet.php b/app/Template/user_view/timesheet.php new file mode 100644 index 00000000..92ebafb5 --- /dev/null +++ b/app/Template/user_view/timesheet.php @@ -0,0 +1,29 @@ + + +

    +isEmpty()): ?> +

    + + + + + + + + + + getCollection() as $record): ?> + + + + + + + + +
    order(t('Task'), 'task_title') ?>order(t('Subtask'), 'subtask_title') ?>order(t('Start'), 'start') ?>order(t('End'), 'end') ?>order(t('Time spent'), 'time_spent') ?>
    url->link($this->text->e($record['task_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?>url->link($this->text->e($record['subtask_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?>dt->datetime($record['start']) ?>dt->datetime($record['end']) ?>
    + + + \ No newline at end of file -- cgit v1.2.3