X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttTeamHelper.class.php;h=684fa63c53fcaae5384a682068cf0a91df861286;hb=8d68ecdd7b1c45cb2a5cf592b8d504d7e4614911;hp=3af484c8e83c61ddc3862e156103cb1fea186d14;hpb=ecbfa220ec9448151166495a3dad39fa97b6c604;p=timetracker.git diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 3af484c8..684fa63c 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -263,17 +263,40 @@ class ttTeamHelper { return false; } + // getActiveRolesForUser - returns an array of relevant active roles for user with rank less than self. + // "Relevant" means that client roles are filtered out if Client plugin is disabled. + static function getActiveRolesForUser() + { + global $user; + $result = array(); + $mdb2 = getConnection(); + + $sql = "select id, name, description, rank, rights from tt_roles where team_id = $user->team_id and rank < $user->rank and status = 1 order by rank"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $val['is_client'] = in_array('track_own_time', explode(',', $val['rights'])) ? 0 : 1; // Clients do not have data entry right. + if ($val['is_client'] && !$user->isPluginEnabled('cl')) + continue; // Skip adding a client role. + $result[] = $val; + } + } + return $result; + } + // getActiveRoles - returns an array of active roles for team. static function getActiveRoles($team_id) { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description from tt_roles where team_id = $team_id and status = 1 order by rank"; + $sql = "select id, name, description, rank, rights from tt_roles where team_id = $team_id and status = 1 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { + $val['is_client'] = in_array('track_own_time', explode(',', $val['rights'])) ? 0 : 1; // Clients do not have data entry right. $result[] = $val; } } @@ -286,7 +309,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description from tt_roles + $sql = "select id, name, rank, description from tt_roles where team_id = $team_id and status = 0 order by rank"; $res = $mdb2->query($sql); $result = array(); @@ -298,6 +321,23 @@ 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) { @@ -369,7 +409,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - if (ROLE_CLIENT == $user->role && $user->client_id) + if ($user->isClient()) $client_part = " and i.client_id = $user->client_id"; $sql = "select i.id, i.name, i.date, i.client_id, i.status, c.name as client_name from tt_invoices i @@ -520,23 +560,6 @@ class ttTeamHelper { return false; } - // getRoles - obtains all roles defined for team. - static function getRoles($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; - } - // getExpenseItems - obtains all expense items for all users in team. static function getExpenseItems($team_id) { $mdb2 = getConnection(); @@ -1031,7 +1054,7 @@ class ttTeamHelper { static function enablePlugin($plugin, $enable = true) { global $user; - if (!$user->canManageTeam()) + if (!$user->can('manage_features')) return false; $plugin_array = explode(',', $user->plugins);