Example #1
0
        public static string CreateMatchToImageUrl(UserSession sessionUser, int width, int height)
        {
            string url = String.Empty;
            if (MatchmakerHelper.MatchToUsername.IsNullOrEmpty())
            {
                if (sessionUser == null)
                    url = CreateImageUrl(-1, 200, 200, false, true, true);
                else
                    url = CreateImageUrl(sessionUser.Gender == User.eGender.Male ? -1 : -2, 200, 200, false, true, true);
            }
            else
            {
                var user = User.Load(MatchmakerHelper.MatchToUsername);

                if (MatchmakerHelper.MatchToFriendImageId > 0)
                    url = CreateImageUrl(MatchmakerHelper.MatchToFriendImageId, 200, 200, false, true, true);
                else if (user.FacebookID.HasValue)
                    url = CreateFacebookImageUrl(user.FacebookID.Value, eFacebookImageType.Large);
                else
                    url = CreateImageUrl(user.Gender == User.eGender.Male ? -1 : -2, 200, 200, false, true, true);
            }
            return url;
        }
Example #2
0
        public static bool HasPermission(UserSession userSession, GroupMember groupMember, Group group, eGroupPermissionType permissionType)
        {
            bool hasNonMembersPermissions = false;
            bool hasMembersPermissions = false;
            bool hasVipMembersPermissions = false;

            switch(permissionType)
            {
                case eGroupPermissionType.ViewGroup:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewGroupNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewGroupMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewGroupVip);
                    break;
                case eGroupPermissionType.ViewMessageBoard:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewMessageBoardNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewMessageBoardMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewMessageBoardVip);
                    break;
                case eGroupPermissionType.ViewGallery:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewGalleryNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewGalleryMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewGalleryVip);
                    break;
                case eGroupPermissionType.ViewMembers:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewMembersNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewMembersMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewMembersVip);
                    break;
                case eGroupPermissionType.ViewEvents:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewEventsNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewEventsMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.ViewEventsVip);
                    break;
                case eGroupPermissionType.UploadPhoto:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.UploadPhotoNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.UploadPhotoMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.UploadPhotoVip);
                    break;
                case eGroupPermissionType.UseChat:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.UseChatNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.UseChatMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.UseChatVip);
                    break;
                case eGroupPermissionType.AddTopic:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddTopicNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddTopicMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddTopicVip);
                    break;
                case eGroupPermissionType.AddPost:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddPostNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddPostMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddPostVip);
                    break;
                case eGroupPermissionType.AddEvent:
                    hasNonMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddEventNonMembers);
                    hasMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddEventMembers);
                    hasVipMembersPermissions = group.IsPermissionEnabled(eGroupPermissions.AddEventVip);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("permissionType");
            }

            if (userSession != null)
            {
                if (groupMember == null && !hasNonMembersPermissions)
                {
                    return false;
                }
                else if (groupMember != null)
                {
                    if (!groupMember.Active)
                    {
                        if (!hasNonMembersPermissions)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if ((groupMember.Type == eType.Member && !hasMembersPermissions) ||
                            (groupMember.Type == eType.VIP && !hasVipMembersPermissions))
                        {
                            return false;
                        }
                    }
                }
            }
            else // is not logged in
            {
                if (!hasNonMembersPermissions)
                {
                    return false;
                }
            }

            return true;
        }
Example #3
0
 public static bool IsAuthorized(UserSession userSession, GroupMember groupMember, Group group)
 {
     if (userSession != null && userSession.IsAdmin())
     {
         return true;
     }
     else if (group == null || (groupMember == null && group.AccessLevel == Group.eAccessLevel.Private))
     {
         return false;
     }
     else
     {
         return true;
     }
 }
Example #4
0
 public UserWorker GetUserBackgroundWorker(HttpSessionState sessionState, UserSession userSession)
 {
     return new UserWorker(sessionState, userSession);
 }
Example #5
0
 public UserWorker(HttpSessionState sessionState, UserSession userSession)
     : this()
 {
     this.SessionState = sessionState;
     this.CurrentUserSession = userSession;
     this.DoWork += bw_FetchUserCacheData;
     //this.DoWork += bw_FetchFacebookCacheData; 
     this.RunWorkerCompleted += new RunWorkerCompletedEventHandler(completehandler);
 }
Example #6
0
        public static void UpdatePopupTips(UserSession userSession)
        {
            if (userSession == null) return;

            var langTips = TipPopup.FetchTipsByLanguage(PageBase.GetLanguageId())
                    .Where(p => p.Content.IsNotNullOrEmpty() && p.Title.IsNotNullOrEmpty()).ToList();
            langTips.ForEach(p => p.ShowPageName = p.ShowPageName
                                                    .Replace("https://", "")
                                                    .Replace("https://", "")
                                                    .Replace("lovehitch.com/", "")
                                                    .ToLower());
            userSession.ProfileTipsStatus = UserTipStatus.FetchTipStatusForUsername(userSession.Username).ToList();
            if (langTips != null && langTips.Count > 0)
            {
                var userTipIds = userSession.ProfileTipsStatus == null
                                    ? new List<int>()
                                    : userSession.ProfileTipsStatus.Select(c => c.TipId).ToList();
                var langTipIds = langTips.Select(c => c.ID).ToList();

                foreach (int id in langTipIds)
                {
                    if (!userTipIds.Contains(id))
                    {
                        UserTipStatus newTip = new UserTipStatus
                        {
                            IsBlocked = false,
                            LastViewedDate = DateTime.Now.AddMonths(-1),
                            TipId = id,
                            Username = userSession.Username,
                            ViewedTimes = 0
                        };
                        newTip.Save();
                        userSession.ProfileTipsStatus.Add(newTip);
                    }
                }
                foreach (TipPopup tip in langTips)
                {
                    var userTipStatus = userSession.ProfileTipsStatus.FirstOrDefault(c => c.TipId == tip.ID);
                    bool viewCondition = userTipStatus != null && !userTipStatus.IsBlocked
                                        && tip.ShowTimes > userTipStatus.ViewedTimes
                                        &&
                                        (tip.DaysCountTrigger <= (DateTime.Now - userTipStatus.LastViewedDate).Days
                                        || tip.LoginCountTrigger <= (DateTime.Now - userSession.LastOnline).Days
                        //|| tip.NoSpendingDaysTrigger <= userSession.Credits
                                        );
                    if (viewCondition)
                    {
                        string[] pages = tip.ShowPageName.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string page in pages)
                        {
                            if (userSession.TipsToPageViewDic.ContainsKey(page))
                            {
                                userSession.TipsToPageViewDic[page].Add(tip);
                            }
                            else
                            {
                                userSession.TipsToPageViewDic.Add(page, new List<TipPopup> { tip });
                            }
                        }
                    }
                }
            }
            var tipsStatuss = userSession.ProfileTipsStatus;
            var orderedTipsDic = new Dictionary<string, List<TipPopup>>();
            foreach (string key in userSession.TipsToPageViewDic.Keys)
            {
                orderedTipsDic.Add(key,
                    userSession.TipsToPageViewDic[key].
                    OrderBy(c => tipsStatuss.First(s => s.TipId == c.ID).LastViewedDate).
                    ToList());
            }
            userSession.TipsToPageViewDic = orderedTipsDic;
        }