- // The insert function creates a new team.
- static function insert($fields) {
-
- $mdb2 = getConnection();
-
- $lock_spec = $fields['lock_spec'];
- if ($lock_spec !== null) {
- $lockspec_f = ', lock_spec';
- $lockspec_v = ', ' . $mdb2->quote($lock_spec);
- } else {
- $lockspec_f = '';
- $lockspec_v = '';
- }
-
- if ($fields['lock_interval'] !== null) {
- $locktime_f = ', locktime';
- $locktime_v = ", " . (int)$fields['lock_interval'];
- } else {
- $locktime_f = '';
- $locktime_v = '';
- }
-
- $lang = $fields['lang'];
- if (!$lang) {
- global $i18n;
- $lang = $i18n->lang;
- }
-
- $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 = '';
- }
-
- $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 = '';
- }
-
- $time_format = $fields['time_format'];
- if ($time_format !== null) {
- $time_format_f = ', time_format';
- $time_format_v = ', ' . $mdb2->quote($time_format);
- } elseif (defined('TIME_FORMAT_DEFAULT')) {
- $time_format_f = ', time_format';
- $time_format_v = ', ' . $mdb2->quote(TIME_FORMAT_DEFAULT);
- } else {
- $time_format_f = '';
- $time_format_v = '';
- }
-
- $week_start = $fields['week_start'];
- if ($week_start !== null) {
- $week_start_f = ', week_start';
- $week_start_v = ', ' . (int)$week_start;
- } elseif (defined('WEEK_START_DEFAULT')) {
- $week_start_f = ', week_start';
- $week_start_v = ', ' . (int)WEEK_START_DEFAULT;
- } else {
- $week_start_f = '';
- $week_start_v = '';
- }
-
- $plugins = $fields['plugins'];
- if ($plugins !== null) {
- $plugins_f = ', plugins';
- $plugins_v = ', ' . $mdb2->quote($plugins);
- } else {
- $plugins_f = '';
- $plugins_v = '';
- }
-
- $tracking_mode = $fields['tracking_mode'];
- if ($tracking_mode !== null) {
- $tracking_mode_f = ', tracking_mode';
- $tracking_mode_v = ', ' . (int)$tracking_mode;
- } else {
- $tracking_mode_f = '';
- $tracking_mode_v = '';
- }
-
- $record_type = $fields['record_type'];
- if ($record_type !== null) {
- $record_type_f = ', record_type';
- $record_type_v = ', ' . (int)$record_type;
- } else {
- $record_type_f = '';
- $record_type_v = '';
- }
-
- $sql = "insert into tt_teams (name, address, currency $lockspec_f $locktime_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $record_type_f)
- values(".$mdb2->quote(trim($fields['name'])).
- ", ".$mdb2->quote(trim($fields['address'])).
- ", ".$mdb2->quote(trim($fields['currency']))." $lockspec_v $locktime_v, ".$mdb2->quote($lang).
- "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $record_type_v)";