X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttTeamHelper.class.php;h=5a3dd2fb6782ca18553f965ead31f6a8f769b12b;hb=bde9999ab047052540e9b57ce39d7932bcb00f9d;hp=b4454a92bb2e224cf2ddef1b3d21c05e2ec556ae;hpb=2908e17af44b65d6a97e299edd03293ddd802802;p=timetracker.git diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index b4454a92..5a3dd2fb 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -60,10 +60,13 @@ class ttTeamHelper { global $i18n; $mdb2 = getConnection(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; + if (isset($options['getAllFields'])) - $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id and u.status = 1 order by upper(u.name)"; + $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $group_id and u.org_id = $org_id and u.status = 1 order by upper(u.name)"; else - $sql = "select id, name from tt_users where group_id = $user->group_id and status = 1 order by upper(name)"; + $sql = "select id, name from tt_users where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)"; $res = $mdb2->query($sql); $user_list = array(); if (is_a($res, 'PEAR_Error')) @@ -290,10 +293,14 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; - $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $user->rank and status = 1 order by rank"; + // Determine max rank. If we are working in on behalf group + // then rank restriction does not apply. + $max_rank = $user->behalfGroup ? MAX_RANK : $user->rank; + + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $max_rank and status = 1 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -351,10 +358,14 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; - $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $user->rank and status = 0 order by rank"; + // Determine max rank. If we are working in on behalf group + // then rank restriction does not apply. + $max_rank = $user->behalfGroup ? MAX_RANK : $user->rank; + + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $max_rank and status = 0 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) {