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
<?php
/**
* 管理员权限分配用静态类
* $Id$
* @author zongbiao
* @package jp.fishow.entity.definition
*/
class SystemFunction
{
public $name;
public $title;
function __construct($record) {
$this->name = $record["name"];
$this->title = $record["title"];
}
/**
* このクラスのインスタンスのリストを返します。
* @return array ImageType一覧
*/
public static function getList() {
static $result;
if ((!is_array($result)) || (count($result) < 1)) {
$data = array();
//下级账号添加权限
$tmp = array("name"=>'ACCOUNT', "title"=>"下级账号发行");
array_push($data, $tmp);
//活动发布权限
$tmp = array("name"=>'EVENT', "title"=>"活动发布");
array_push($data, $tmp);
//下级发起的活动审核权限
$tmp = array("name"=>'CHECK', "title"=>"活动审核");
array_push($data, $tmp);
$result = array();
foreach ($data as $row) {
$tmp2 = new SystemFunction($row);
array_push($result, $tmp2);
}
}
return $result;
}
/**
* 定義名から対応するインスタンスを返します。
* @return SystemFunction 対応するインスタンス。ない場合null。
*/
public static function getByName($name) {
$list = SystemFunction::getList();
foreach ($list as $tmp) {
if ($tmp->name == $name) {
return $tmp;
}
}
return null;
}
/**
* 通过定义名取得标题,用于显示
* @return
*/
public static function getTitlesByNames($names) {
if (empty($names)) {
return "拥有全部权限";
}
if (!is_array($names)) {
$names = explode(",", $names);
}
$list = SystemFunction::getList();
$result = array();
foreach ($list as $tmp) {
if (in_array($tmp->name, $names)) {
array_push($result, $tmp->title);
}
}
return implode(",", $result);
}
}