Пример #1
0
function admin_check_allow($uid, $is_role_id = 0)
{
    global $_J;
    if (MEMBER_ID < 1) {
        return false;
    }
    if (true === JISHIGOU_FOUNDER) {
        return true;
    }
    $uid = is_numeric($uid) ? $uid : 0;
    if ($uid > 0) {
        if (!$is_role_id) {
            if ($uid == MEMBER_ID) {
                return true;
            }
            if (true === jsg_member_is_founder($uid)) {
                return false;
            }
            $info = jsg_member_info($uid);
            $role_id = $info['role_id'];
        } else {
            $role_id = $uid;
        }
        if ('normal' == $_J['member']['role_type']) {
            return false;
        }
        if ($role_id == $_J['member']['role_id']) {
            return false;
        }
        $role_info = jsg_role_info($role_id);
        if ('admin' == $role_info['type']) {
            return false;
        }
    }
    return true;
}
Пример #2
0
function jsg_role_check_allow($action, $to_uid, $from_uid = MEMBER_ID)
{
    $rets = array();
    $to_uid = is_numeric($to_uid) ? $to_uid : 0;
    $from_uid = is_numeric($from_uid) ? $from_uid : 0;
    if ($to_uid < 1 || $from_uid < 1 || $to_uid == $from_uid) {
        return $rets;
    }
    if (MEMBER_ID == $from_uid && true === JISHIGOU_FOUNDER) {
        return $rets;
    }
    $actions = array('sendpm' => '私信', 'topic_forward' => '转发', 'topic_reply' => '评论', 'topic_at' => '@', 'follow' => '关注');
    $action_name = $actions[$action];
    if (is_null($action_name)) {
        return $rets;
    }
    $to_member = jsg_member_info($to_uid);
    $from_member = jsg_member_info($from_uid);
    if ($to_member && $from_member) {
        $to_role_id = $to_member['role_id'];
        $from_role_id = $from_member['role_id'];
        $to_role = jsg_role_info($to_role_id);
        $from_role = jsg_role_info($from_role_id);
        if ($to_role && $from_role) {
            $to_field = "allow_{$action}_to";
            $from_field = "allow_{$action}_from";
            $allow_action_to = $from_role[$to_field];
            if ($allow_action_to) {
                if (-2 == $allow_action_to || !jsg_find($allow_action_to, $to_role_id)) {
                    $rets['error'] = "由于用户组权限设置,您没有 {$action_name} TA的权限";
                    return $rets;
                }
            }
        }
    }
    return $rets;
}