+ $err->add($i18n->get('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->get('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))
+ $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->get('error.db'));