Skip to content

Commit bf03701

Browse files
committed
Improved export-import to include allow_ip and password_complexity.
1 parent 885b2d9 commit bf03701

4 files changed

Lines changed: 49 additions & 103 deletions

File tree

WEB-INF/lib/ttExportHelper.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ function createDataFile($compress = false) {
7070
"\" config=\"".$user->config.
7171
"\">\n");
7272
fwrite($file, " <name><![CDATA[".$user->group."]]></name>\n");
73+
fwrite($file, " <allow_ip><![CDATA[".$user->allow_ip."]]></allow_ip>\n");
74+
fwrite($file, " <password_complexity><![CDATA[".$user->password_complexity."]]></password_complexity>\n");
7375
fwrite($file, "</group>\n");
7476

7577
// Prepare role map.

WEB-INF/lib/ttImportHelper.class.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function endElement($parser, $name) {
124124
// Now we can create a group.
125125
if ($this->canImport) {
126126
$this->top_role_id = ttRoleHelper::getRoleByRank(512, 0);
127-
$group_id = ttTeamHelper::insert(array(
127+
$group_id = $this->createGroup(array(
128128
'name' => $this->groupData['NAME'],
129129
'currency' => $this->groupData['CURRENCY'],
130130
'decimal_mark' => $this->groupData['DECIMAL_MARK'],
@@ -137,6 +137,8 @@ function endElement($parser, $name) {
137137
'task_required' => $this->groupData['TASK_REQUIRED'],
138138
'record_type' => $this->groupData['RECORD_TYPE'],
139139
'bcc_email' => $this->groupData['BCC_EMAIL'],
140+
'allow_ip' => $this->groupData['ALLOW_IP'],
141+
'password_complexity' => $this->groupData['PASSWORD_COMPLEXITY'],
140142
'plugins' => $this->groupData['PLUGINS'],
141143
'lock_spec' => $this->groupData['LOCK_SPEC'],
142144
'workday_minutes' => $this->groupData['WORKDAY_MINUTES'],
@@ -343,7 +345,9 @@ function dataElement($parser, $data) {
343345
|| $this->currentTag == 'LABEL'
344346
|| $this->currentTag == 'VALUE'
345347
|| $this->currentTag == 'COMMENT'
346-
|| $this->currentTag == 'ADDRESS') {
348+
|| $this->currentTag == 'ADDRESS'
349+
|| $this->currentTag == 'ALLOW_IP'
350+
|| $this->currentTag == 'PASSWORD_COMPLEXITY') {
347351
if (isset($this->currentElement[$this->currentTag]))
348352
$this->currentElement[$this->currentTag] .= trim($data);
349353
else
@@ -432,6 +436,46 @@ function uncompress($in, $out) {
432436
return true;
433437
}
434438

439+
// createGroup function creates a new group.
440+
private function createGroup($fields) {
441+
442+
global $user;
443+
$mdb2 = getConnection();
444+
445+
$columns = '(name, currency, decimal_mark, lang, date_format, time_format, week_start, tracking_mode'.
446+
', project_required, task_required, record_type, bcc_email, allow_ip, password_complexity, plugins'.
447+
', lock_spec, workday_minutes, config, created, created_ip, created_by)';
448+
449+
$values = ' values ('.$mdb2->quote(trim($fields['name']));
450+
$values .= ', '.$mdb2->quote(trim($fields['currency']));
451+
$values .= ', '.$mdb2->quote($fields['decimal_mark']);
452+
$values .= ', '.$mdb2->quote($fields['lang']);
453+
$values .= ', '.$mdb2->quote($fields['date_format']);
454+
$values .= ', '.$mdb2->quote($fields['time_format']);
455+
$values .= ', '.(int)$fields['week_start'];
456+
$values .= ', '.(int)$fields['tracking_mode'];
457+
$values .= ', '.(int)$fields['project_required'];
458+
$values .= ', '.(int)$fields['task_required'];
459+
$values .= ', '.(int)$fields['record_type'];
460+
$values .= ', '.$mdb2->quote($fields['bcc_email']);
461+
$values .= ', '.$mdb2->quote($fields['allow_ip']);
462+
$values .= ', '.$mdb2->quote($fields['password_complexity']);
463+
$values .= ', '.$mdb2->quote($fields['plugins']);
464+
$values .= ', '.$mdb2->quote($fields['lock_spec']);
465+
$values .= ', '.(int)$fields['workday_minutes'];
466+
$values .= ', '.$mdb2->quote($fields['config']);
467+
$values .= ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id);
468+
$values .= ')';
469+
470+
$sql = 'insert into tt_groups '.$columns.$values;
471+
$affected = $mdb2->exec($sql);
472+
if (!is_a($affected, 'PEAR_Error')) {
473+
$group_id = $mdb2->lastInsertID('tt_groups', 'id');
474+
return $group_id;
475+
}
476+
return false;
477+
}
478+
435479
// insertMonthlyQuota - a helper function to insert a monthly quota.
436480
private function insertMonthlyQuota($group_id, $year, $month, $minutes) {
437481
$mdb2 = getConnection();

WEB-INF/lib/ttTeamHelper.class.php

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -673,106 +673,6 @@ static function getMonthlyQuotas($group_id) {
673673
return false;
674674
}
675675

676-
// The insert function creates a new group.
677-
static function insert($fields) {
678-
679-
global $user;
680-
$mdb2 = getConnection();
681-
682-
// Start with group name and currency.
683-
$columns = 'name, currency';
684-
$values = $mdb2->quote(trim($fields['name'])).', '.$mdb2->quote(trim($fields['currency']));
685-
686-
if ($fields['decimal_mark']) {
687-
$columns .= ', decimal_mark';
688-
$values .= ', '.$mdb2->quote($fields['decimal_mark']);
689-
}
690-
691-
$lang = $fields['lang'];
692-
if (!$lang) {
693-
global $i18n;
694-
$lang = $i18n->lang;
695-
}
696-
$columns .= ', lang';
697-
$values .= ', '.$mdb2->quote($lang);
698-
699-
if ($fields['date_format'] || defined('DATE_FORMAT_DEFAULT')) {
700-
$date_format = $fields['date_format'] ? $fields['date_format'] : DATE_FORMAT_DEFAULT;
701-
$columns .= ', date_format';
702-
$values .= ', '.$mdb2->quote($date_format);
703-
}
704-
705-
if ($fields['time_format'] || defined('TIME_FORMAT_DEFAULT')) {
706-
$time_format = $fields['time_format'] ? $fields['time_format'] : TIME_FORMAT_DEFAULT;
707-
$columns .= ', time_format';
708-
$values .= ', '.$mdb2->quote($time_format);
709-
}
710-
711-
if ($fields['week_start'] || defined('WEEK_START_DEFAULT')) {
712-
$week_start = $fields['week_start'] ? $fields['week_start'] : WEEK_START_DEFAULT;
713-
$columns .= ', week_start';
714-
$values .= ', '.(int)$week_start;
715-
}
716-
717-
if ($fields['tracking_mode']) {
718-
$columns .= ', tracking_mode';
719-
$values .= ', '.(int)$fields['tracking_mode'];
720-
}
721-
722-
if ($fields['project_required']) {
723-
$columns .= ', project_required';
724-
$values .= ', '.(int)$fields['project_required'];
725-
}
726-
727-
if ($fields['task_required']) {
728-
$columns .= ', task_required';
729-
$values .= ', '.(int)$fields['task_required'];
730-
}
731-
732-
if ($fields['record_type']) {
733-
$columns .= ', record_type';
734-
$values .= ', '.(int)$fields['record_type'];
735-
}
736-
737-
if ($fields['bcc_email']) {
738-
$columns .= ', bcc_email';
739-
$values .= ', '.$mdb2->quote($fields['bcc_email']);
740-
}
741-
742-
if ($fields['plugins']) {
743-
$columns .= ', plugins';
744-
$values .= ', '.$mdb2->quote($fields['plugins']);
745-
}
746-
747-
if ($fields['lock_spec']) {
748-
$columns .= ', lock_spec';
749-
$values .= ', '.$mdb2->quote($fields['lock_spec']);
750-
}
751-
752-
if ($fields['workday_minutes']) {
753-
$columns .= ', workday_minutes';
754-
$values .= ', '.(int)$fields['workday_minutes'];
755-
}
756-
757-
if ($fields['config']) {
758-
$columns .= ', config';
759-
$values .= ', '.$mdb2->quote($fields['config']);
760-
}
761-
762-
$columns .= ', created, created_ip, created_by';
763-
$values .= ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id);
764-
765-
$sql = "insert into tt_groups ($columns) values($values)";
766-
$affected = $mdb2->exec($sql);
767-
768-
if (!is_a($affected, 'PEAR_Error')) {
769-
$group_id = $mdb2->lastInsertID('tt_groups', 'id');
770-
return $group_id;
771-
}
772-
773-
return false;
774-
}
775-
776676
// The getInactiveGroups is a maintenance function that returns an array of inactive group ids (max 100).
777677
static function getInactiveGroups() {
778678
$inactive_groups = array();

WEB-INF/templates/footer.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<br>
1313
<table cellspacing="0" cellpadding="4" width="100%" border="0">
1414
<tr>
15-
<td align="center">&nbsp;Anuko Time Tracker 1.17.87.4249 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
15+
<td align="center">&nbsp;Anuko Time Tracker 1.17.87.4250 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
1616
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
1717
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
1818
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>

0 commit comments

Comments
 (0)