Discuz forumperm函数 论坛权限判定
/**
* 论坛权限
* @param $permstr - 权限信息
* @param $groupid - 只判断用户组
* @return 0 无权限 > 0 有权限
*/
function forumperm($permstr, $groupid = 0) {
global $_G;
$groupidarray = array($_G['groupid']);
if($groupid) {
return preg_match("/(^|\t)(".$groupid.")(\t|$)/", $permstr);
}
$groupterms = dunserialize(getuserprofile('groupterms'));
foreach(explode("\t", $_G['member']['extgroupids']) as $extgroupid) {
if($extgroupid = intval(trim($extgroupid))) {
if($groupterms['ext'][$extgroupid] && $groupterms['ext'][$extgroupid] < TIMESTAMP){
continue;
}
$groupidarray[] = $extgroupid;
}
}
if($_G['setting']['verify']['enabled']) {
getuserprofile('verify1');
foreach($_G['setting']['verify'] as $vid => $verify) {
if($verify['available'] && $_G['member']['verify'.$vid] == 1) {
$groupidarray[] = 'v'.$vid;
}
}
}
return preg_match("/(^|\t)(".implode('|', $groupidarray).")(\t|$)/", $permstr);
}
* 论坛权限
* @param $permstr - 权限信息
* @param $groupid - 只判断用户组
* @return 0 无权限 > 0 有权限
*/
function forumperm($permstr, $groupid = 0) {
global $_G;
$groupidarray = array($_G['groupid']);
if($groupid) {
return preg_match("/(^|\t)(".$groupid.")(\t|$)/", $permstr);
}
$groupterms = dunserialize(getuserprofile('groupterms'));
foreach(explode("\t", $_G['member']['extgroupids']) as $extgroupid) {
if($extgroupid = intval(trim($extgroupid))) {
if($groupterms['ext'][$extgroupid] && $groupterms['ext'][$extgroupid] < TIMESTAMP){
continue;
}
$groupidarray[] = $extgroupid;
}
}
if($_G['setting']['verify']['enabled']) {
getuserprofile('verify1');
foreach($_G['setting']['verify'] as $vid => $verify) {
if($verify['available'] && $_G['member']['verify'.$vid] == 1) {
$groupidarray[] = 'v'.$vid;
}
}
}
return preg_match("/(^|\t)(".implode('|', $groupidarray).")(\t|$)/", $permstr);
}