Fixed visibility of the Required checkbox on group settings.
authorNik Okuntseff <support@anuko.com>
Sat, 7 Apr 2018 14:58:23 +0000 (14:58 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 7 Apr 2018 14:58:23 +0000 (14:58 +0000)
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/group_edit.tpl
group_edit.php
locking.php
quotas.php

index 6920ab3..b22e8b5 100644 (file)
@@ -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;
     }
index 2fb7caa..ae197c6 100644 (file)
@@ -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;
+  }
 }
index 86c58ed..ac4aadb 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.87.4240 | 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.87.4241 | 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>
index 35e7604..7cb8d2e 100644 (file)
@@ -142,7 +142,7 @@ function handlePluginCheckboxes() {
           </tr>
           <tr>
             <td align="right" nowrap>{$i18n.form.profile.tracking_mode}:</td>
-            <td>{$forms.groupForm.tracking_mode.control} {$forms.profileForm.task_required.control} <span id="task_required_label"><label for="task_required">{$i18n.label.required}</label></span></td>
+            <td>{$forms.groupForm.tracking_mode.control} {$forms.groupForm.task_required.control} <span id="task_required_label"><label for="task_required">{$i18n.label.required}</label></span></td>
           </tr>
           <tr>
             <td align="right" nowrap>{$i18n.form.profile.record_type}:</td>
index 64a1530..cc27afa 100644 (file)
@@ -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,
index 8aae756..94996ad 100644 (file)
@@ -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 {
index a453099..ac6542f 100644 (file)
@@ -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'));
     }