Esempio n. 1
0
        /// <summary>
        /// 检索隐私配置,当前 viewer 对 owner 的某个item是否具有访问权限
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public Boolean HasPrivacyPermission(IMember owner, String item)
        {
            // 自己总可以访问
            if (this.Id == owner.Id)
            {
                return(true);
            }

            User target = owner as User;

            if (target == null)
            {
                return(true);
            }

            int val = UserSecurity.GetPrivacy(target, item);

            if (val == UserPrivacy.EveryOne)
            {
                return(true);
            }
            if (val == UserPrivacy.Self)
            {
                return(this.Id == owner.Id);
            }
            if (val == UserPrivacy.Friend)
            {
                return(IsFriend(owner.Id));
            }
            if (val == UserPrivacy.LoginUser)
            {
                return(IsLogin);
            }

            return(true);
        }