PHP Class Cml\Vendor\Acl
对方法注释 @noacl 则不检查该方法的权限
对方法注释 @acljump web/User/add 则将当前方法的权限检查跳转为检查 web/User/add方法的权限
加到normal.php配置中
权限控制配置
'administratorid'=>'1', //超管理员id
建库语句
CREATE TABLE
hadm_access (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '权限ID',
userid int(11) DEFAULT '0' COMMENT '所属用户权限ID',
groupid smallint(3) DEFAULT '0' COMMENT '所属群组权限ID',
menuid int(11) NOT NULL DEFAULT '0' COMMENT '权限模块ID',
PRIMARY KEY (
id),
KEY
idx_userid (
userid) USING BTREE,
KEY
idx_groupid (
groupid) USING BTREE,
KEY
idx_menuid (
menuid) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1038 DEFAULT CHARSET=utf8 COMMENT='用户或者用户组权限记录';
CREATE TABLE
hadm_group (
id smallint(3) unsigned NOT NULL AUTO_INCREMENT,
name varchar(150) DEFAULT NULL,
status tinyint(1) unsigned DEFAULT '1' COMMENT '1正常,0删除',
PRIMARY KEY (
id)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
CREATE TABLE
hadm_menu (
id int(11) NOT NULL AUTO_INCREMENT,
pid int(11) NOT NULL DEFAULT '0' COMMENT '父模块ID编号 0则为顶级模块',
title char(64) NOT NULL COMMENT '标题',
url char(64) NOT NULL COMMENT 'url路径',
isshow tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否显示',
order int(4) NOT NULL DEFAULT '0' COMMENT '排序倒序',
PRIMARY KEY (
id),
KEY
idex_pid (
pid) USING BTREE,
KEY
idex_order (
order) USING BTREE,
KEY
idx_action (
url)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='权限模块信息表';
CREATE TABLE
hadm_users (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
groupid varchar(255) NOT NULL DEFAULT '',
username varchar(40) NOT NULL DEFAULT '',
password varchar(40) NOT NULL DEFAULT '',
lastlogin int(10) unsigned NOT NULL DEFAULT '0',
ctime int(10) unsigned NOT NULL DEFAULT '0',
stime int(10) unsigned NOT NULL DEFAULT '0',
status tinyint(1) unsigned DEFAULT '1' COMMENT '1正常,0删除',
PRIMARY KEY (
id),
UNIQUE KEY
username (
username)
) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
ファイルを表示
Open project: linhecheng/cmlphp
Class Usage Examples
Public Properties
Public Methods
Method Details
checkAcl()
public static method
public static checkAcl ( object | string $controller ) : integer |
$controller |
object | string |
传入控制器实例对象,用来判断当前访问的方法是不是要跳过权限检查。
如当前访问的方法为web/User/list则传入new \web\Controller\User()获得的实例。最常用的是在基础控制器的init方法或构造方法里传入$this。
传入字符串如web/User/list时会自动 new \web\Controller\User()获取实例用于判断 |
return |
integer |
返回1是通过检查,0是不能通过检查 |
getLoginInfo()
public static method
isSuperUser()
public static method
logout()
public static method
setEncryptKey()
public static method
设置加密用的混淆key Cookie::set本身有一重加密 这里再加一重
setLoginStatus()
public static method
Property Details
$aclNames public_oe static_oe property
public static array $aclNames |
return |
array |
|
$authUser public_oe static_oe property
public static null $authUser |
return |
null |
|