Ejemplo n.º 1
0
        public OnlineSettings()
        {
            StarsUpgradeValve = 4;
            DefaultOpen = true;
            ShowOnlineCount = 200;

            string iconPath = Globals.GetRelativeUrl(SystemDirecotry.Assets_OnlineIcon);

            RolesInOnline = new RoleInOnlineCollection();
            RolesInOnline.Add(new RoleInOnline(Role.Administrators.RoleID, 1, Role.Administrators.Name, UrlUtil.JoinUrl(iconPath, "admin.gif")));
            RolesInOnline.Add(new RoleInOnline(Role.SuperModerators.RoleID, 2, Role.SuperModerators.Name, UrlUtil.JoinUrl(iconPath, "supermod.gif")));//超级版主
            RolesInOnline.Add(new RoleInOnline(Role.CategoryModerators.RoleID, 3, Role.CategoryModerators.Name, UrlUtil.JoinUrl(iconPath, "sbm.gif")));//分类版主
            RolesInOnline.Add(new RoleInOnline(Role.Moderators.RoleID, 4, Role.Moderators.Name, UrlUtil.JoinUrl(iconPath, "mod.gif")));//版主
            RolesInOnline.Add(new RoleInOnline(Role.Users.RoleID, 5, Role.Users.Name, UrlUtil.JoinUrl(iconPath, "user.gif")));
            RolesInOnline.Add(new RoleInOnline(Role.Guests.RoleID, 6, Role.Guests.Name, UrlUtil.JoinUrl(iconPath, "guest.gif")));
        }
Ejemplo n.º 2
0
        public RoleInOnline GetUserRoleInOnline(int userID)
        {
            RoleInOnlineCollection rolesInOnline = AllSettings.Current.OnlineSettings.RolesInOnline;

            if (userID == 0)
            {
                return(rolesInOnline.GetValue(Role.Guests.RoleID));
            }
            else
            {
                User user = UserBO.Instance.GetUser(userID);

                if (user == null)
                {
                    return(rolesInOnline.GetValue(Role.Users.RoleID));
                }

                string roleIDString = user.Roles.GetJoinedIds();

                if (roleIDString == Role.Users.RoleID.ToString())
                {
                    return(rolesInOnline.GetValue(Role.Users.RoleID));
                }
                else
                {
                    if (!string.IsNullOrEmpty(roleIDString))
                    {
                        roleIDString = "," + roleIDString + ",";

                        foreach (RoleInOnline roleInOnline in rolesInOnline)
                        {
                            if (roleIDString.Contains("," + roleInOnline.RoleID.ToString() + ","))
                            {
                                return(roleInOnline);
                            }
                        }
                    }
                }

                //在不是游客的情况下,到了这里还没返回,oh my god,直接返回every图标吧
                return(rolesInOnline.GetValue(Role.Users.RoleID));
            }
        }
