/* Application User List*/
SELECT DECODE ( usr.IS_ONLINE,
	   		  	NULL, NULL,
				'<img src="images/i_online.gif" title="User is online at '|| usr.ONLINE_AT  ||'" width="16" height="16" border="0" hspace="2">' ) AS user_online,
	   DECODE ( usr.IS_DISABLED,
	   		  	NULL, 'LIMG_USER',
				'LIMG_USER_DISABLED' ) AS user_image,
	   usr.user_id,
	   usr.full_name,
	   usr.USER_EMAIL,
	   usr.USER_NAME,
	   usr.DOMAIN,
	   usr.LAST_REQUEST
  FROM (
		SELECT usr.*
		  FROM USERS usr,
		  	   USER_APPLICATIONS ua
		 WHERE ua.USER_ID = usr.USER_ID
		   AND ua.APP_ID = :APP_ID
  		) usr
 WHERE( 
 		( /* Full name filter */
 	   	( LOWER( usr.FULL_NAME ) LIKE LOWER( :FULL_NAME )  	AND NOT :FULL_NAME IS NULL )  OR
		( usr.FULL_NAME = usr.FULL_NAME  			 		AND :FULL_NAME IS NULL ) 
 	   )
   OR ( /* Username filter */
 	   	( LOWER( usr.USER_NAME ) LIKE LOWER( :USER_NAME )  	AND NOT :USER_NAME IS NULL )  OR
		( usr.USER_NAME = usr.USER_NAME  			 		AND :USER_NAME IS NULL ) 
 	   )
   OR ( /* Domain filter */
 	   	( LOWER( usr.DOMAIN ) LIKE LOWER( :DOMAIN_NAME )  	AND NOT :DOMAIN_NAME IS NULL )  OR
		( usr.DOMAIN = usr.DOMAIN  			 		 		AND :DOMAIN_NAME IS NULL ) 
 	   )
	   )
   AND usr.USER_ID NOT IN 
   (SELECT USER_ID FROM MEMBERS_GROUP WHERE GROUP_EMAIL_ID IN  
   (SELECT GROUP_EMAIL_ID 
   FROM AUTOBUILD_FAILURE 
   WHERE VIEW_ID = :VIEW_ID
   AND PROJ_ID = :PROJ_ID
   )
   )
  
   	   	   	   
ORDER BY UPPER(usr.FULL_NAME)