<?php
include_once ("_dirinfo.php");

include_once (PATH_TO_ROOT."init.php");
include_once (PATH_TO_ROOT."_ajaxManipulators/_class/class.gridData.php");


class RedirectionMan extends GridDataManipulator
{
	public function selectAction()
	{
		if( substr( $_POST["RMtable"],0, 9) == 'GetQNames' )
		{
			$this->table = substr( $_POST["RMtable"], 10);
			$_POST['sort'] = 'q_pos';
			
			parent::fetchSelect();
			
			array_unshift( $this->arr , array('id' => -3,'q_name'=> 'Quota full' ) );
			
			array_unshift( $this->arr ,array('id' => -2,'q_name'=> 'Final question' ) );
			array_unshift( $this->arr , array('id' => -1,'q_name'=> 'Normal finish' ) );
			
		}
		return parent::selectAction();
		
	}
}

$db->ChangeDatabase($_POST['database']);

$project = $_POST['RMtable'];

$manipulator = new RedirectionMan($db,$project);
//$manipulator->table = $project;
		
$comm = $_POST['action'].'Action';
if(method_exists($manipulator,$comm))
	echo $manipulator->$comm();
else 
{
	
	Echo '{success:false,error:"Unknown action!"}';	
	
}
?>