예제 #1
0
        //public static List<ModeratorInfo> GetModeratorList()
        //{
        //    var cacheService = XCache.Current;
        //    List<ModeratorInfo> list = cacheService.RetrieveObject(CacheKeys.FORUM_MODERATOR_LIST) as List<ModeratorInfo>;
        //    if (list == null)
        //    {
        //        list = BBX.Data.Moderators.GetModeratorList();
        //        XCache.Add(CacheKeys.FORUM_MODERATOR_LIST, list);
        //    }
        //    return list;
        //}

        public static bool IsModer(int adminId, int uid, int fid)
        {
            if (adminId == 0)
            {
                return(false);
            }
            if (adminId == 1 || adminId == 2)
            {
                return(true);
            }
            if (adminId == 3)
            {
                //foreach (ModeratorInfo current in Moderators.GetModeratorList())
                //{
                //    if (current.Uid == uid && current.Fid == fid)
                //    {
                //        return true;
                //    }
                //}
                if (Moderator.FindByUidAndFid(uid, fid) != null)
                {
                    return(true);
                }

                return(false);
            }
            return(false);
        }
예제 #2
0
        public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid)
        {
            if (oldmoderators == null || String.IsNullOrEmpty(oldmoderators))
            {
                return;
            }
            string[] array = oldmoderators.Split(',');
            for (int i = 0; i < array.Length; i++)
            {
                string name = array[i];
                if (name != "" && ("," + newmoderators + ",").IndexOf("," + name + ",") < 0)
                {
                    var user = User.FindByName(name);
                    if (user != null)
                    {
                        int uid     = user.ID;
                        int adminid = user.AdminID;
                        //DataTable uidInModeratorsByUid = BBX.Data.Moderators.GetUidInModeratorsByUid(currentfid, uid);
                        //if (uidInModeratorsByUid.Rows.Count == 0 && adminid != 1)
                        if (adminid != 1 && Moderator.FindByUidAndFid(uid, currentfid) == null)
                        {
                            var ug = CreditsFacade.GetCreditsUserGroupId((float)user.Credits);
                            //BBX.Data.Users.UpdateUserOnlineInfo(ug.ID, uid);
                            //BBX.Data.Users.UpdateUserOtherInfo(ug.ID, uid);
                            user.AdminID = 0;
                            user.GroupID = ug.ID;
                            user.Save();

                            var online = Online.FindByUserID(user.ID);
                            if (online != null)
                            {
                                online.AdminID = 0;
                                online.GroupID = ug.ID;
                                online.Save();
                            }
                        }
                    }
                }
            }
        }