]> wagnertech.de Git - timetracker.git/commitdiff
More work in progress on roles. Implemented status edit for roles.
authorNik Okuntseff <support@anuko.com>
Sat, 24 Feb 2018 21:52:18 +0000 (21:52 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 24 Feb 2018 21:52:18 +0000 (21:52 +0000)
34 files changed:
WEB-INF/lib/ttRoleHelper.class.php
WEB-INF/lib/ttTaskHelper.class.php
WEB-INF/resources/ca.lang.php
WEB-INF/resources/cs.lang.php
WEB-INF/resources/da.lang.php
WEB-INF/resources/de.lang.php
WEB-INF/resources/en.lang.php
WEB-INF/resources/es.lang.php
WEB-INF/resources/et.lang.php
WEB-INF/resources/fa.lang.php
WEB-INF/resources/fi.lang.php
WEB-INF/resources/fr.lang.php
WEB-INF/resources/he.lang.php
WEB-INF/resources/hu.lang.php
WEB-INF/resources/it.lang.php
WEB-INF/resources/ja.lang.php
WEB-INF/resources/ko.lang.php
WEB-INF/resources/nl.lang.php
WEB-INF/resources/no.lang.php
WEB-INF/resources/pl.lang.php
WEB-INF/resources/pt-br.lang.php
WEB-INF/resources/pt.lang.php
WEB-INF/resources/ro.lang.php
WEB-INF/resources/ru.lang.php
WEB-INF/resources/sk.lang.php
WEB-INF/resources/sl.lang.php
WEB-INF/resources/sr.lang.php
WEB-INF/resources/sv.lang.php
WEB-INF/resources/tr.lang.php
WEB-INF/resources/zh-cn.lang.php
WEB-INF/resources/zh-tw.lang.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/role_edit.tpl [new file with mode: 0644]
role_edit.php [new file with mode: 0644]

index 08e1a21858e5028bc5d149197b4a6c51ab5213d6..957bcdaf8305025911b9ec78f65ca93a9cc9063a 100644 (file)
@@ -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;
index d238bfbc882b0809ee5346793d2c3d3e519e7047..2bb99da424374a896a0078b21cbee4fb5913ac4f 100644 (file)
@@ -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;
index 3ea8edcf04fbdf3f7b58c07396ad902e86733086..4fe1148dbf9f43099878b6989159ee1e13cd680f 100644 (file)
@@ -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.',
index e7e7318b12c1ebd50d4e96531b2edab1a7fc65f5..5a04757b5e5700a301b872dd7c927c4d136b6d11 100644 (file)
@@ -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.',
index 177b2d145976a31a73b0bba25fa7ec48063436b6..b5ec4b2219b11c96e2aae3d50aa35507b49a65c6 100644 (file)
@@ -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.',
index ea9460e61eaff337c74dc5064cc207741988104f..3cd956807af1e1c854266585e9aca1fc334af205 100644 (file)
@@ -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.',
index 6ddf977b3c37a44586a7b973383845d7f4ba5c13..408c0392ff4291fde5239195b4fffc4a24842a3a 100644 (file)
@@ -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.',
index 069527db58eacfc49e9aafa003c2667799b9955c..7e618924dad81630f0627c24536b38f3fc7f80ce 100644 (file)
@@ -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.',
index 01aefb2233f1a39d0541946e009263d7d1eeb8de..b572ae9541212448cab1f772620e82be92e744b2 100644 (file)
@@ -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.',
index 8b023751454b299699185a14208e6ba0c427de10..020b403bbb5f270f80f3cec666a803c35af75ea6 100644 (file)
@@ -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' => 'مشتری با این نام هم اکنون وجود دارد.',
index 68e953aaf73a56d2c867a8a5a2c3f9e69926bfc7..c608cb870be4e536ffa5c9e5473a16a18d36494e 100644 (file)
@@ -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.',
index e22f856d7b25c5dacb3d4aadd90518be643129a5..76457f330e28b094b7ff2118c10e3c16fddbfb20 100644 (file)
@@ -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à.',
index 1c7d48de68a9e08f94b6787f4be26fa8b4f3c5ce..9a3a14a9b09b22c02692d80e11b24bf9deb9b598 100644 (file)
@@ -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' => 'שם לקוח כבר קיים',
index 9704884a6319c1f3b4aa86553c7aab4e7ff8e0f1..88db66883cb3baf233c35e11371155a4baf381d7 100644 (file)
@@ -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.',
index 141a6f83266717dafc9593c5ac856d109354aea6..37407a9084b1c026d541270bd42ccea9b2f7add5 100644 (file)
@@ -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.',
index 42c2f109f6bf30698a338c2f4b1272e862cb6d5a..0c857f9d5580778d2008b7b1f41bfd1956c3a5c4 100644 (file)
@@ -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.',
index 005fb34db66fd23f49e6d6e6181c0cb9e6ba8d54..115cfe01a5e0608243a95dc65d0c9fca581c2374 100644 (file)
@@ -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.',
index 36ab344e75996d66b124fe21ae64b1367af19ab2..9cc82c8f81d8bc941c48eb225b6649fee80af03e 100644 (file)
@@ -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.',
index c7573bea371194a5a6b49c18ab65517ab107ef99..a369452f968d00daefbc1dbf9933685a5e1b82e0 100644 (file)
@@ -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.',
index a91a7544913f2bc604d168ecd2cf5302eb6b8b01..27466aa3855eca9e71c49a66b6c46817db0c118e 100644 (file)
@@ -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.',
index aecc222697514b5c53a5231994fae7454f0251b9..f6e7448009584c1bb043671fe3f4f5060b43eab0 100644 (file)
@@ -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.',
index 6aeed5ed3c51a760faf52ff6e4834da07e7854eb..2a4f3a1d4ef01eb4968091057117b02ec2f87496 100644 (file)
@@ -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.',
index 9dd29a1dc31b1f650a85d43dd2dd7a3fbb25bfd1..c9893fa3cd54d20b545d156739a2109e84fe910a 100644 (file)
@@ -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.',
index 84a7e4c027807fd6af42e42e3996b550c9f798d8..e84243af2f626b23f32270f47bef5ad99bdf9264 100644 (file)
@@ -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' => 'Клиент с таким именем уже есть.',
index 90b8b0a5e951c6767d3bb76b73e7028302aeb17a..f1a6d4111e5b8dd8361c7ad4438e800b85c6d025 100644 (file)
@@ -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.',
index 72228894e4975a9790775c7aa09b45fc7c9ddfca..689fccacd976e8fafb9068c5adad19ae596a6d77 100644 (file)
@@ -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.',
index 5137ef348a2ecc7b95310982fc5b34e32461286b..bf1e6052a902d9b0b0a2a4aa154bd8fa8a8ac798 100644 (file)
@@ -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.',
index ba55c2c2d4cc444e59f727e2c98dd9b471fa9463..f75436dcc54324849ce0440e94849c4ca8749e07 100644 (file)
@@ -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.',
index 8a9f19704de604759e3652d3c2028236ac1e2cbe..54b4d83ce41c2f110b0a99fa9b503834e5e82f25 100644 (file)
@@ -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.',
index ae04c02ff89c158fb7637218e66880f0393e5ee9..a1700c9e83e365504fd19ce50a07b4dce71d8ec1 100644 (file)
@@ -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.',
index 8424008024f3f9760982d4bbc6d337fdf7c04a2e..f0675a6cd3099058dd57a04da3898d71d265f093 100644 (file)
@@ -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.',
index f377346e6fd201cd147cb816072908ee9a61ae71..6c2702eece5f79d3775a414aad863bb7f6b99d4a 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.32.4026 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.32.4027 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
diff --git a/WEB-INF/templates/role_edit.tpl b/WEB-INF/templates/role_edit.tpl
new file mode 100644 (file)
index 0000000..7a20d6a
--- /dev/null
@@ -0,0 +1,33 @@
+{$forms.roleForm.open}
+<table cellspacing="4" cellpadding="7" border="0">
+  <tr>
+    <td>
+      <table cellspacing="1" cellpadding="2" border="0">
+        <tr>
+          <td align="right">{$i18n.label.thing_name} (*):</td>
+          <td>{$forms.roleForm.name.control}</td>
+        </tr>
+        <tr>
+          <td align = "right">{$i18n.label.description}:</td>
+          <td>{$forms.roleForm.description.control}</td>
+        </tr>
+        <tr>
+          <td align = "right">{$i18n.label.status}:</td>
+          <td>{$forms.roleForm.status.control}</td>
+        </tr>
+        <tr>
+          <td></td>
+          <td>{$i18n.label.required_fields}</td>
+        </tr>
+        <tr>
+          <td></td>
+          <td>&nbsp;</td>
+        </tr>
+        <tr>
+          <td colspan="2" align="center" height="50">{$forms.roleForm.btn_save.control}</td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+</table>
+{$forms.roleForm.close}
diff --git a/role_edit.php b/role_edit.php
new file mode 100644 (file)
index 0000000..94d47e6
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttTeamHelper'); // TODO: remove this?
+import('ttTaskHelper'); // TODO: remove this?
+import('ttRoleHelper');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$cl_role_id = (int)$request->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');