A bit of refactoring.
authorNik Okuntseff <support@anuko.com>
Wed, 14 Feb 2018 17:14:06 +0000 (17:14 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 14 Feb 2018 17:14:06 +0000 (17:14 +0000)
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/templates/footer.tpl

index a58c2cd..15bb3d6 100644 (file)
@@ -640,13 +640,13 @@ class ttTeamHelper {
 
     $mdb2 = getConnection();
 
-    $decimal_mark = $fields['decimal_mark'];
-    if ($decimal_mark !== null) {
-      $decimal_mark_f = ', decimal_mark';
-      $decimal_mark_v = ', ' . $mdb2->quote($decimal_mark);
-    } else {
-      $decimal_mark_f = '';
-      $decimal_mark_v = '';
+    // Start with team name and currency.
+    $columns = 'name, currency';
+    $values = $mdb2->quote(trim($fields['name'])).', '.$mdb2->quote(trim($fields['currency']));
+
+    if ($fields['decimal_mark']) {
+      $columns .= ', decimal_mark';
+      $values .= ', '.$mdb2->quote($fields['decimal_mark']);
     }
 
     $lang = $fields['lang'];
@@ -654,17 +654,13 @@ class ttTeamHelper {
       global $i18n;
       $lang = $i18n->lang;
     }
+    $columns .= ', lang';
+    $values .= ', '.$mdb2->quote($lang);
 
-    $date_format = $fields['date_format'];
-    if ($date_format !== null) {
-      $date_format_f = ', date_format';
-      $date_format_v = ', ' . $mdb2->quote($date_format);
-    } elseif (defined('DATE_FORMAT_DEFAULT')) {
-      $date_format_f = ', date_format';
-      $date_format_v = ', ' . $mdb2->quote(DATE_FORMAT_DEFAULT);
-    } else {
-      $date_format_f = '';
-      $date_format_v = '';
+    if ($fields['date_format'] || defined('DATE_FORMAT_DEFAULT')) {
+      $date_format = $fields['date_format'] ? $fields['date_format'] : DATE_FORMAT_DEFAULT;
+      $columns .= ', date_format';
+      $values .= ', '.$mdb2->quote($date_format);
     }
 
     $time_format = $fields['time_format'];
@@ -772,10 +768,8 @@ class ttTeamHelper {
       $config_f = '';
     }
 
-    $sql = "insert into tt_teams (name, currency $decimal_mark_f, lang $date_format_f $time_format_f $week_start_f $tracking_mode_f $project_required_f $task_required_f $record_type_f $bcc_email_f $plugins_f $lockspec_f $workday_minutes_f $config_f)
-      values(".$mdb2->quote(trim($fields['name'])).
-      ", ".$mdb2->quote(trim($fields['currency']))." $decimal_mark_v, ".$mdb2->quote($lang).
-      "$date_format_v $time_format_v $week_start_v $tracking_mode_v $project_required_v $task_required_v $record_type_v $bcc_email_v $plugins_v $lockspec_v $workday_minutes_v $config_v)";
+    $sql = "insert into tt_teams ($columns $time_format_f $week_start_f $tracking_mode_f $project_required_f $task_required_f $record_type_f $bcc_email_f $plugins_f $lockspec_f $workday_minutes_f $config_f)
+      values($values $time_format_v $week_start_v $tracking_mode_v $project_required_v $task_required_v $record_type_v $bcc_email_v $plugins_v $lockspec_v $workday_minutes_v $config_v)";
     $affected = $mdb2->exec($sql);
 
     if (!is_a($affected, 'PEAR_Error')) {
index 12aac3e..931e078 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.19.3989 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.19.3990 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>