From: Nik Okuntseff Date: Sun, 25 Feb 2018 16:00:14 +0000 (+0000) Subject: Work in progress on role editor. X-Git-Tag: timetracker_1.19-1~1084 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4d07dc7fef357e5139f35df6271cc15dc6bea955;p=timetracker.git Work in progress on role editor. --- diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index 5a4baa9b..19dd0111 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -110,6 +110,10 @@ class Form { $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; diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index 957bcdaf..7e103943 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -69,19 +69,17 @@ class ttRoleHelper { } // 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')); } diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 4fe1148d..5da5aa50 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -119,6 +119,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 5a04757b..411dc555 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -122,6 +122,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index b5ec4b22..6390680e 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -106,6 +106,7 @@ $i18n_key_words = array( 'button.cancel' => 'Fortryd', 'button.submit' => 'Gem', 'button.add' => 'Tilføj', +'button.delete' => 'Slet', 'button.generate' => 'Generer', 'button.reset_password' => 'Nulstil adgangskode', 'button.send' => 'Send', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index 3cd95680..eb2dfdac 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -106,6 +106,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 408c0392..b53e4836 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -105,6 +105,7 @@ $i18n_key_words = array( 'button.cancel' => 'Cancel', 'button.submit' => 'Submit', 'button.add' => 'Add', +'button.delete' => 'Delete', 'button.generate' => 'Generate', 'button.reset_password' => 'Reset password', 'button.send' => 'Send', @@ -396,6 +397,8 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 7e618924..2adf12e5 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -118,6 +118,7 @@ $i18n_key_words = array( 'button.cancel' => 'Cancelar', 'button.submit' => 'Enviar', 'button.add' => 'Agregar', +'button.delete' => 'Eliminar', 'button.generate' => 'Generar', // TODO: translate the following. // 'button.reset_password' => 'Reset password', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index b572ae95..9663f5f2 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -122,6 +122,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 020b403b..d1605891 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -115,6 +115,7 @@ $i18n_key_words = array( 'button.cancel' => 'لغو', 'button.submit' => 'ثبت', 'button.add' => 'درج', +'button.delete' => 'حذف', 'button.generate' => 'تولید', 'button.reset_password' => 'بازسازی رمزعبور', 'button.send' => 'ارسال', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index c608cb87..639154e4 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -108,6 +108,7 @@ $i18n_key_words = array( '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ä', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 76457f33..e2babb37 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -106,6 +106,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 9a3a14a9..a27e41ee 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -124,6 +124,7 @@ $i18n_key_words = array( 'button.cancel' => 'ביטול', 'button.submit' => 'שלח', 'button.add' => 'הוסף', +'button.delete' => 'מחק', 'button.generate' => 'הרץ', 'button.reset_password' => 'איפוס סיסמה', 'button.send' => 'שלח', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 88db6688..a15c6812 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -119,6 +119,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 37407a90..beed939f 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -107,6 +107,7 @@ $i18n_key_words = array( 'button.cancel' => 'Cancella', 'button.submit' => 'Invia', 'button.add' => 'Aggiungi', +'button.delete' => 'Elimina', 'button.generate' => 'Genera', 'button.reset_password' => 'Reset password', 'button.send' => 'Invia', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 0c857f9d..669fe10c 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -121,6 +121,7 @@ $i18n_key_words = array( 'button.cancel' => 'キャンセル', 'button.submit' => '送信', 'button.add' => '追加', +'button.delete' => '削除', 'button.generate' => '生成', // TODO: translate the following. // 'button.reset_password' => 'Reset password', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 115cfe01..28117227 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -121,6 +121,7 @@ $i18n_key_words = array( 'button.cancel' => '취소', 'button.submit' => '발송', 'button.add' => '추가', +'button.delete' => '삭제', 'button.generate' => '생성', // TODO: translate the following. // 'button.reset_password' => 'Reset password', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 9cc82c8f..9e6b63d0 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -105,6 +105,7 @@ $i18n_key_words = array( 'button.cancel' => 'Afbreken', 'button.submit' => 'Bewaren', 'button.add' => 'Toevoegen', +'button.delete' => 'Verwijderen', 'button.generate' => 'Genereren', 'button.reset_password' => 'Herstel het wachtwoord', 'button.send' => 'Verzenden', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index a369452f..04fe3c46 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -122,6 +122,7 @@ $i18n_key_words = array( // 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', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 27466aa3..8889ec2a 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -110,6 +110,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index f6e74480..8b49b7b7 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -107,6 +107,7 @@ $i18n_key_words = array( 'button.cancel' => 'Cancelar', 'button.submit' => 'Enviar', 'button.add' => 'Adicionar', +'button.delete' => 'Apagar', 'button.generate' => 'Criar', 'button.reset_password' => 'Resetar senha', 'button.send' => 'Enviar', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 2a4f3a1d..c8bb53c6 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -117,6 +117,7 @@ $i18n_key_words = array( 'button.cancel' => 'Cancelar', 'button.submit' => 'Submeter', 'button.add' => 'Adicionar', +'button.delete' => 'Apagar', // TODO: translate the following. // 'button.generate' => 'Generate', // 'button.reset_password' => 'Reset password', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index c9893fa3..f1ce0376 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -125,6 +125,7 @@ $i18n_key_words = array( 'button.cancel' => 'Renunta', 'button.submit' => 'Trimite', 'button.add' => 'Adauga', +'button.delete' => 'Șterge', 'button.generate' => 'Genereaza', // TODO: translate the following. // 'button.reset_password' => 'Reset password', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index e84243af..a612f95c 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -104,6 +104,7 @@ $i18n_key_words = array( 'button.cancel' => 'Отменить', 'button.submit' => 'Подтвердить', 'button.add' => 'Добавить', +'button.delete' => 'Удалить', 'button.generate' => 'Сгенерировать', 'button.reset_password' => 'Сбросить пароль', 'button.send' => 'Отправить', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index f1a6d411..25676d2e 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -114,6 +114,7 @@ $i18n_key_words = array( 'button.cancel' => 'Zrušiť', 'button.submit' => 'Odoslať', 'button.add' => 'Pridať', +'button.delete' => 'Vymazať', 'button.generate' => 'Generovať', 'button.reset_password' => 'Obnoviť heslo', 'button.send' => 'Odoslať', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 689fccac..839bdba8 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index bf1e6052..3bfa69c0 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -107,6 +107,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index f75436dc..ae5e2d33 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -107,6 +107,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 54b4d83c..dc15a2e6 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -127,6 +127,7 @@ $i18n_key_words = array( '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', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index a1700c9e..3ab0904a 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -113,6 +113,7 @@ $i18n_key_words = array( 'button.cancel' => '取消', 'button.submit' => '提交', 'button.add' => '添加', +'button.delete' => '删除', 'button.generate' => '创建', 'button.reset_password' => '重置密码', 'button.send' => '发送', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index f0675a6c..b9e73bae 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -119,6 +119,7 @@ $i18n_key_words = array( 'button.cancel' => '取消', 'button.submit' => '提交', 'button.add' => '添加', +'button.delete' => '刪除', 'button.generate' => '創建', 'button.reset_password' => '重設密碼', 'button.send' => '發送', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6c2702ee..e7f9eb4c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- + + + - + + + + + +
 Anuko Time Tracker 1.17.32.4027 | Copyright © Anuko | +  Anuko Time Tracker 1.17.32.4028 | 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 index 7a20d6a8..6ba4ddce 100644 --- a/WEB-INF/templates/role_edit.tpl +++ b/WEB-INF/templates/role_edit.tpl @@ -19,12 +19,20 @@ {$i18n.label.required_fields}
{$forms.roleForm.btn_save.control}
 
{$forms.roleForm.btn_save.control}{$i18n.form.roles.assigned}:{$forms.roleForm.assigned_rights.control}{$forms.roleForm.btn_delete.control}
{$i18n.form.roles.not_assigned}:{$forms.roleForm.available_rights.control}{$forms.roleForm.btn_add.control}
diff --git a/role_edit.php b/role_edit.php index 94d47e60..21ed258d 100644 --- a/role_edit.php +++ b/role_edit.php @@ -37,15 +37,20 @@ if (!ttAccessCheck(right_manage_team)) { 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']; @@ -55,30 +60,74 @@ $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)); + +// 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