$el = new Combobox($params["name"]);
$el->setData(@$params["data"]);
$el->setDataDefault(@$params["empty"]);
+ if (isset($params["multiple"])) {
+ $el->setMultiple($params["multiple"]);
+ $el->name .= '[]'; // Add brackets to the end of name to get back an array on POST.
+ }
if (isset($params["datakeys"])) $el->setDataKeys($params["datakeys"]);
break;
}
// update function updates a role in the database.
- static function update($fields)
- {
+ 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";
+ if (isset($fields['name'])) $name_part = 'name = '.$mdb2->quote($fields['name']);
+ if (isset($fields['description'])) $descr_part = ', description = '.$mdb2->quote($fields['description']);
+ if (isset($fields['status'])) $status_part = ', status = '.(int)$fields['status'];
+ if (isset($fields['rights'])) $rights_part = ', rights = '.$mdb2->quote($fields['rights']);
+ $parts = trim($name_part.$descr_part.$status_part.$rights_part, ',');
+ $sql = "update tt_roles set $parts where id = $id and team_id = $user->team_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
'button.cancel' => 'Cancel·lar',
'button.submit' => 'Enviar',
'button.add' => 'Agregar',
+'button.delete' => 'Eliminar',
'button.generate' => 'Generar',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Zrušit',
'button.submit' => 'Uložit',
'button.add' => 'Přidat',
+'button.delete' => 'Smazat',
'button.generate' => 'Vytvořit',
'button.reset_password' => 'Resetovat heslo',
'button.send' => 'Poslat',
'button.cancel' => 'Fortryd',
'button.submit' => 'Gem',
'button.add' => 'Tilføj',
+'button.delete' => 'Slet',
'button.generate' => 'Generer',
'button.reset_password' => 'Nulstil adgangskode',
'button.send' => 'Send',
'button.cancel' => 'Abbrechen',
'button.submit' => 'Abschicken',
'button.add' => 'Hinzufügen',
+'button.delete' => 'Löschen',
'button.generate' => 'Erstellen',
'button.reset_password' => 'Passwort zurücksetzen',
'button.send' => 'Senden',
'button.cancel' => 'Cancel',
'button.submit' => 'Submit',
'button.add' => 'Add',
+'button.delete' => 'Delete',
'button.generate' => 'Generate',
'button.reset_password' => 'Reset password',
'button.send' => 'Send',
'form.roles.active_roles' => 'Active Roles',
'form.roles.inactive_roles' => 'Inactive Roles',
'form.roles.rights' => 'Rights',
+'form.roles.assigned' => 'Assigned',
+'form.roles.not_assigned' => 'Not assigned',
// Clients form. See example at https://timetracker.anuko.com/clients.php
'form.clients.active_clients' => 'Active Clients',
'button.cancel' => 'Cancelar',
'button.submit' => 'Enviar',
'button.add' => 'Agregar',
+'button.delete' => 'Eliminar',
'button.generate' => 'Generar',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Tühista',
'button.submit' => 'Postita',
'button.add' => 'Lisa',
+'button.delete' => 'Kustuta',
'button.generate' => 'Loo',
'button.reset_password' => 'Tühjenda salasõna',
'button.send' => 'Saada',
'button.cancel' => 'لغو',
'button.submit' => 'ثبت',
'button.add' => 'درج',
+'button.delete' => 'حذف',
'button.generate' => 'تولید',
'button.reset_password' => 'بازسازی رمزعبور',
'button.send' => 'ارسال',
'button.cancel' => 'Keskeytä',
'button.submit' => 'Hyväksy',
'button.add' => 'Lisää',
+'button.delete' => 'Poista',
'button.generate' => 'Luo',
'button.reset_password' => 'Nollaa salasana',
'button.send' => 'Lähetä',
'button.cancel' => 'Annuler',
'button.submit' => 'Soumettre',
'button.add' => 'Ajouter',
+'button.delete' => 'Supprimer',
'button.generate' => 'Générer',
'button.reset_password' => 'Réinitialiser',
'button.send' => 'Envoyer',
'button.cancel' => 'ביטול',
'button.submit' => 'שלח',
'button.add' => 'הוסף',
+'button.delete' => 'מחק',
'button.generate' => 'הרץ',
'button.reset_password' => 'איפוס סיסמה',
'button.send' => 'שלח',
'button.cancel' => 'Vissza',
'button.submit' => 'Mentés',
'button.add' => 'Hozzáadás',
+'button.delete' => 'Törlés',
'button.generate' => 'Generálás',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Cancella',
'button.submit' => 'Invia',
'button.add' => 'Aggiungi',
+'button.delete' => 'Elimina',
'button.generate' => 'Genera',
'button.reset_password' => 'Reset password',
'button.send' => 'Invia',
'button.cancel' => 'キャンセル',
'button.submit' => '送信',
'button.add' => '追加',
+'button.delete' => '削除',
'button.generate' => '生成',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => '취소',
'button.submit' => '발송',
'button.add' => '추가',
+'button.delete' => '삭제',
'button.generate' => '생성',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Afbreken',
'button.submit' => 'Bewaren',
'button.add' => 'Toevoegen',
+'button.delete' => 'Verwijderen',
'button.generate' => 'Genereren',
'button.reset_password' => 'Herstel het wachtwoord',
'button.send' => 'Verzenden',
// TODO: translate the following.
// 'button.submit' => 'Submit',
'button.add' => 'Legg til',
+'button.delete' => 'Slett',
'button.generate' => 'Generer',
'button.reset_password' => 'Resett passord',
'button.send' => 'Send',
'button.cancel' => 'Anuluj',
'button.submit' => 'Zatwierdź',
'button.add' => 'Dodaj',
+'button.delete' => 'Usuń',
'button.generate' => 'Wygeneruj',
'button.reset_password' => 'Resetuj hasło',
'button.send' => 'Wyślij',
'button.cancel' => 'Cancelar',
'button.submit' => 'Enviar',
'button.add' => 'Adicionar',
+'button.delete' => 'Apagar',
'button.generate' => 'Criar',
'button.reset_password' => 'Resetar senha',
'button.send' => 'Enviar',
'button.cancel' => 'Cancelar',
'button.submit' => 'Submeter',
'button.add' => 'Adicionar',
+'button.delete' => 'Apagar',
// TODO: translate the following.
// 'button.generate' => 'Generate',
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Renunta',
'button.submit' => 'Trimite',
'button.add' => 'Adauga',
+'button.delete' => 'Șterge',
'button.generate' => 'Genereaza',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Отменить',
'button.submit' => 'Подтвердить',
'button.add' => 'Добавить',
+'button.delete' => 'Удалить',
'button.generate' => 'Сгенерировать',
'button.reset_password' => 'Сбросить пароль',
'button.send' => 'Отправить',
'button.cancel' => 'Zrušiť',
'button.submit' => 'Odoslať',
'button.add' => 'Pridať',
+'button.delete' => 'Vymazať',
'button.generate' => 'Generovať',
'button.reset_password' => 'Obnoviť heslo',
'button.send' => 'Odoslať',
'button.cancel' => 'Prekliči',
'button.submit' => 'Potrdi',
'button.add' => 'Dodaj',
+'button.delete' => 'Izbriši',
'button.generate' => 'Ustvari',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => 'Otkaži',
'button.submit' => 'Pošalji',
'button.add' => 'Dodaj',
+'button.delete' => 'Obriši',
'button.generate' => 'Napravi',
'button.reset_password' => 'Resetuj lozinku',
'button.send' => 'Pošalji',
'button.cancel' => 'Avbryt',
'button.submit' => 'Skicka',
'button.add' => 'Lägg till',
+'button.delete' => 'Ta bort',
'button.generate' => 'Generera',
'button.reset_password' => 'Återställ lösenord',
'button.send' => 'Skicka',
'button.cancel' => 'Iptal',
'button.submit' => 'Gönder',
'button.add' => 'Ekle',
+'button.delete' => 'Sil',
'button.generate' => 'Yarat',
// TODO: translate the following.
// 'button.reset_password' => 'Reset password',
'button.cancel' => '取消',
'button.submit' => '提交',
'button.add' => '添加',
+'button.delete' => '删除',
'button.generate' => '创建',
'button.reset_password' => '重置密码',
'button.send' => '发送',
'button.cancel' => '取消',
'button.submit' => '提交',
'button.add' => '添加',
+'button.delete' => '刪除',
'button.generate' => '創建',
'button.reset_password' => '重設密碼',
'button.send' => '發送',
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <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> |
+ <td align="center"> Anuko Time Tracker 1.17.32.4028 | 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>
<td></td>
<td>{$i18n.label.required_fields}</td>
</tr>
+ <tr>
+ <td colspan="2" align="center" height="50">{$forms.roleForm.btn_save.control}</td>
+ </tr>
<tr>
<td></td>
<td> </td>
</tr>
<tr>
- <td colspan="2" align="center" height="50">{$forms.roleForm.btn_save.control}</td>
+ <td align = "right">{$i18n.form.roles.assigned}:</td>
+ <td>{$forms.roleForm.assigned_rights.control}</td><td>{$forms.roleForm.btn_delete.control}</td>
+ </tr>
+ <tr>
+ <td align = "right">{$i18n.form.roles.not_assigned}:</td>
+ <td>{$forms.roleForm.available_rights.control}</td><td>{$forms.roleForm.btn_add.control}</td>
</tr>
</table>
</td>
header('Location: access_denied.php');
exit();
}
-
$cl_role_id = (int)$request->getParameter('id');
+$role = ttRoleHelper::get($cl_role_id);
+if (!$role) {
+ header('Location: access_denied.php');
+ exit();
+}
+$assigned_rights = explode(',', $role['rights']);
+$available_rights = array_diff($user->rights_array, $assigned_rights);
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->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));
+
+// Multiple select controls for assigned and available rights.
+$form->addInput(array('type'=>'combobox','name'=>'assigned_rights','style'=>'width: 250px;','multiple'=>true,'data'=>$assigned_rights));
+$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('button.delete')));
+$form->addInput(array('type'=>'combobox','name'=>'available_rights','style'=>'width: 250px;','multiple'=>true,'data'=>$available_rights));
+$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
+
+
$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 ($request->getParameter('btn_save')) {
+ // 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();
+ 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.db'));
- } else
- $err->add($i18n->getKey('error.object_exists'));
+ $err->add($i18n->getKey('error.object_exists'));
+ }
+ }
+ if ($request->getParameter('btn_delete') && $request->getParameter('assigned_rights')) {
+ $rights = $role['rights'];
+ $to_delete = $request->getParameter('assigned_rights');
+ foreach($to_delete as $index) {
+ $right_to_delete = $assigned_rights[$index];
+ $rights = str_replace($right_to_delete, '', $rights);
+ $rights = str_replace(',,',',', $rights);
+ }
+ $rights = trim($rights, ',');
+ if (ttRoleHelper::update(array('id' => $cl_role_id,'rights'=> $rights))) {
+ header('Location: role_edit.php?id='.$role['id']);
+ exit();
+ } else
+ $err->add($i18n->getKey('error.db'));
+ }
+ if ($request->getParameter('btn_add') && $request->getParameter('available_rights')) {
+ $rights = $role['rights'];
+ $to_add = $request->getParameter('available_rights');
+ foreach($to_add as $index) {
+ $right_to_add = $available_rights[$index];
+ // Just in case remove it.
+ $rights = str_replace($right_to_add, '', $rights);
+ $rights = str_replace(',,',',', $rights);
+ // Add the right only if we have it ourselves.
+ if (in_array($right_to_add, $user->rights_array))
+ $rights .= ','.$right_to_add;
+ }
+ $rights = trim($rights, ',');
+ if (ttRoleHelper::update(array('id' => $cl_role_id,'rights'=> $rights))) {
+ header('Location: role_edit.php?id='.$role['id']);
+ exit();
+ } else
+ $err->add($i18n->getKey('error.db'));
}
} // isPost