X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=group_edit.php;h=08c1db59061d5f46e70fb7fe5f4a86d49850d347;hb=f58ab716cb0cc4b8be8e48723b345bfab29697a6;hp=a98243cbbc92848c773fac095730163c6a6a72d9;hpb=807daaa6d030a1ee01a5fb3822db3a299a84bfc9;p=timetracker.git diff --git a/group_edit.php b/group_edit.php index a98243cb..08c1db59 100644 --- a/group_edit.php +++ b/group_edit.php @@ -44,7 +44,14 @@ if ($group_id && !$user->isGroupValid($group_id)) { } // End of access checks. -if (!$group_id) $group_id = $user->getActiveGroup(); +if ($group_id) { + // We are passed a valid group_id. + // Set on behalf group accordingly. + $user->setOnBehalfGroup($group_id); +} + +if (!$group_id) $group_id = $user->getGroup(); +$groups = $user->getGroupsForDropdown(); $group = ttGroupHelper::getGroupAttrs($group_id); $config = new ttConfigHelper($group['config']); @@ -53,6 +60,7 @@ if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$'); if ($request->isPost()) { $cl_group = trim($request->getParameter('group_name')); + $cl_description = trim($request->getParameter('description')); $cl_currency = trim($request->getParameter('currency')); if (!$cl_currency) $cl_currency = CURRENCY_DEFAULT; $cl_lang = $request->getParameter('lang'); @@ -73,6 +81,7 @@ if ($request->isPost()) { $cl_allow_ip = trim($request->getParameter('allow_ip')); } else { $cl_group = $group['name']; + $cl_description = $group['description']; $cl_currency = ($group['currency'] == ''? CURRENCY_DEFAULT : $group['currency']); $cl_lang = $group['lang']; $cl_decimal_mark = $group['decimal_mark']; @@ -94,7 +103,18 @@ if ($request->isPost()) { $form = new Form('groupForm'); $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id)); +if (count($groups) > 1) { + $form->addInput(array('type'=>'combobox', + 'onchange'=>'document.groupForm.group_changed.value=1;document.groupForm.submit();', + 'name'=>'group', + 'style'=>'width: 250px;', + 'value'=>$group_id, + 'data'=>$groups, + 'datakeys'=>array('id','name'))); + $form->addInput(array('type'=>'hidden','name'=>'group_changed')); +} $form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'group_name','value'=>$cl_group,'enable'=>$advanced_settings)); +$form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); $form->addInput(array('type'=>'text','maxlength'=>'7','name'=>'currency','value'=>$cl_currency)); // Prepare an array of available languages. @@ -179,7 +199,16 @@ if ($advanced_settings) { $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); if ($user->can('delete_group')) $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('button.delete'))); +$form->setValueByElement('group_changed',''); + if ($request->isPost()) { + if ($request->getParameter('group_changed')) { + // User changed the group in dropdown. + $new_group_id = $request->getParameter('group'); + // Redirect to self. + header('Location: group_edit.php?id='.$new_group_id); + exit(); + } if ($request->getParameter('btn_delete')) { // Delete button pressed, redirect. @@ -188,7 +217,8 @@ if ($request->isPost()) { } // Validate user input. - if (!ttValidString($cl_group, true)) $err->add($i18n->get('error.field'), $i18n->get('label.group_name')); + if (!ttValidString($cl_group)) $err->add($i18n->get('error.field'), $i18n->get('label.group_name')); + if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); if (!ttValidString($cl_currency, true)) $err->add($i18n->get('error.field'), $i18n->get('label.currency')); if ($advanced_settings) { if (!ttValidEmail($cl_bcc_email, true)) $err->add($i18n->get('error.field'), $i18n->get('label.bcc')); @@ -207,6 +237,7 @@ if ($request->isPost()) { if ($user->updateGroup(array( 'group_id' => $group_id, 'name' => $cl_group, + 'description' => $cl_description, 'currency' => $cl_currency, 'lang' => $cl_lang, 'decimal_mark' => $cl_decimal_mark, @@ -229,6 +260,8 @@ if ($request->isPost()) { } // isPost $smarty->assign('auth_external', $auth->isPasswordExternal()); +$smarty->assign('group_id', $group_id); +$smarty->assign('group_dropdown', count($groups) > 1); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="handleTaskRequiredCheckbox(); handlePluginCheckboxes();"'); $smarty->assign('title', $i18n->get('title.edit_group'));