<?php
class folder_form_options extends myQuicty {

function __construct($page) {
	parent::__construct();
	$this->page = $page;
	$this->form = $this->page->form;
	$this->init_field_define();
}

function check_uniq($data) {
	$id = $_REQUEST[$this->id_column];
	$data = strtolower($data);
	if($id) {
		$condition = "where id=$id and name='$data' and application_id=".$_REQUEST['application_id'];
		$num = $this->form->count_rows($condition);
		if($num==1 or $num==0) {
			$result = true;
		} else {
			$result = false;
		}
	} else {
		$condition = "where name='$data' and application_id=".$_REQUEST['application_id'];
		$num = $this->form->count_rows($condition);
		if($num==0) {
			$result = true;
		} else {
			$result = false;
		}
	}
	return $result;
}


function set_form_options() {
	$this->form->set_base_link_addr(quicty_base_url().'/folder/');
	$this->form->set_restart_link_addr(quicty_base_url().'/folder/');
	$this->form->set_button_status('use_confirm',false);
	$this->form->registerRule('check_uniq','callback','check_uniq',$this);
	$this->form->addRule('name','そのフォルダはすでに存在します。','check_uniq',NULL,'server');
}

// filters

function set_form_filters() {
	$this->form->applyFilter('_ALL_','trim');
	$this->form->applyFilter('name','strtolower');
}

} // end of class folder_form_options
?>