<?php
	require_once( $GLOBALS["site_root"] . "/includes/widgets/AdminAutocomplete.inc.php" );

	class AdminUserSelector extends AdminAutocomplete {

		public function __construct( $id , $parent = NULL ) {
			parent::__construct( $id , $parent );
			$this->setStrict( true );
			$this->setWidth( 250 );
		}
		
		protected function getAutocompleteHints( $filter ) {
			$query = sprintf( "select user_id as id,user_name|| ' (#'||user_id||')' as label from users where user_name ilike '%s%%' order by user_name,user_id limit 50",
				FNTH_db_addslashes( $filter ) );
			return FNTH_db_get_resultset($query);
		}

		protected function getLabelForId( $id ) {
			$query = sprintf( "select user_name|| ' (#'||user_id||')' as label from users where user_id=%d" , $id );
			return FNTH_db_get_field( $query , "label" );
		}

	}

?>
