From: Nik Okuntseff Date: Sat, 7 Apr 2018 14:58:23 +0000 (+0000) Subject: Fixed visibility of the Required checkbox on group settings. X-Git-Tag: timetracker_1.19-1~861 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ce2bb98acb1f5e2a846f95b798a4af409c842ebb;p=timetracker.git Fixed visibility of the Required checkbox on group settings. --- diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 6920ab35..b22e8b5f 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -833,53 +833,6 @@ class ttTeamHelper { return false; } - // The update function updates team information. - static function update($group_id, $fields) - { - global $user; - $mdb2 = getConnection(); - $name_part = 'name = '.$mdb2->quote($fields['name']); - $currency_part = ''; - $lang_part = ''; - $decimal_mark_part = ''; - $date_format_part = ''; - $time_format_part = ''; - $week_start_part = ''; - $tracking_mode_part = ''; - $task_required_part = ' , task_required = '.(int) $fields['task_required']; - $record_type_part = ''; - $bcc_email_part = ''; - $allow_ip = ''; - $plugins_part = ''; - $config_part = ''; - $lock_spec_part = ''; - $workday_minutes_part = ''; - - if (isset($fields['currency'])) $currency_part = ', currency = '.$mdb2->quote($fields['currency']); - if (isset($fields['lang'])) $lang_part = ', lang = '.$mdb2->quote($fields['lang']); - if (isset($fields['decimal_mark'])) $decimal_mark_part = ', decimal_mark = '.$mdb2->quote($fields['decimal_mark']); - if (isset($fields['date_format'])) $date_format_part = ', date_format = '.$mdb2->quote($fields['date_format']); - if (isset($fields['time_format'])) $time_format_part = ', time_format = '.$mdb2->quote($fields['time_format']); - if (isset($fields['week_start'])) $week_start_part = ', week_start = '.(int) $fields['week_start']; - if (isset($fields['tracking_mode'])) $tracking_mode_part = ', tracking_mode = '.(int) $fields['tracking_mode']; - if (isset($fields['record_type'])) $record_type_part = ', record_type = '.(int) $fields['record_type']; - if (isset($fields['bcc_email'])) $bcc_email_part = ', bcc_email = '.$mdb2->quote($fields['bcc_email']); - if (isset($fields['allow_ip'])) $allow_ip_part = ', allow_ip = '.$mdb2->quote($fields['allow_ip']); - if (isset($fields['plugins'])) $plugins_part = ', plugins = '.$mdb2->quote($fields['plugins']); - if (isset($fields['config'])) $config_part = ', config = '.$mdb2->quote($fields['config']); - if (isset($fields['lock_spec'])) $lock_spec_part = ', lock_spec = '.$mdb2->quote($fields['lock_spec']); - if (isset($fields['workday_minutes'])) $workday_minutes_part = ', workday_minutes = '.$mdb2->quote($fields['workday_minutes']); - $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); - - $sql = "update tt_groups set $name_part $currency_part $lang_part $decimal_mark_part - $date_format_part $time_format_part $week_start_part $tracking_mode_part $task_required_part $record_type_part - $bcc_email_part $allow_ip_part $plugins_part $config_part $lock_spec_part $workday_minutes_part $modified_part where id = $group_id"; - $affected = $mdb2->exec($sql); - if (is_a($affected, 'PEAR_Error')) return false; - - return true; - } - // The getInactiveTeams is a maintenance function that returns an array of inactive team ids (max 100). static function getInactiveTeams() { $inactive_teams = array(); @@ -1100,7 +1053,7 @@ class ttTeamHelper { $plugins = implode(',', $plugin_array); if ($plugins != $user->plugins) { - if (!ttTeamHelper::update($user->group_id, array('name' => $user->group,'plugins' => $plugins))) + if (!$user->updateGroup(array('plugins' => $plugins))) return false; $user->plugins = $plugins; } diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 2fb7caa1..ae197c69 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -413,4 +413,41 @@ class ttUser { } return false; } + + // updateGroup updates group information with new data. + function updateGroup($fields) { + + $mdb2 = getConnection(); + + if (isset($fields['name'])) $name_part = ', name = '.$mdb2->quote($fields['name']); + if (isset($fields['currency'])) $currency_part = ', currency = '.$mdb2->quote($fields['currency']); + if (isset($fields['lang'])) $lang_part = ', lang = '.$mdb2->quote($fields['lang']); + if (isset($fields['decimal_mark'])) $decimal_mark_part = ', decimal_mark = '.$mdb2->quote($fields['decimal_mark']); + if (isset($fields['date_format'])) $date_format_part = ', date_format = '.$mdb2->quote($fields['date_format']); + if (isset($fields['time_format'])) $time_format_part = ', time_format = '.$mdb2->quote($fields['time_format']); + if (isset($fields['week_start'])) $week_start_part = ', week_start = '.(int) $fields['week_start']; + if (isset($fields['tracking_mode'])) { + $tracking_mode_part = ', tracking_mode = '.(int) $fields['tracking_mode']; + $project_required_part = ' , project_required = '.(int) $fields['project_required']; + $task_required_part = ' , task_required = '.(int) $fields['task_required']; + } + if (isset($fields['record_type'])) $record_type_part = ', record_type = '.(int) $fields['record_type']; + if (isset($fields['bcc_email'])) $bcc_email_part = ', bcc_email = '.$mdb2->quote($fields['bcc_email']); + if (isset($fields['allow_ip'])) $allow_ip_part = ', allow_ip = '.$mdb2->quote($fields['allow_ip']); + if (isset($fields['plugins'])) $plugins_part = ', plugins = '.$mdb2->quote($fields['plugins']); + if (isset($fields['config'])) $config_part = ', config = '.$mdb2->quote($fields['config']); + if (isset($fields['lock_spec'])) $lock_spec_part = ', lock_spec = '.$mdb2->quote($fields['lock_spec']); + if (isset($fields['workday_minutes'])) $workday_minutes_part = ', workday_minutes = '.$mdb2->quote($fields['workday_minutes']); + $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($this->id); + + $parts = trim($name_part.$currency_part.$lang_part.$decimal_mark_part.$date_format_part. + $time_format_part.$week_start_part.$tracking_mode_part.$task_required_part.$project_required_part.$record_type_part. + $bcc_email_part.$allow_ip_part.$plugins_part.$config_part.$lock_spec_part.$workday_minutes_part.$modified_part, ','); + + $sql = "update tt_groups set $parts where id = $this->group_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) return false; + + return true; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 86c58ed2..ac4aadba 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - + diff --git a/group_edit.php b/group_edit.php index 64a15309..cc27afae 100644 --- a/group_edit.php +++ b/group_edit.php @@ -273,7 +273,7 @@ if ($request->isPost()) { $config .= ',uncompleted_indicators'; $config = trim($config, ','); - $update_result = ttTeamHelper::update($user->group_id, array( + $update_result = $user->updateGroup(array( 'name' => $cl_group, 'currency' => $cl_currency, 'lang' => $cl_lang, diff --git a/locking.php b/locking.php index 8aae756d..94996ada 100644 --- a/locking.php +++ b/locking.php @@ -51,9 +51,7 @@ if ($request->isPost()) { if (!ttValidCronSpec($cl_lock_spec)) $err->add($i18n->get('error.field'), $i18n->get('label.schedule')); if ($err->no()) { - if (ttTeamHelper::update($user->group_id, array( - 'name' => $user->group, - 'lock_spec' => $cl_lock_spec))) { + if ($user->updateGroup(array('lock_spec' => $cl_lock_spec))) { header('Location: group_edit.php'); exit(); } else { diff --git a/quotas.php b/quotas.php index a453099e..ac6542f5 100644 --- a/quotas.php +++ b/quotas.php @@ -90,7 +90,7 @@ if ($request->isPost()){ // Handle workday hours. $workday_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours')); if ($workday_minutes != $user->workday_minutes) { - if (!ttTeamHelper::update($user->group_id, array('name'=>$user->group,'workday_minutes'=>$workday_minutes))) + if (!$user->updateGroup(array('workday_minutes'=>$workday_minutes))) $err->add($i18n->get('error.db')); }
 Anuko Time Tracker 1.17.87.4240 | Copyright © Anuko | +  Anuko Time Tracker 1.17.87.4241 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/group_edit.tpl b/WEB-INF/templates/group_edit.tpl index 35e76046..7cb8d2e6 100644 --- a/WEB-INF/templates/group_edit.tpl +++ b/WEB-INF/templates/group_edit.tpl @@ -142,7 +142,7 @@ function handlePluginCheckboxes() {
{$i18n.form.profile.tracking_mode}:{$forms.groupForm.tracking_mode.control} {$forms.profileForm.task_required.control} {$forms.groupForm.tracking_mode.control} {$forms.groupForm.task_required.control}
{$i18n.form.profile.record_type}: