예제 #1
0
        public ProfileVisibility Clone()
        {
            var pv = new ProfileVisibility()
            {
                VisibilityMode           = VisibilityMode,
                RoleVisibilities         = new List <RoleInfo>(RoleVisibilities),
                RelationshipVisibilities = new List <Relationship>(RelationshipVisibilities)
            };

            return(pv);
        }
예제 #2
0
 public ProfileVisibility Clone()
 {
     var pv = new ProfileVisibility()
                  {
                      VisibilityMode = VisibilityMode,
                      RoleVisibilities = new List<RoleInfo>(RoleVisibilities),
                      RelationshipVisibilities = new List<Relationship>(RelationshipVisibilities)
                  };
     return pv;
 }
        private bool HasSocialReplationship(UserInfo targetUser, UserInfo accessingUser, string extendedVisibility)
        {
            if (string.IsNullOrEmpty(extendedVisibility))
            {
                return false;
            }

            var profileVisibility = new ProfileVisibility(PortalSettings.PortalId, extendedVisibility);

            var isVisible = accessingUser.UserID == targetUser.UserID;
            if (!isVisible)
            {
                //Relationships
                foreach (var relationship in profileVisibility.RelationshipVisibilities)
                {
                    switch (relationship.RelationshipTypeId)
                    {
                        case (int)DefaultRelationshipTypes.Followers:
                            isVisible = targetUser.Social.Following != null && targetUser.Social.Following.Status == RelationshipStatus.Accepted;
                            break;
                        case (int)DefaultRelationshipTypes.Friends:
                            isVisible = targetUser.Social.Friend != null && targetUser.Social.Friend.Status == RelationshipStatus.Accepted;
                            break;
                        default:
                            isVisible = targetUser.Social.UserRelationships.Any(userRelationship =>
                                                                          (userRelationship.RelationshipId == relationship.RelationshipId
                                                                              && accessingUser.UserID == userRelationship.RelatedUserId
                                                                              && userRelationship.Status == RelationshipStatus.Accepted)
                                                                      );
                            break;
                    }

                    if (isVisible)
                    {
                        break;
                    }
                }
                //Groups/Roles
                if (profileVisibility.RoleVisibilities.Any(role => accessingUser.IsInRole(role.RoleName)))
                {
                    isVisible = true;
                }
            }

            return isVisible;
        }
예제 #4
0
		/// <summary>
		/// LoadPostData loads the Post Back Data and determines whether the value has change
		/// </summary>
		/// <param name="postDataKey">A key to the PostBack Data to load</param>
		/// <param name="postCollection">A name value collection of postback data</param>
		/// <history>
		///     [cnurse]	05/03/2006	created
		/// </history>
		public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
		{
			var dataChanged = false;
            var presentVisibility = Visibility.VisibilityMode;
            var postedValue = Convert.ToInt32(postCollection[postDataKey]);
		    var postedVisibility = (UserVisibilityMode) Enum.ToObject(typeof (UserVisibilityMode), postedValue);
            if (!presentVisibility.Equals(postedVisibility) || postedVisibility == UserVisibilityMode.FriendsAndGroups)
			{
                if (postedVisibility == UserVisibilityMode.FriendsAndGroups)
                {
                    var sb = new StringBuilder();
                    sb.Append("G:");
                    foreach (var role in User.Social.Roles)
                    {
                        if (postCollection[postDataKey + ":group_" + role.RoleID.ToString(CultureInfo.InvariantCulture)] != null)
                        {
                            sb.Append(role.RoleID.ToString(CultureInfo.InvariantCulture) + ",");
                        }
                    }

                    sb.Append(";R:");
                    foreach (var relationship in User.Social.Relationships)
                    {
                        if (postCollection[postDataKey + ":relationship_" + relationship.RelationshipId.ToString(CultureInfo.InvariantCulture)] != null)
                        {
                            sb.Append(relationship.RelationshipId.ToString(CultureInfo.InvariantCulture) + ",");
                        }
                    }
                    
                    Value = new ProfileVisibility(User.PortalID, sb.ToString())
                                    {
                                        VisibilityMode = postedVisibility
                                    };                    
                }
                else
                {
                    Value = new ProfileVisibility
                                    {
                                        VisibilityMode = postedVisibility
                                    };
                }

				dataChanged = true;
			}
			return dataChanged;
		}