1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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);
$tmp = array("id"=>7, "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;
}
}