From db51a4b1e95f48d82bf2a214f8d0736f2485e3a2 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 30 Nov 2018 14:51:33 +0000 Subject: [PATCH] Ongoing refactoring on decoupling import. --- WEB-INF/lib/ttOrgImportHelper.class.php | 23 +++++++++++++++++------ WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 328eabef..060a7c1d 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -27,13 +27,8 @@ // +----------------------------------------------------------------------+ import('ttUserHelper'); -import('ttRoleHelper'); import('ttTaskHelper'); -import('ttClientHelper'); import('ttInvoiceHelper'); -import('ttTimeHelper'); -import('ttExpenseHelper'); -import('ttFavReportHelper'); // ttOrgImportHelper class is used to import organization data from an XML file // prepared by ttOrgExportHelper and consisting of nested groups with their info. @@ -63,7 +58,7 @@ class ttOrgImportHelper { // Constructor. function __construct(&$errors) { $this->errors = &$errors; - $this->top_role_id = ttRoleHelper::getRoleByRank(512, 0); + $this->top_role_id = $this->getTopRole(); } // startElement - callback handler for opening tags in XML. @@ -981,4 +976,20 @@ class ttOrgImportHelper { $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } + + // getTopRole returns top role id. + private function getTopRole() { + global $user; + $mdb2 = getConnection(); + + $sql = "select id from tt_roles where group_id = 0 and rank = ".MAX_RANK." and status = 1"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['id']) + return $val['id']; + } + return false; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 0b4dd2b4..f0d3ff54 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4546 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4547 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1