From 7f5a871f84639a90eebd0ac1d0ee7f759e220cf6 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 5 Oct 2014 12:32:44 -0400 Subject: Projects are not anymore visible to everybody by default --- app/Locales/de_DE/translations.php | 4 ++-- app/Locales/es_ES/translations.php | 4 ++-- app/Locales/fi_FI/translations.php | 4 ++-- app/Locales/fr_FR/translations.php | 4 ++-- app/Locales/it_IT/translations.php | 4 ++-- app/Locales/pl_PL/translations.php | 4 ++-- app/Locales/pt_BR/translations.php | 4 ++-- app/Locales/ru_RU/translations.php | 4 ++-- app/Locales/sv_SE/translations.php | 4 ++-- app/Locales/zh_CN/translations.php | 4 ++-- app/Model/ProjectPermission.php | 24 ++++-------------------- app/Model/User.php | 18 ++++++++++++++++++ app/Templates/project_sidebar.php | 2 +- app/Templates/project_users.php | 2 +- 14 files changed, 44 insertions(+), 42 deletions(-) (limited to 'app') diff --git a/app/Locales/de_DE/translations.php b/app/Locales/de_DE/translations.php index 4e72cfc0..db6e83ed 100644 --- a/app/Locales/de_DE/translations.php +++ b/app/Locales/de_DE/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'entfernen', 'List of authorized users' => 'Liste der autorisierten Benutzer', 'User' => 'Benutzer', - 'Everybody have access to this project.' => 'Jeder hat Zugang zu diesem Projekt.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Unzureichende Zugriffsrechte zu diesem Projekt.', 'Comments' => 'Kommentare', 'Post comment' => 'Kommentieren', @@ -421,7 +421,7 @@ return array( // 'view the task on Kanboard' => '', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Locales/es_ES/translations.php b/app/Locales/es_ES/translations.php index 4e7bc537..cd611bf8 100644 --- a/app/Locales/es_ES/translations.php +++ b/app/Locales/es_ES/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'revocar', 'List of authorized users' => 'Lista de los usuarios autorizados', 'User' => 'Usuario', - 'Everybody have access to this project.' => 'Todo el mundo tiene acceso al proyecto.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'No está autorizado a acceder a este proyecto.', 'Comments' => 'Comentarios', 'Post comment' => 'Commentar', @@ -421,7 +421,7 @@ return array( 'view the task on Kanboard' => 'ver la tarea en Kanboard', 'Public access' => 'Acceso público', 'Categories management' => 'Gestión de Categorías', - 'Users management' => 'Gestión de Usuarios', + 'User management' => 'Gestión de Usuarios', 'Active tasks' => 'Tareas activas', 'Disable public access' => 'Desactivar acceso público', 'Enable public access' => 'Activar acceso público', diff --git a/app/Locales/fi_FI/translations.php b/app/Locales/fi_FI/translations.php index f5618b8b..f832de66 100644 --- a/app/Locales/fi_FI/translations.php +++ b/app/Locales/fi_FI/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'poista', 'List of authorized users' => 'Sallittujen käyttäjien lista', 'User' => 'Käyttäjät', - 'Everybody have access to this project.' => 'Kaikilla on pääsy tähän projektiin.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Sinulla ei ole pääsyä tähän projektiin.', 'Comments' => 'Kommentit', 'Post comment' => 'Lisää kommentti', @@ -421,7 +421,7 @@ return array( // 'view the task on Kanboard' => '', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Locales/fr_FR/translations.php b/app/Locales/fr_FR/translations.php index 8c9c74ea..dc7fcc72 100644 --- a/app/Locales/fr_FR/translations.php +++ b/app/Locales/fr_FR/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'révoquer', 'List of authorized users' => 'Liste des utilisateurs autorisés', 'User' => 'Utilisateur', - 'Everybody have access to this project.' => 'Tout le monde a accès au projet.', + 'Nobody have access to this project.' => 'Personne n\'est autorisé à accéder au projet.', 'You are not allowed to access to this project.' => 'Vous n\'êtes pas autorisé à accéder à ce projet.', 'Comments' => 'Commentaires', 'Post comment' => 'Commenter', @@ -421,7 +421,7 @@ return array( 'view the task on Kanboard' => 'voir la tâche sur Kanboard', 'Public access' => 'Accès public', 'Categories management' => 'Gestion des catégories', - 'Users management' => 'Gestion des utilisateurs', + 'User management' => 'Gestion des utilisateurs', 'Active tasks' => 'Tâches actives', 'Disable public access' => 'Désactiver l\'accès public', 'Enable public access' => 'Activer l\'accès public', diff --git a/app/Locales/it_IT/translations.php b/app/Locales/it_IT/translations.php index 24d13360..8e9343f6 100644 --- a/app/Locales/it_IT/translations.php +++ b/app/Locales/it_IT/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'revocare', 'List of authorized users' => 'Lista di utenti autorizzati', 'User' => 'Utente', - 'Everybody have access to this project.' => 'Tutti hanno accesso a questo progetto.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Non hai l\'accesso a questo progetto.', 'Comments' => 'Commenti', 'Post comment' => 'Mandare commento', @@ -421,7 +421,7 @@ return array( 'view the task on Kanboard' => 'vedi il compito su Kanboard', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Locales/pl_PL/translations.php b/app/Locales/pl_PL/translations.php index 41e5555d..e0e25f28 100644 --- a/app/Locales/pl_PL/translations.php +++ b/app/Locales/pl_PL/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'odbierz dostęp', 'List of authorized users' => 'Lista użytkowników mających dostęp', 'User' => 'Użytkownik', - 'Everybody have access to this project.' => 'Każdy ma dostęp do tego projektu.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Nie masz dostępu do tego projektu.', 'Comments' => 'Komentarze', 'Post comment' => 'Dodaj komentarz', @@ -421,7 +421,7 @@ return array( // 'view the task on Kanboard' => '', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Locales/pt_BR/translations.php b/app/Locales/pt_BR/translations.php index 89f789c3..b53650a7 100644 --- a/app/Locales/pt_BR/translations.php +++ b/app/Locales/pt_BR/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'revogar', 'List of authorized users' => 'Lista de usuários autorizados', 'User' => 'Usuário', - 'Everybody have access to this project.' => 'Todos têm acesso a este projeto.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Você não está autorizado a acessar este projeto.', 'Comments' => 'Comentários', 'Post comment' => 'Postar comentário', @@ -421,7 +421,7 @@ return array( // 'view the task on Kanboard' => '', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Locales/ru_RU/translations.php b/app/Locales/ru_RU/translations.php index e658c09c..7783b781 100644 --- a/app/Locales/ru_RU/translations.php +++ b/app/Locales/ru_RU/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'отозвать', 'List of authorized users' => 'Список авторизованных пользователей', 'User' => 'Пользователь', - 'Everybody have access to this project.' => 'Кто угодно имеет доступ к этому проекту.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Вам запрешен доступ к этому проекту.', 'Comments' => 'Комментарии', 'Post comment' => 'Оставить комментарий', @@ -421,7 +421,7 @@ return array( 'view the task on Kanboard' => 'посмотреть задачу на Kanboard', 'Public access' => 'Общий доступ', 'Categories management' => 'Управление категориями', - 'Users management' => 'Управление пользователями', + 'User management' => 'Управление пользователями', 'Active tasks' => 'Активные задачи', 'Disable public access' => 'Отключить общий доступ', 'Enable public access' => 'Включить общий доступ', diff --git a/app/Locales/sv_SE/translations.php b/app/Locales/sv_SE/translations.php index 9c9eac02..e8994fbb 100644 --- a/app/Locales/sv_SE/translations.php +++ b/app/Locales/sv_SE/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => 'Dra tillbaka behörighet', 'List of authorized users' => 'Lista med behöriga användare', 'User' => 'Användare', - 'Everybody have access to this project.' => 'Alla har tillgång till detta projekt.', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => 'Du har inte tillgång till detta projekt.', 'Comments' => 'Kommentarer', 'Post comment' => 'Ladda upp kommentar', @@ -421,7 +421,7 @@ return array( 'view the task on Kanboard' => 'Visa uppgiften på Kanboard', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Locales/zh_CN/translations.php b/app/Locales/zh_CN/translations.php index 41afd362..8d4b3678 100644 --- a/app/Locales/zh_CN/translations.php +++ b/app/Locales/zh_CN/translations.php @@ -196,7 +196,7 @@ return array( 'revoke' => '撤销', 'List of authorized users' => '已授权的用户列表', 'User' => '用户', - 'Everybody have access to this project.' => '任何人都有该项目权限。', + // 'Nobody have access to this project.' => '', 'You are not allowed to access to this project.' => '您对该项目没有权限。', 'Comments' => '评论', 'Post comment' => '发表评论', @@ -421,7 +421,7 @@ return array( // 'view the task on Kanboard' => '', // 'Public access' => '', // 'Categories management' => '', - // 'Users management' => '', + // 'User management' => '', // 'Active tasks' => '', // 'Disable public access' => '', // 'Enable public access' => '', diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php index 51c11735..9d339f4d 100644 --- a/app/Model/ProjectPermission.php +++ b/app/Model/ProjectPermission.php @@ -33,10 +33,6 @@ class ProjectPermission extends Base { $allowed_users = $this->getAllowedUsers($project_id); - if (empty($allowed_users)) { - $allowed_users = $this->user->getList(); - } - if ($prepend_unassigned) { $allowed_users = array(t('Unassigned')) + $allowed_users; } @@ -146,22 +142,10 @@ class ProjectPermission extends Base */ public function isUserAllowed($project_id, $user_id) { - // If there is nobody specified, everybody have access to the project - $nb_users = $this->db - ->table(self::TABLE) - ->eq('project_id', $project_id) - ->count(); - - if ($nb_users < 1) return true; - - // Check if user has admin rights - $nb_users = $this->db - ->table(User::TABLE) - ->eq('id', $user_id) - ->eq('is_admin', 1) - ->count(); - - if ($nb_users > 0) return true; + // Check if the user has admin rights + if ($this->user->isAdmin($user_id)) { + return true; + } // Otherwise, allow only specific users return (bool) $this->db diff --git a/app/Model/User.php b/app/Model/User.php index b54f6309..33bd6720 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -28,6 +28,24 @@ class User extends Base */ const EVERYBODY_ID = -1; + /** + * Return true is the given user id is administrator + * + * @access public + * @param integer $user_id User id + * @return boolean + */ + public function isAdmin($user_id) + { + $result = $this->db + ->table(User::TABLE) + ->eq('id', $user_id) + ->eq('is_admin', 1) + ->count(); + + return $result > 0; + } + /** * Get the default project from the session * diff --git a/app/Templates/project_sidebar.php b/app/Templates/project_sidebar.php index d711e347..41f1d447 100644 --- a/app/Templates/project_sidebar.php +++ b/app/Templates/project_sidebar.php @@ -23,7 +23,7 @@
  • - +
  • diff --git a/app/Templates/project_users.php b/app/Templates/project_users.php index dca3524f..8d75f39f 100644 --- a/app/Templates/project_users.php +++ b/app/Templates/project_users.php @@ -3,7 +3,7 @@ -
    +

    -- cgit v1.2.3