From f6afe28937ca24f05e0a4fc0f4b4054d1832f5a9 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 19 Nov 2018 21:01:53 +0000 Subject: [PATCH] Added user config params to import. --- WEB-INF/lib/ttOrgImportHelper.class.php | 29 +++++++++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 9907f6e7..dda7f75d 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -526,6 +526,18 @@ class ttOrgImportHelper { } return; } + + if ($name == 'USER_PARAM') { + if (!$this->insertUserParam(array( + 'group_id' => $this->current_group_id, + 'org_id' => $this->org_id, + 'user_id' => $this->currentGroupUserMap[$attrs['USER_ID']], + 'param_name' => $attrs['PARAM_NAME'], + 'param_value' => $attrs['PARAM_VALUE']))) { + $this->errors->add($i18n->get('error.db')); + } + return; + } } } @@ -884,4 +896,21 @@ class ttOrgImportHelper { $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } + + // insertUserParam - a helper function to insert a user parameter. + private function insertUserParam($fields) { + $mdb2 = getConnection(); + + $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; + $user_id = (int) $fields['user_id']; + $param_name = $fields['param_name']; + $param_value = $fields['param_value']; + + $sql = "insert into tt_config". + " (user_id, group_id, org_id, param_name, param_value)". + " values ($user_id, $group_id, $org_id, ".$mdb2->quote($param_name).", ".$mdb2->quote($param_value).")"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 23cc0edb..c6c6ed7d 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.22.4466 | Copyright © Anuko | +  Anuko Time Tracker 1.18.22.4467 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1