header('Location: access_denied.php');
exit();
}
+if ($request->isPost() && $request->getParameter('group_changed') && !$user->isGroupValid($request->getParameter('group'))) {
+ header('Location: access_denied.php'); // Wrong group id in post.
+ exit();
+}
// End of access checks.
-$config = new ttConfigHelper($user->config);
-
+// TODO: re-structure the file, perhaps by separating post and get processing into whole different sections.
+if ($request->isPost() && $request->getParameter('group_changed')) {
+ $group_id = $request->getParameter('group');
+ $user->setOnBehalfGroup($group_id);
+} else {
+ $group_id = $user->getGroup();
+}
if ($request->isPost()) {
// Plugin checkboxes.
$cl_work_units = $request->getParameter('work_units');
} else {
// Which plugins do we have enabled?
- $plugins = explode(',', $user->plugins);
+ $plugins = explode(',', $user->getPlugins());
$cl_charts = in_array('ch', $plugins);
$cl_clients = in_array('cl', $plugins);
$cl_client_required = in_array('cm', $plugins);
$form = new Form('pluginsForm');
+if ($user->can('manage_subgroups')) {
+ $groups = $user->getGroupsForDropdown();
+ if (count($groups) > 1) {
+ $form->addInput(array('type'=>'combobox',
+ 'onchange'=>'document.pluginsForm.group_changed.value=1;document.pluginsForm.submit();',
+ 'name'=>'group',
+ 'style'=>'width: 250px;',
+ 'value'=>$group_id,
+ 'data'=>$groups,
+ 'datakeys'=>array('id','name')));
+ $form->addInput(array('type'=>'hidden','name'=>'group_changed'));
+ $smarty->assign('group_dropdown', 1);
+ }
+}
+
// Plugin checkboxes.
$form->addInput(array('type'=>'checkbox','name'=>'charts','value'=>$cl_charts));
$form->addInput(array('type'=>'checkbox','name'=>'clients','value'=>$cl_clients,'onchange'=>'handlePluginCheckboxes()'));
$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
+$form->setValueByElement('group_changed','');
+
if ($request->isPost()) {
+ if ($request->getParameter('group_changed')) {
+ // User changed the group in dropdown.
+ // Redirect to self.
+ header('Location: plugins.php');
+ exit();
+ }
// Validate user input. Do we have to?
$plugins .= ',wu';
// Recycle week view plugin options as they are not configured on this page.
- $existing_plugins = explode(',', $user->plugins);
+ $existing_plugins = explode(',', $user->getPlugins());
if (in_array('wvn', $existing_plugins))
$plugins .= ',wvn';
if (in_array('wvl', $existing_plugins))
if ($user->updateGroup(array(
'plugins' => $plugins))) {
- header('Location: time.php');
+ header('Location: success.php');
exit();
} else
$err->add($i18n->get('error.db'));