Ejemplo n.º 3
0
        protected string GetOnlineRoleImgs(string style)
        {
            if (string.IsNullOrEmpty(style))
            {
                style = "<img src=\"{0}\" border=\"0\" alt=\"{1}\" />{1}&nbsp;&nbsp;";
            }

            RoleInOnlineCollection roles = AllSettings.Current.OnlineSettings.RolesInOnline;

            StringBuilder logoUrlString = new StringBuilder();

            foreach (RoleInOnline rio in roles)
            {
                if (!string.IsNullOrEmpty(rio.LogoUrl))
                {
                    logoUrlString.AppendFormat(style, rio.LogoUrl, rio.RoleName);
                }
            }
            return(logoUrlString.ToString());
        }
        public bool SaveSettings()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("rolename", "logourl");
            RoleInOnlineCollection tempCollection = new RoleInOnlineCollection();
            RoleInOnline temp;
            foreach (Role r in RoleSettings.Roles)
            {
                if (_Request.Get(r.RoleID.ToString(), Method.Post) == "1")
                {
                    temp = GetData(r.RoleID);
                    tempCollection.Add(temp);
                }
            }

            /*注册用户和游客不能删除, 始终都必须有*/
            temp = GetData(Role.Users.RoleID);
            tempCollection.Add(temp);
            temp = GetData(Role.Guests.RoleID);
            tempCollection.Add(temp);
            /*======================================*/

            //重新排序序号, 并且避免重复
            bool flag = false;
            do
            {
                flag = false;
                for (int i = 0; i < tempCollection.Count - 1; i++)
                {
                    for (int j = i + 1; j < tempCollection.Count; j++)
                    {
                        if (tempCollection[j].SortOrder == tempCollection[i].SortOrder)
                        {
                            tempCollection[j].SortOrder++;
                            flag = true;
                        }
                    }
                }
            } while (flag);

            for (int i = 0; i < tempCollection.Count; i++)
            {
                if (string.IsNullOrEmpty(tempCollection[i].RoleName))
                {
                    msgDisplay.AddError("rolename", i, Lang_Error.Online_EmpryRoleNameError);
                }
                if (string.IsNullOrEmpty(tempCollection[i].LogoUrlSrc))
                {
                    msgDisplay.AddError("logourl", i, Lang_Error.Online_EmptyLogoUrlError);
                }
            }

            if (msgDisplay.HasAnyError())
            {
                m_RolesInOnlineList = tempCollection;
                msgDisplay.AddError(new DataNoSaveError());
            }
            else
            {
                OnlineSettings.RolesInOnline = tempCollection;
                SettingManager.SaveSettings(OnlineSettings);
                OnlineUserPool.Instance.UpdateUsersOnlineRole();
                //OnlineManager.UpdateUserOnlineRoleLogo();
            }

            return true;
        }
        public bool SaveSettings()
        {
            MessageDisplay         msgDisplay     = CreateMessageDisplay("rolename", "logourl");
            RoleInOnlineCollection tempCollection = new RoleInOnlineCollection();
            RoleInOnline           temp;

            foreach (Role r in RoleSettings.Roles)
            {
                if (_Request.Get(r.RoleID.ToString(), Method.Post) == "1")
                {
                    temp = GetData(r.RoleID);
                    tempCollection.Add(temp);
                }
            }

            /*注册用户和游客不能删除, 始终都必须有*/
            temp = GetData(Role.Users.RoleID);
            tempCollection.Add(temp);
            temp = GetData(Role.Guests.RoleID);
            tempCollection.Add(temp);
            /*======================================*/

            //重新排序序号, 并且避免重复
            bool flag = false;

            do
            {
                flag = false;
                for (int i = 0; i < tempCollection.Count - 1; i++)
                {
                    for (int j = i + 1; j < tempCollection.Count; j++)
                    {
                        if (tempCollection[j].SortOrder == tempCollection[i].SortOrder)
                        {
                            tempCollection[j].SortOrder++;
                            flag = true;
                        }
                    }
                }
            } while (flag);

            for (int i = 0; i < tempCollection.Count; i++)
            {
                if (string.IsNullOrEmpty(tempCollection[i].RoleName))
                {
                    msgDisplay.AddError("rolename", i, Lang_Error.Online_EmpryRoleNameError);
                }
                if (string.IsNullOrEmpty(tempCollection[i].LogoUrlSrc))
                {
                    msgDisplay.AddError("logourl", i, Lang_Error.Online_EmptyLogoUrlError);
                }
            }

            if (msgDisplay.HasAnyError())
            {
                m_RolesInOnlineList = tempCollection;
                msgDisplay.AddError(new DataNoSaveError());
            }
            else
            {
                OnlineSettings.RolesInOnline = tempCollection;
                SettingManager.SaveSettings(OnlineSettings);
                OnlineUserPool.Instance.UpdateUsersOnlineRole();
                //OnlineManager.UpdateUserOnlineRoleLogo();
            }

            return(true);
        }