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;
$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;
}
return $last_id;
}
- // update function updates a task in database.
+ // update function updates a task in the database.
static function update($fields)
{
global $user;
'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.',
'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.',
// '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.',
// '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.',
'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.',
'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.',
'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.',
// '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' => 'مشتری با این نام هم اکنون وجود دارد.',
// '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.',
// '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à.',
// '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' => 'שם לקוח כבר קיים',
// '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.',
'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.',
// '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.',
// '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.',
'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.',
// '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.',
// '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.',
// '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.',
// '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.',
'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.',
'error.record' => 'Выберите запись.',
'error.auth' => 'Неправильно введен логин или пароль.',
'error.user_exists' => 'Пользователь с таким логином уже существует.',
+'error.object_exists' => 'Объект с таким именем уже есть.',
'error.project_exists' => 'Проект с таким именем уже есть.',
'error.task_exists' => 'Задача с таким названием уже есть.',
'error.client_exists' => 'Клиент с таким именем уже есть.',
// '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.',
// '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.',
// '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.',
// '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.',
'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.',
// '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.',
// '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.',
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.32.4026 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.32.4027 | Copyright © <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>
--- /dev/null
+{$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> </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center" height="50">{$forms.roleForm.btn_save.control}</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+{$forms.roleForm.close}
--- /dev/null
+<?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');