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();
$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;
}
}
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;
+ }
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.87.4240 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.87.4241 | Copyright © <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>
</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>
$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,
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 {
// 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'));
}