<?php
/**
 * 用户角色
 * $Id$
 * @author huangliang
 * @package cn.compass.entity.definition
 */
class UserRole
{
	public $id;
	public $title;
	
	function __construct($record) {
		$this->id = $record["id"];
		$this->title = $record["title"];
	}
	
	/**
	 * 
	 * @return array UserRole
	 */
	public static function getList() {
		static $result;
			
		if ((!is_array($result)) || (count($result) < 1)) {
			
			$data = array();

			$tmp = array("id"=>1, "title"=>"家园用户");
			array_push($data, $tmp);
			
			$tmp = array("id"=>2, "title"=>"家校用户");
			array_push($data, $tmp);
			
			$tmp = array("id"=>3, "title"=>"高职用户");
			array_push($data, $tmp);
			
			$tmp = array("id"=>4, "title"=>"教育局领导");
			array_push($data, $tmp);
			
			$tmp = array("id"=>5, "title"=>"社会用户");
			array_push($data, $tmp);
			
			$tmp = array("id"=>6, "title"=>"机构用户");
			array_push($data, $tmp);
			
			$result = array();
			foreach ($data as $row) {
				$tmp2 = new UserRole($row);
				array_push($result, $tmp2);
			}
		}
		return $result;
	}
	
	/**
	 * 
	 * @return UserRole 
	 */
	public static function getById($id) {
		$list = UserRole::getList();
		foreach ($list as $tmp) {
			if ($tmp->id == $id) {
				return $tmp;
			}
		}
		return null;
	}
	
	/**
	 * 
	 * @return UserRole 
	 */
	public static function getTitleById($id) {
		$list = UserRole::getList();
		foreach ($list as $tmp) {
			if ($tmp->id == $id) {
				return $tmp->title;
			}
		}
		return null;
	}
	

}