From 66ed07f63445a6ae7884cc1a1db8ffa109d90863 Mon Sep 17 00:00:00 2001
From: Lapinkiller <lapinkiller@hotmail.fr>
Date: Tue, 14 Jun 2011 13:29:09 +0200
Subject: [PATCH] filter: users in list when all_projects selected

---
 core/filter_api.php |   22 ++++++++++++----------
 core/print_api.php  |   26 +++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/core/filter_api.php b/core/filter_api.php
index 7680e5b..1172f44 100644
--- a/core/filter_api.php
+++ b/core/filter_api.php
@@ -18,7 +18,7 @@
  * @package CoreAPI
  * @subpackage FilterAPI
  * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  * @link http://www.mantisbt.org
  */
 
@@ -3530,21 +3530,23 @@ function print_filter_user_monitor() {
  */
 function print_filter_handler_id() {
 	global $t_select_modifier, $t_filter, $f_view_type;
+	$t_current_project = helper_get_current_project();
 	?>
 		<!-- Handler -->
 		<select <?php echo $t_select_modifier;?> name="handler_id[]">
 			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
-			<?php if( access_has_project_level( config_get( 'view_handler_threshold' ) ) ) {?>
-			<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
+			<?php 
+			if( access_has_project_level(config_get( 'view_handler_threshold'))|| $t_current_project == ALL_PROJECTS) {?>
+				<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
 			<?php
-								if( access_has_project_level( config_get( 'handle_bug_threshold' )) || $t_filter[FILTER_PROPERTY_HANDLER_ID][0] == ALL_PROJECTS) {
-			echo '<option value="' . META_FILTER_MYSELF . '" ';
-			check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_MYSELF );
-			echo '>[' . lang_get( 'myself' ) . ']</option>';
-		}
+				if( access_has_project_level( config_get( 'handle_bug_threshold' )) || $t_current_project == ALL_PROJECTS) {
+					echo '<option value="' . META_FILTER_MYSELF . '" ';
+					check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_MYSELF );
+					echo '>[' . lang_get( 'myself' ) . ']</option>';
+				}
 
-		print_assign_to_option_list( $t_filter[FILTER_PROPERTY_HANDLER_ID] );
-	}?>
+				print_assign_to_option_list( $t_filter[FILTER_PROPERTY_HANDLER_ID], $t_current_project);
+			}?>
 		</select>
 		<?php
 }
diff --git a/core/print_api.php b/core/print_api.php
index 704c48c..c4d9062 100644
--- a/core/print_api.php
+++ b/core/print_api.php
@@ -19,7 +19,7 @@
  * @package CoreAPI
  * @subpackage PrintAPI
  * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  * @link http://www.mantisbt.org
  */
 
@@ -219,9 +219,29 @@ function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = A
 		$p_project_id = helper_get_current_project();
 	}
 
-	$t_users = project_get_all_user_rows( $p_project_id, $p_access );
+	if($p_project_id === ALL_PROJECTS){
+		$t_projects = user_get_accessible_projects(auth_get_current_user_id());
 
-	# handles ALL_PROJECTS case
+		foreach($t_projects as $t_project_id){
+			$t_project_users_list = project_get_all_user_rows($t_project_id,$p_access);
+		
+			$t_users_temp = array_merge($t_users_temp,$t_project_users_list);
+		}
+		
+		$t_users_id_list = array();
+		//Remove user from list (there is a "myself" value)
+		$t_users_id_list[] = auth_get_current_user_id();
+		
+		//Deleting duplicate
+		foreach($t_users_temp as $t_user){
+			if(!in_array($t_user['id'],$t_users_id_list)){
+				$t_users_id_list[] = $t_user['id'];
+				$t_users[] = $t_user;
+			}
+		}
+	}else{
+		$t_users = project_get_all_user_rows( $p_project_id, $p_access,false );
+	}
 
 	$t_display = array();
 	$t_sort = array();
-- 
1.7.4.msysgit.0

