Commit c5266ab9 by biao

1

parent 3d03e845
<?php
/**
* 管理员权限分配用静态类
* $Id$
* @author zongbiao
* @package jp.fishow.entity.definition
*/
class AuthorityLevel
{
public $id;
public $level;
public $model;
function __construct($record) {
$this->id = $record["id"];
$this->level = $record["level"];
$this->model = $record["model"];
}
/**
* このクラスのインスタンスのリストを返します。
* @return array ImageType一覧
*/
public static function getList() {
static $result;
if ((!is_array($result)) || (count($result) < 1)) {
$data = array();
//系统管理员
$tmp = array("id"=>1, "level"=>"0", "model"=>"ACCOUNT|EVENT|CHECK");
array_push($data, $tmp);
//省厅级权限
$tmp = array("id"=>2, "level"=>"1", "model"=>"ACCOUNT|CHECK");
array_push($data, $tmp);
//市级权限
$tmp = array("id"=>3, "level"=>"2", "model"=>"ACCOUNT|CHECK");
array_push($data, $tmp);
//区县管局权限
$tmp = array("id"=>4, "level"=>"3", "model"=>"ACCOUNT|CHECK");
array_push($data, $tmp);
//学校级别权限
$tmp = array("id"=>5, "level"=>"4", "model"=>"ACCOUNT|CHECK");
array_push($data, $tmp);
//班级级别权限
$tmp = array("id"=>6, "level"=>"5", "model"=>"ACCOUNT|CHECK");
array_push($data, $tmp);
$result = array();
foreach ($data as $row) {
$tmp2 = new AuthorityLevel($row);
array_push($result, $tmp2);
}
}
return $result;
}
/**
* IDから対応するインスタンスを返します。
* @return AuthorityLevel 対応するインスタンス。ない場合null。
*/
public static function getById($id) {
$list = AuthorityLevel::getList();
foreach ($list as $tmp) {
if ($tmp->id == $id) {
return $tmp;
}
}
return null;
}
/**
* 定義名から対応するインスタンスを返します。
* @return AuthorityLevel 対応するインスタンス。ない場合null。
*/
public static function getByName($name) {
$list = AuthorityLevel::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 = AuthorityLevel::getList();
$result = array();
foreach ($list as $tmp) {
if (in_array($tmp->name, $names)) {
array_push($result, $tmp->title);
}
}
return implode(",", $result);
}
}
\ No newline at end of file
<?php
/**
* 用户角色
* $Id$
* @author huangliang
* @package cn.compass.entity.definition
*/
class CourseParentCategory
{
public $id;
public $title;
public $subCategorys;
function __construct($record) {
$this->id = $record["id"];
$this->title = $record["title"];
}
/**
*
* @return array CourseParentCategory
*/
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);
$result = array();
foreach ($data as $row) {
$tmp2 = new CourseParentCategory($row);
array_push($result, $tmp2);
}
}
return $result;
}
/**
*
* @return CourseParentCategory
*/
public static function getById($id) {
$list = CourseParentCategory::getList();
foreach ($list as $tmp) {
if ($tmp->id == $id) {
return $tmp;
}
}
return null;
}
/**
*
* @return CourseParentCategory
*/
public static function getTitleById($id) {
$list = CourseParentCategory::getList();
foreach ($list as $tmp) {
if ($tmp->id == $id) {
return $tmp->title;
}
}
return null;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment