From: Nik Okuntseff Date: Tue, 27 Nov 2018 00:32:34 +0000 (+0000) Subject: Adjusted plugins.php page to support subgroups. X-Git-Tag: timetracker_1.19-1~539 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=dc825d15a8f66df15a52af1275fbaad594e93aa1;p=timetracker.git Adjusted plugins.php page to support subgroups. --- diff --git a/WEB-INF/lib/ttGroup.class.php b/WEB-INF/lib/ttGroup.class.php index 26f2ee6c..1d33fe11 100644 --- a/WEB-INF/lib/ttGroup.class.php +++ b/WEB-INF/lib/ttGroup.class.php @@ -94,12 +94,15 @@ class ttGroup { $this->password_complexity = $val['password_complexity']; $this->group_name = $val['group_name']; $this->currency = $val['currency']; + */ $this->plugins = $val['plugins']; + /* $this->lock_spec = $val['lock_spec']; $this->workday_minutes = $val['workday_minutes']; $this->custom_logo = $val['custom_logo']; - + */ $this->config = $val['config']; + /* $config = new ttConfigHelper($this->config); // Set user config options. $this->show_holidays = $config->getDefinedValue('show_holidays'); diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 2da8f981..bece653d 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -181,6 +181,16 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->tracking_mode : $this->tracking_mode); } + // getPlugins returns plugins string for active group. + function getPlugins() { + return ($this->behalfGroup ? $this->behalfGroup->plugins : $this->plugins); + } + + // getConfig returns config string for active group. + function getConfig() { + return ($this->behalfGroup ? $this->behalfGroup->config : $this->config); + } + // The getActiveUser returns user id on behalf of whom the current user is operating. function getActiveUser() { return ($this->behalf_id ? $this->behalf_id : $this->id); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index dba4a8b6..fa239232 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4526 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4527 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/plugins.tpl b/WEB-INF/templates/plugins.tpl index f72d5699..d31bb841 100644 --- a/WEB-INF/templates/plugins.tpl +++ b/WEB-INF/templates/plugins.tpl @@ -89,6 +89,13 @@ function handlePluginCheckboxes() {
+{if $group_dropdown} + + + + +
{$i18n.label.group}: {$forms.pluginsForm.group.control}
+{/if} diff --git a/plugins.php b/plugins.php index 60b86fed..5c830149 100644 --- a/plugins.php +++ b/plugins.php @@ -34,10 +34,19 @@ if (!ttAccessAllowed('manage_features')) { 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. @@ -56,7 +65,7 @@ if ($request->isPost()) { $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); @@ -74,6 +83,21 @@ if ($request->isPost()) { $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()')); @@ -91,7 +115,15 @@ $form->addInput(array('type'=>'checkbox','name'=>'work_units','value'=>$cl_work_ $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? @@ -125,7 +157,7 @@ if ($request->isPost()) { $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)) @@ -137,7 +169,7 @@ if ($request->isPost()) { if ($user->updateGroup(array( 'plugins' => $plugins))) { - header('Location: time.php'); + header('Location: success.php'); exit(); } else $err->add($i18n->get('error.db'));
{$forms.pluginsForm.charts.control}