<?php
class CUnitJob
{
	var $job_id; //名称
	var $job_url;	//执行路径
	var $job_desc;//描述
	
	function Init($id, $url, $desc)
	{
		$this->job_id = $id; 
		$this->job_url = $url;	
		$this->job_desc = $desc;
	}
};

function RegisterAction($id, $url, $desc)
{
	global $Config;
	$job = new CUnitJob();
	$job->Init($id, $url, $desc);
	$i = sizeof($Config['actions']);
	$Config['actions'][$i] = $job;
}

function RegisterView($id, $url, $desc)
{
	global $Config;
	$job = new CUnitJob();
	$job->Init($id, $url, $desc);
	$i = sizeof($Config['views']);
	$Config['views'][$i] = $job;
	
}

function RegisterDialog($id, $url, $desc)
{
	global $Config;
	$job = new CUnitJob();
	$job->Init($id, $url, $desc);
	$i = sizeof($Config['dlgs']);
	$Config['dlgs'][$i] = $job;	
}

function AutoLoadAction(&$action_class)
{
	global $Config;
	$job = $_REQUEST['action']; 
	$action = 'action/action.none.php';
	$action_class = 'CActionNone';
	
	for($i=0;$i<sizeof($Config['actions']);$i++)
	{
		if($Config['actions'][$i]->job_id == $job)
		{
			$action	= $Config['actions'][$i]->job_url;
			$action_class = $Config['actions'][$i]->job_desc;
			break;
		}	
	}
		
	return $action;
}

function AutoLoadView(&$view_desc)
{
	global $Config;
	$job = "";
	$view = 'view/view.no_job.php';
	$view_desc = "错误页面";
	
	if(array_key_exists("job", $_REQUEST))
		$job = $_REQUEST['job'];
		
	$job = $job=="" ? "issue_list" : $job;
	
	for($i=0;$i<sizeof($Config['views']);$i++)
	{
		if($Config['views'][$i]->job_id == $job)
		{
			$view	= $Config['views'][$i]->job_url;
			$view_desc = $Config['views'][$i]->job_desc;
			break;
		}
	}
	
	return $view;
}

function AutoLoadDialog()
{
	$job = $_REQUEST['dlg']; 
	global $Config;
	$dlg = 'dlg.none.php';
	
	for($i=0;$i<sizeof($Config['dlgs']);$i++)
	{
		if($Config['dlgs'][$i]->job_id == $job)
		{
			$dlg	= $Config['dlgs'][$i]->job_url;
			break;
		}	
	}
		
	return $dlg;
}

//用户管理的界面
function GetSubUserView()
{
	global $view_desc, $ln;
	$subjob = "";
	$view = 'view/view.no_job.php';
	$view_desc = $view_desc . " >> ";
	
	if(array_key_exists("subjob", $_REQUEST))
		$subjob = $_REQUEST['subjob'];
		
	if($subjob == "view_config_dept")
	{
		$view = 'sub_view/subview.dept.php';
		$view_desc = $view_desc . $ln["user_mgr"]["dept"]; 
	}
	else if($subjob == "view_config_role")
	{
		$view = 'sub_view/subview.role.php';
		$view_desc = $view_desc . $ln["user_mgr"]["role"]; 
	}
	else
	{
		$view = 'sub_view/subview.user.php';
		$view_desc = $view_desc . $ln["user_mgr"]["user"]; 
	}
	
	return $view;
}

//项目配置的管理界面
function GetSubProjectView()
{
	global $view_desc;
	$subjob = "";
	$view = 'view/view.no_job.php';
	$view_desc = $view_desc . " >> ";
	
	if(array_key_exists("subjob", $_REQUEST))
		$subjob = $_REQUEST['subjob'];
	
	if($subjob == "project_config")
	{
		$view = 'sub_view/subview.project_config.php';
		$view_desc = $view_desc . "项目配置"; 
	}
	else
	{
		$view = 'sub_view/subview.project_list.php';
		$view_desc = $view_desc . "项目列表"; 
	}
	
	return $view;
}

function GetProjectConfigView()
{
		$config_job="";
		if(array_key_exists("config_job", $_REQUEST))
			$config_job = $_REQUEST['config_job'];
			
		if($config_job == "work_group")
			$view = "subview.project_config_workgroup.php";
		else if($config_job == "project_module")
			$view = "subview.project_config_module.php";
		else if($config_job == "project_field")
			$view = "subview.project_config_field.php";
		else
			$view = "subview.project_config_issuetype.php";
			
		return $view;
}

function GetSubReleaseView()
{
		$subjob="";
		$view = "sub_view/subview.release_server.php";
		
		if(array_key_exists("subjob", $_REQUEST))
			$subjob = $_REQUEST['subjob'];
		
		if($subjob == "version_client")
			$view = "sub_view/subview.release_client.php";
		
		return $view;
}

?>