From: Nik Okuntseff Date: Sat, 17 Mar 2018 19:59:32 +0000 (+0000) Subject: Fixed team export by assigning role id 0 to top managers. X-Git-Tag: timetracker_1.19-1~1018 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=717d0c75c9e3ddb161c3d3d8583e2b5761b1b634;p=timetracker.git Fixed team export by assigning role id 0 to top managers. --- diff --git a/WEB-INF/lib/ttExportHelper.class.php b/WEB-INF/lib/ttExportHelper.class.php index 0c8084e2..67224c8e 100644 --- a/WEB-INF/lib/ttExportHelper.class.php +++ b/WEB-INF/lib/ttExportHelper.class.php @@ -73,7 +73,7 @@ class ttExportHelper { fwrite($file, "\n"); // Prepare role map. - $roles = ttTeamHelper::getAllRoles($user->team_id); + $roles = ttExportHelper::getAllRoles(); foreach ($roles as $key=>$role_item) $this->roleMap[$role_item['id']] = $key + 1; @@ -114,7 +114,6 @@ class ttExportHelper { // Write roles. fwrite($file, "\n"); - $roles = ttTeamHelper::getAllRoles($user->team_id); foreach ($roles as $role) { fwrite($file, " roleMap[$role['id']]."\" rank=\"".$role['rank']."\"". " rights=\"".$role['rights']."\">\n"); @@ -127,7 +126,8 @@ class ttExportHelper { // Write users. fwrite($file, "\n"); foreach ($users as $user_item) { - fwrite($file, " userMap[$user_item['id']]."\" login=\"".htmlentities($user_item['login'])."\" password=\"".$user_item['password']."\" role_id=\"".$this->roleMap[$user_item['role_id']]."\" client_id=\"".$this->clientMap[$user_item['client_id']]."\" rate=\"".$user_item['rate']."\" email=\"".$user_item['email']."\" status=\"".$user_item['status']."\">\n"); + $role_id = $user_item['rank'] == 512 ? 0 : $this->roleMap[$user_item['role_id']]; // Special role_id 0 (not null) for top manager. + fwrite($file, " userMap[$user_item['id']]."\" login=\"".htmlentities($user_item['login'])."\" password=\"".$user_item['password']."\" role_id=\"".$role_id."\" client_id=\"".$this->clientMap[$user_item['client_id']]."\" rate=\"".$user_item['rate']."\" email=\"".$user_item['email']."\" status=\"".$user_item['status']."\">\n"); fwrite($file, " \n"); fwrite($file, " \n"); } @@ -356,12 +356,30 @@ class ttExportHelper { return true; } - // The getAllUsers obtains all users in team. + // getAllRoles - obtains all roles defined for team. + static function getAllRoles() { + global $user; + $mdb2 = getConnection(); + + $result = array(); + $sql = "select * from tt_roles where team_id = $user->team_id"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + return $result; + } + return false; + } + + // The getAllUsers obtains all users in team for the purpose of export. static function getAllUsers() { global $user; $mdb2 = getConnection(); - $sql = "select * from tt_users where team_id = $user->team_id order by upper(name)"; // Note: deleted users are included. + $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id order by upper(u.name)"; // Note: deleted users are included. $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index fec798a5..bbca70e8 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -139,25 +139,6 @@ class ttTeamHelper { return false; } - // The getAllUsers obtains all users in a given team. - static function getAllUsers($team_id, $all_fields = false) { - $mdb2 = getConnection(); - - if ($all_fields) - $sql = "select * from tt_users where team_id = $team_id order by upper(name)"; - else - $sql = "select id, name from tt_users where team_id = $team_id order by upper(name)"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - while ($val = $res->fetchRow()) { - $result[] = $val; - } - return $result; - } - return false; - } - // getActiveProjects - returns an array of active projects for team. static function getActiveProjects($team_id) { @@ -347,23 +328,6 @@ class ttTeamHelper { return $result; } - // getAllRoles - obtains all roles defined for team. - static function getAllRoles($team_id) { - $mdb2 = getConnection(); - - $result = array(); - $sql = "select * from tt_roles where team_id = $team_id"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - while ($val = $res->fetchRow()) { - $result[] = $val; - } - return $result; - } - return false; - } - // The getActiveClients returns an array of active clients for team. static function getActiveClients($team_id, $all_fields = false) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f1d31481..5fde5b95 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.51.4093 | Copyright © Anuko | +  Anuko Time Tracker 1.17.51.4094 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}