From 9ad84bfb6ed27f1a98820b810c0d5fcf630eba79 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 24 Feb 2018 21:52:18 +0000 Subject: [PATCH] More work in progress on roles. Implemented status edit for roles. --- WEB-INF/lib/ttRoleHelper.class.php | 36 ++++++++++++ WEB-INF/lib/ttTaskHelper.class.php | 9 ++- WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 2 + WEB-INF/resources/de.lang.php | 2 + WEB-INF/resources/en.lang.php | 1 + WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 1 + WEB-INF/resources/fa.lang.php | 2 + WEB-INF/resources/fi.lang.php | 2 + WEB-INF/resources/fr.lang.php | 2 + WEB-INF/resources/he.lang.php | 2 + WEB-INF/resources/hu.lang.php | 1 + WEB-INF/resources/it.lang.php | 2 + WEB-INF/resources/ja.lang.php | 2 + WEB-INF/resources/ko.lang.php | 2 + WEB-INF/resources/nl.lang.php | 2 + WEB-INF/resources/no.lang.php | 2 + WEB-INF/resources/pl.lang.php | 2 + WEB-INF/resources/pt-br.lang.php | 2 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 1 + WEB-INF/resources/sk.lang.php | 2 + WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 2 + WEB-INF/resources/sv.lang.php | 2 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 2 + WEB-INF/resources/zh-tw.lang.php | 2 + WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/role_edit.tpl | 33 +++++++++++ role_edit.php | 88 ++++++++++++++++++++++++++++++ 34 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 WEB-INF/templates/role_edit.tpl create mode 100644 role_edit.php diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index 08e1a218..957bcdaf 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -50,6 +50,42 @@ class ttRoleHelper { return false; } + // The getRoleByName looks up a role by name. + static function getRoleByName($role_name) { + + $mdb2 = getConnection(); + global $user; + + $sql = "select id from tt_roless where team_id = $user->team_id and name = ". + $mdb2->quote($role_name)." and (status = 1 or status = 0)"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['id']) + return $val; + } + return false; + } + + // update function updates a role in the database. + static function update($fields) + { + global $user; + $mdb2 = getConnection(); + + $id = (int)$fields['id']; + $name = $fields['name']; + $description = $fields['description']; + $status = (int)$fields['status']; + // TODO: add rights later when we have them. + + $sql = "update tt_roles set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description). + ", status = $status where id = $id and team_id = $user->team_id"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } + // delete - marks the role as deleted. static function delete($role_id) { global $user; diff --git a/WEB-INF/lib/ttTaskHelper.class.php b/WEB-INF/lib/ttTaskHelper.class.php index d238bfbc..2bb99da4 100644 --- a/WEB-INF/lib/ttTaskHelper.class.php +++ b/WEB-INF/lib/ttTaskHelper.class.php @@ -79,13 +79,12 @@ class ttTaskHelper { $sql = "select id from tt_tasks where team_id = $user->team_id and name = ". $mdb2->quote($task_name)." and (status = 1 or status = 0)"; - $res = $mdb2->query($sql); + $res = $mdb2->query($sql); - if (!is_a($res, 'PEAR_Error')) { + if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); - if ($val['id']) { + if ($val['id']) return $val; - } } return false; } @@ -185,7 +184,7 @@ class ttTaskHelper { return $last_id; } - // update function updates a task in database. + // update function updates a task in the database. static function update($fields) { global $user; diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 3ea8edcf..4fe1148d 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -92,6 +92,7 @@ $i18n_key_words = array( 'error.auth' => 'Usuari o parula de pas incorrecta.', // TODO: translate the following. // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Ja existeix un projecte amb aquest nom.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index e7e7318b..5a04757b 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -94,6 +94,7 @@ $i18n_key_words = array( 'error.auth' => 'Nesprávné jméno nebo heslo.', // TODO: translate the following. // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Projekt tohoto jména již existuje.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index 177b2d14..b5ec4b22 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -80,6 +80,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Forkert brugernavn eller adgangskode.', 'error.user_exists' => 'Brugernavn eksistere allerede.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Der eksiterer allerede et projekt med det navn.', 'error.task_exists' => 'Opgavenavn eksistere allerede.', 'error.client_exists' => 'Der eksistere allerede en klient med dette navn.', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index ea9460e6..3cd95680 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -80,6 +80,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Benutzername oder Passwort ungültig.', 'error.user_exists' => 'Benutzer mit diesem Konto ist bereits vorhanden.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Es gibt bereits ein Projekt mit diesem Namen.', 'error.task_exists' => 'Task mit diesem Namen existiert bereits.', 'error.client_exists' => 'Der Kunde mit dem Namen existiert schon.', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 6ddf977b..408c0392 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -80,6 +80,7 @@ $i18n_key_words = array( 'error.record' => 'Select record.', 'error.auth' => 'Incorrect login or password.', 'error.user_exists' => 'User with this login already exists.', +'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Project with this name already exists.', 'error.task_exists' => 'Task with this name already exists.', 'error.client_exists' => 'Client with this name already exists.', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 069527db..7e618924 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -90,6 +90,7 @@ $i18n_key_words = array( 'error.auth' => 'Usuario o contraseña incorrecta.', // TODO: translate the following. // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Ya existe un proyecto con este nombre.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 01aefb22..b572ae95 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -94,6 +94,7 @@ $i18n_key_words = array( 'error.auth' => 'Vale login või salasõna.', // TODO: translate the following. // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Selle nimega projekt on juba olemas.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 8b023751..020b403b 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -86,6 +86,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'نام کاربری یا رمز عبور اشتباه است.', 'error.user_exists' => 'کاربری با این نام کاربری موجود است.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'پروژه ای با این نام موجود است.', 'error.task_exists' => 'وظیفه ای با این نام هم اکنون وجود دارد.', 'error.client_exists' => 'مشتری با این نام هم اکنون وجود دارد.', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 68e953aa..c608cb87 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -82,6 +82,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Virheellinen käyttäjänimi tai salasana.', 'error.user_exists' => 'Tämä käyttäjänimi on jo olemassa.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Tämän niminen projekti on jo olemassa.', 'error.task_exists' => 'Tämän niminen tehtävä on jo olemassa.', 'error.client_exists' => 'Tämän niminen asiakas on jo olemassa.', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index e22f856d..76457f33 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -80,6 +80,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Nom d\\\'utilisateur ou mot de passe incorrect.', 'error.user_exists' => 'Un utilisateur avec cet identifiant existe déjà.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Un projet avec ce nom existe déjà.', 'error.task_exists' => 'Une tâche avec ce nom existe déjà.', 'error.client_exists' => 'Un client avec ce nom existe déjà.', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 1c7d48de..9a3a14a9 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -96,6 +96,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'שם משתמש או סיסמה שגויים', 'error.user_exists' => 'שם משתמש כבר קיים', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'שם פרוייקט כבר קיים', 'error.task_exists' => 'קיימת משימה עם שם דומה', 'error.client_exists' => 'שם לקוח כבר קיים', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 9704884a..88db6688 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -91,6 +91,7 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', // 'error.auth' => 'Incorrect login or password.', // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Ilyen nevű projekt már létezik.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 141a6f83..37407a90 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -81,6 +81,8 @@ $i18n_key_words = array( 'error.record' => 'Seleziona record.', 'error.auth' => 'Login o password errati.', 'error.user_exists' => 'Esiste già un utente con questo username.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Esiste già un progetto con questo nome.', 'error.task_exists' => 'Esiste già un compito con questo nome.', 'error.client_exists' => 'Esiste già un cliente con questo nome.', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 42c2f109..0c857f9d 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -91,6 +91,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => '不正確なログインあるいはパスワードが不正確です。', 'error.user_exists' => 'このログインと関連されたユーザーは既に存在します。', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'この名前のプロジェクトは既に存在します。', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 005fb34d..115cfe01 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -91,6 +91,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => '부정확한 로그인 혹은 암호가 틀립니다.', 'error.user_exists' => '본 로그인과 연계된 사용자가 이미 있습니다.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => '본 이름과 연계된 프로젝트가 이미 있습니다.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 36ab344e..9cc82c8f 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -79,6 +79,8 @@ $i18n_key_words = array( 'error.record' => 'Selecteer record.', // TODO: why not Kies as above? 'error.auth' => 'Onjuiste inlognaam of wachtwoord.', 'error.user_exists' => 'Een gebruiker met deze inlognaam bestaat al.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Een project met deze naam bestaat al.', 'error.task_exists' => 'Er bestaat al een taak met deze naam.', 'error.client_exists' => 'Een klant met deze naam bestaat al.', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index c7573bea..a369452f 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -90,6 +90,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Feil brukernavn eller passord.', 'error.user_exists' => 'Bruker med et slikt brukernavn eksisterer allerede.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Et prosjekt med dette navnet er allerede opprettet.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index a91a7544..27466aa3 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -83,6 +83,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Błędny login lub hasło.', 'error.user_exists' => 'Użytkownik o takiej nazwie już istnieje.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Projekt o takiej nazwie już istnieje.', 'error.task_exists' => 'Zadanie o takiej nazwie już istnieje.', 'error.client_exists' => 'Klient o takiej nazwie już istnieje.', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index aecc2226..f6e74480 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -81,6 +81,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Usuário ou senha incorretos.', 'error.user_exists' => 'Já existe usuário com este login.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Já existe projeto com este nome.', 'error.task_exists' => 'Já existe tarefa com este nome.', 'error.client_exists' => 'Já existe cliente com este nome.', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 6aeed5ed..2a4f3a1d 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -91,6 +91,7 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', // 'error.auth' => 'Incorrect login or password.', // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', // 'error.project_exists' => 'Project with this name already exists.', // 'error.task_exists' => 'Task with this name already exists.', // 'error.client_exists' => 'Client with this name already exists.', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 9dd29a1d..c9893fa3 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -97,6 +97,7 @@ $i18n_key_words = array( 'error.auth' => 'Nume de utilizator sau parola incorecta.', // TODO: translate the following. // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Proiectul cu acest nume exista deja.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 84a7e4c0..e84243af 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -79,6 +79,7 @@ $i18n_key_words = array( 'error.record' => 'Выберите запись.', 'error.auth' => 'Неправильно введен логин или пароль.', 'error.user_exists' => 'Пользователь с таким логином уже существует.', +'error.object_exists' => 'Объект с таким именем уже есть.', 'error.project_exists' => 'Проект с таким именем уже есть.', 'error.task_exists' => 'Задача с таким названием уже есть.', 'error.client_exists' => 'Клиент с таким именем уже есть.', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 90b8b0a5..f1a6d411 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -85,6 +85,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Nesprávne prihlasovacie meno alebo heslo.', 'error.user_exists' => 'Používateľ s týmto prihlasovacím menom už existuje.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Projekt s týmto názvom už existuje.', 'error.task_exists' => 'Úloha s týmto názvom už existuje.', 'error.client_exists' => 'Klient s týmto menom už existuje.', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 72228894..689fccac 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -90,6 +90,7 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', // 'error.auth' => 'Incorrect login or password.', // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', // 'error.project_exists' => 'Project with this name already exists.', // 'error.task_exists' => 'Task with this name already exists.', // 'error.client_exists' => 'Client with this name already exists.', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 5137ef34..bf1e6052 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -80,6 +80,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Pogrešno korisničko ime ili lozinka.', 'error.user_exists' => 'Korisnik pod ovim imenom već postoji.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Projekat pod ovim nazivom već postoji.', 'error.task_exists' => 'Zadatak pod ovim nazivom već postoji.', 'error.client_exists' => 'Klijent pod ovim imenom već postoji.', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index ba55c2c2..f75436dc 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -81,6 +81,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => 'Ogiltigt användarnamn eller lösenord.', 'error.user_exists' => 'Det finns redan en användare med det här användarnamnet.', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Det finns redan ett projekt med det här namnet.', 'error.task_exists' => 'Det finns redan en arbetsuppgift med det här namnet.', 'error.client_exists' => 'Det finns redan en kund med det här namnet.', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 8a9f1970..54b4d83c 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -99,6 +99,7 @@ $i18n_key_words = array( 'error.auth' => 'Hatalı kullanıcı adı veya parola.', // TODO: translate the following. // 'error.user_exists' => 'User with this login already exists.', +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => 'Bu isimde proje zaten vardır.', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index ae04c02f..a1700c9e 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -83,6 +83,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => '不正确的用户名或密码。', 'error.user_exists' => '该用户登录信息已经存在。', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => '该项目名称已经存在。', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 84240080..f0675a6c 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -89,6 +89,8 @@ $i18n_key_words = array( // 'error.record' => 'Select record.', 'error.auth' => '不正確的用戶名或密碼。', 'error.user_exists' => '該使用者登錄資訊已經存在。', +// TODO: translate the following. +// 'error.object_exists' => 'Object with this name already exists.', 'error.project_exists' => '該專案名稱已經存在。', // TODO: translate the following. // 'error.task_exists' => 'Task with this name already exists.', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f377346e..6c2702ee 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.32.4026 | Copyright © Anuko | +  Anuko Time Tracker 1.17.32.4027 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/role_edit.tpl b/WEB-INF/templates/role_edit.tpl new file mode 100644 index 00000000..7a20d6a8 --- /dev/null +++ b/WEB-INF/templates/role_edit.tpl @@ -0,0 +1,33 @@ +{$forms.roleForm.open} + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
{$i18n.label.thing_name} (*):{$forms.roleForm.name.control}
{$i18n.label.description}:{$forms.roleForm.description.control}
{$i18n.label.status}:{$forms.roleForm.status.control}
{$i18n.label.required_fields}
 
