<?php
	require_once( $GLOBALS["site_root"]."/includes/widgets/Widget.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/widgets/FrontendTextbox.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/widgets/FrontendSubmit.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/widgets/FrontendCheckbox.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/widgets/UserTypeFilter.inc.php" );
	
	require_once( $GLOBALS["site_root"]."/includes/models/MyUser.inc.php" );
	
	require_once( $GLOBALS["site_root"]."/includes/urlgen/Blueboard.inc.php" );

	class BlueboardFilterForm extends Widget {
		public $oAlreadyCommented;
		public $oCommentedByMe;
		public $oUserType;
		public $oNameFilter;
		public $oFilter;

		public function __construct( $id , $parent ) {
			parent::__construct( $id , $parent );
			$this->oAlreadyCommented = new FrontendCheckbox( "ac" , $this );
			$this->oCommentedByMe = new FrontendCheckbox( "mc" , $this );
			$this->oUserType = new UserTypeFilter( "utype" , $this );
			$this->oNameFilter = new FrontendTextbox( "namefilter" , $this );
			$this->oFilter = new FrontendSubmit( "filter" , $this );
			$this->oFilter->setValue( __("Search","attr") );
		}

		protected function initializeWidgets() {

		}

		public function handleEvents() {
			$this->oFilter->refreshValueFromArray( $this->aG );
			if (!$this->oFilter->isSubmitted()) return parent::handleEvents();
			$this->refreshChildValuesFromArray( $this->aG );
			return parent::handleEvents();
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$mum = new MyUserModel();
			$user_id = $mum->getLoggedInUserId();
			$this->setParam( "user_id" , $user_id );
			if ($user_id) {
				$p = $this->aG;
				$p["user_id"]=$user_id;
				if (isset( $p["lang"] )) unset( $p["lang"] );
				$this->setParam( "url_my_feedback_page" , BlueboardURL::renderURL( $p ) );
			}
			return parent::render();
		}

	}
?>
