コード例 #1
0
        //whether current user has permission to view target user's photo.
        private bool TryGetPhotoFile(UserInfo targetUser, out IFileInfo photoFile)
        {
            bool isVisible = false;

            photoFile = null;

            UserInfo       user          = UserController.Instance.GetCurrentUserInfo();
            PortalSettings settings      = PortalController.Instance.GetCurrentPortalSettings();
            var            photoProperty = targetUser.Profile.GetProperty("Photo");

            if (photoProperty != null)
            {
                isVisible = ProfilePropertyAccess.CheckAccessLevel(settings, photoProperty, user, targetUser);

                if (!string.IsNullOrEmpty(photoProperty.PropertyValue) && isVisible)
                {
                    photoFile = FileManager.Instance.GetFile(int.Parse(photoProperty.PropertyValue));
                    if (photoFile == null)
                    {
                        isVisible = false;
                    }
                }
                else
                {
                    isVisible = false;
                }
            }

            return(isVisible);
        }
コード例 #2
0
        private bool IsPicVisibleToCurrentUser(int profileUserId)
        {
            var settings    = PortalController.Instance.GetCurrentSettings();
            var profileUser = UserController.Instance.GetUser(settings.PortalId, profileUserId);

            if (profileUser == null)
            {
                return(false);
            }

            var photoProperty = profileUser.Profile.GetProperty("Photo");

            if (photoProperty == null)
            {
                return(false);
            }

            var currentUser = UserController.Instance.GetCurrentUserInfo();

            return(ProfilePropertyAccess.CheckAccessLevel((PortalSettings)settings, photoProperty, currentUser, profileUser));
        }
コード例 #3
0
        /// <summary>
        /// whether current user has permission to view target user's photo.
        /// </summary>
        /// <param name="photoFile"></param>
        /// <returns></returns>
        public bool TryGetPhotoFile(out IFileInfo photoFile)
        {
            photoFile = null;

            var settings   = PortalController.Instance.GetCurrentPortalSettings();
            var targetUser = UserController.Instance.GetUser(settings.PortalId, this.UserID);

            if (targetUser == null)
            {
                return(false);
            }

            var photoProperty = targetUser.Profile.GetProperty("Photo");

            if (photoProperty == null)
            {
                return(false);
            }

            var user      = UserController.Instance.GetCurrentUserInfo();
            var isVisible = ProfilePropertyAccess.CheckAccessLevel(settings, photoProperty, user, targetUser);

            if (!string.IsNullOrEmpty(photoProperty.PropertyValue) && isVisible)
            {
                photoFile = FileManager.Instance.GetFile(int.Parse(photoProperty.PropertyValue));
                if (photoFile == null)
                {
                    isVisible = false;
                }
            }
            else
            {
                isVisible = false;
            }

            return(isVisible);
        }