Some more work in progress on subgroups.
[timetracker.git] / time.php
index 5307d8b..da81636 100644 (file)
--- a/time.php
+++ b/time.php
@@ -124,10 +124,12 @@ if ($user->can('manage_subgroups')) {
 } // SUBGROUP_DEBUG
 
 if ($user->can('track_time')) {
+  // Determine max rank.
+  $max_rank = $on_behalf_group_id == $user->group_id ? $user->rank-1 : 512; // TODO: stop using magic numbers.
   if ($user->can('track_own_time'))
-    $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1,'include_self'=>true,'self_first'=>true);
+    $options = array('group_id'=>$on_behalf_group_id,'status'=>ACTIVE,'max_rank'=>$max_rank,'include_self'=>true,'self_first'=>true);
   else
-    $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1);
+    $options = array('group_id'=>$on_behalf_group_id,'status'=>ACTIVE,'max_rank'=>$max_rank);
   $user_list = $user->getUsers($options);
   if (count($user_list) >= 1) {
     $form->addInput(array('type'=>'combobox',