{$forms.roleForm.btn_save.control}
+
+{$forms.roleForm.close} diff --git a/role_edit.php b/role_edit.php new file mode 100644 index 00000000..94d47e60 --- /dev/null +++ b/role_edit.php @@ -0,0 +1,88 @@ +getParameter('id'); + +if ($request->isPost()) { + $cl_name = trim($request->getParameter('name')); + $cl_description = trim($request->getParameter('description')); + $cl_status = $request->getParameter('status'); +} else { + $role = ttRoleHelper::get($cl_role_id); + $cl_name = $role['name']; + $cl_description = $role['description']; + $cl_status = $role['status']; +} + +$form = new Form('roleForm'); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_role_id)); +$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','style'=>'width: 250px;','value'=>$cl_name)); +$form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); +$form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status, + 'data'=>array(ACTIVE=>$i18n->getKey('dropdown.status_active'),INACTIVE=>$i18n->getKey('dropdown.status_inactive')))); +$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save'))); + +if ($request->isPost()) { + // Validate user input. + if (!ttValidString($cl_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name')); + if (!ttValidString($cl_description, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.description')); + + if ($err->no()) { + $existing_role = ttRoleHelper::getRoleByName($cl_name); + if (!$existing_role || ($cl_role_id == $existing_role['id'])) { + // Update role information. + if (ttRoleHelper::update(array( + 'id' => $cl_role_id, + 'name' => $cl_name, + 'description' => $cl_description, + 'status' => $cl_status))) { + header('Location: roles.php'); + exit(); + } else + $err->add($i18n->getKey('error.db')); + } else + $err->add($i18n->getKey('error.object_exists')); + } +} // isPost + +$smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('title', $i18n->getKey('title.edit_role')); +$smarty->assign('content_page_name', 'role_edit.tpl'); +$smarty->display('index.tpl'); -- 2.20.1