From: Nik Okuntseff Date: Sat, 7 Apr 2018 15:46:03 +0000 (+0000) Subject: Moved enablePlugin to ttUser class. X-Git-Tag: timetracker_1.19-1~860 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2e2c4428476aebac3f30d481980d0c7f9614c5c0;p=timetracker.git Moved enablePlugin to ttUser class. --- diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index b22e8b5f..3bb71656 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -1033,31 +1033,4 @@ class ttTeamHelper { return true; } - - // enablePlugin either enables or disables a specific plugin for team. - static function enablePlugin($plugin, $enable = true) - { - global $user; - if (!$user->can('manage_features')) - return false; - - $plugin_array = explode(',', $user->plugins); - if ($enable && !in_array($plugin, $plugin_array)) - $plugin_array[] = $plugin; // Add plugin to array. - - if (!$enable && in_array($plugin, $plugin_array)) { - $key = array_search($plugin, $plugin_array); - if ($key !== false) - unset($plugin_array[$key]); // Remove plugin from array. - } - - $plugins = implode(',', $plugin_array); - if ($plugins != $user->plugins) { - if (!$user->updateGroup(array('plugins' => $plugins))) - return false; - $user->plugins = $plugins; - } - - return true; - } } diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index ae197c69..cbfd62d1 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -416,6 +416,9 @@ class ttUser { // updateGroup updates group information with new data. function updateGroup($fields) { + if (!($this->can('manage_basic_settings') || + $this->can('manage_advanced_settings') || + $this->can('manage_features'))) return false; $mdb2 = getConnection(); @@ -450,4 +453,32 @@ class ttUser { return true; } + + // enablePlugin either enables or disables a specific plugin for group. + function enablePlugin($plugin, $enable = true) + { + if (!$this->can('manage_advanced_settings')) + return false; // Note: enablePlugin is currently only used on week_view.php. + // So, it's not really a plugin we are enabling, but rather week view display options. + // Therefore, a check for manage_advanced_settings, not manage_features. + + $plugin_array = explode(',', $this->plugins); + if ($enable && !in_array($plugin, $plugin_array)) + $plugin_array[] = $plugin; // Add plugin to array. + + if (!$enable && in_array($plugin, $plugin_array)) { + $key = array_search($plugin, $plugin_array); + if ($key !== false) + unset($plugin_array[$key]); // Remove plugin from array. + } + + $plugins = implode(',', $plugin_array); + if ($plugins != $this->plugins) { + if (!$this->updateGroup(array('plugins' => $plugins))) + return false; + $this->plugins = $plugins; + } + + return true; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index ac4aadba..1ce30a99 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.87.4241 | Copyright © Anuko | +  Anuko Time Tracker 1.17.87.4242 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/week_view.php b/week_view.php index e5ec1479..38b753a1 100644 --- a/week_view.php +++ b/week_view.php @@ -59,9 +59,9 @@ $form->addInput(array('type'=>'checkbox','name'=>'notes','value'=>$cl_notes)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); if ($request->isPost()){ - if (!ttTeamHelper::enablePlugin('wvn', $cl_week_note) || - !ttTeamHelper::enablePlugin('wvl', $cl_week_list) || - !ttTeamHelper::enablePlugin('wvns', $cl_notes)) { + if (!$user->enablePlugin('wvn', $cl_week_note) || + !$user->enablePlugin('wvl', $cl_week_list) || + !$user->enablePlugin('wvns', $cl_notes)) { $err->add($i18n->get('error.db')); } }