Exemplo n.º 1
0
        public List <UserGroupInfo> GetAllUserGroup()
        {
            List <UserGroupInfo> list = new List <UserGroupInfo>();

            //for (int i = 0; i < 10; i++)
            //{
            //    list.Add(new UserGroupInfo
            //    {
            //        UserGroupDescription = "UserGroupDescription UserGroupInfo" + i,
            //        UserGroupID = (uint)i,
            //        UserGroupName = "UserGroupInfo" + i
            //    });
            //}
            //return list;



            int lQueryHandle = Framework.Container.Instance.IVXProtocol.QueryUserGroupList();

            while (true)
            {
                UserGroupInfo groupInfo = Framework.Container.Instance.IVXProtocol.QueryNextUserGroup(lQueryHandle);
                if (groupInfo != null)
                {
                    list.Add(groupInfo);
                }
                else
                {
                    break;
                }
            }
            Framework.Container.Instance.IVXProtocol.CloseUserGroupQuery(lQueryHandle);
            return(list);
        }
Exemplo n.º 2
0
        public uint AddUserGroup(UserGroupInfo userGroupInfo)
        {
            uint ret = Framework.Container.Instance.IVXProtocol.AddUserGroup(userGroupInfo);

            Framework.Container.Instance.EvtAggregator.GetEvent <AddUserGroupEvent>().Publish(ret);
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据积分公式更新用户积分,并且受分数变动影响有可能会更改用户所属的用户组
        /// <param name="uid">用户ID</param>
        /// </summary>
        public static int UpdateUserCredits(int uid)
        {
            UserInfo tmpUserInfo = Users.GetUserInfo(uid);

            if (tmpUserInfo == null)
            {
                return(0);
            }

            DatabaseProvider.GetInstance().UpdateUserCredits(uid, Scoresets.GetScoreCalFormula());
            tmpUserInfo = Users.GetUserInfo(uid);
            UserGroupInfo tmpUserGroupInfo = UserGroups.GetUserGroupInfo(tmpUserInfo.Groupid);

            if (tmpUserGroupInfo != null && tmpUserGroupInfo.System == 0 && tmpUserGroupInfo.Radminid == 0)
            {
                tmpUserGroupInfo = GetCreditsUserGroupID(tmpUserInfo.Credits);
                DatabaseProvider.GetInstance().UpdateUserGroup(uid, tmpUserGroupInfo.Groupid);
                OnlineUsers.UpdateGroupid(uid, tmpUserGroupInfo.Groupid);
            }
            else
            {
                //当用户是已删除的特殊组成员时,则运算相应积分,并更新该用户所属组信息
                if (tmpUserGroupInfo != null && tmpUserGroupInfo.Groupid == 7 && tmpUserInfo.Adminid == -1)
                {
                    tmpUserGroupInfo = GetCreditsUserGroupID(tmpUserInfo.Credits);
                    DatabaseProvider.GetInstance().UpdateUserGroup(uid, tmpUserGroupInfo.Groupid);
                    OnlineUsers.UpdateGroupid(uid, tmpUserGroupInfo.Groupid);
                }
            }
            return(1);
        }
Exemplo n.º 4
0
        public SingleResponeMessage <UserGroupInfo> Get(int id)
        {
            SingleResponeMessage <UserGroupInfo> ret = new SingleResponeMessage <UserGroupInfo>();

            try
            {
                UserGroupInfo item = UserGroupService.GetInstance().GetDetail(id);
                if (item == null)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "001";
                    ret.err.msgString = "no  User found";
                    return(ret);
                }
                ret.item      = item;
                ret.isSuccess = true;
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Exemplo n.º 5
0
        public static ModelAddState Add(UserGroupInfo model)
        {
            int           num = UserGroup.ExistsUserGroup(model.GroupName, model.TableName);
            ModelAddState result;

            if (num > 0)
            {
                result = (ModelAddState)num;
            }
            else
            {
                string tableName = "dbo." + model.TableName;
                int    num2      = BizBase.dbo.InsertModel <UserGroupInfo>(model);
                if (num2 > 0)
                {
                    try
                    {
                        TableManager.CreateTable(tableName, "AutoID");
                        TableManager.AddTableColumn(tableName, "UserID", "INT", false, "0");
                        UserGroup.AddDefaultField(num2);
                        CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
                        result = ModelAddState.Success;
                        return(result);
                    }
                    catch
                    {
                        result = ModelAddState.CreateTableError;
                        return(result);
                    }
                }
                CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
                result = ModelAddState.Error;
            }
            return(result);
        }
Exemplo n.º 6
0
        public static ModelDeleteStatus Delete(int modelID)
        {
            UserGroupInfo     cacheUserGroupById = UserGroup.GetCacheUserGroupById(modelID);
            ModelDeleteStatus result;

            if (cacheUserGroupById == null)
            {
                result = ModelDeleteStatus.ModelNotExists;
            }
            else if (UserGroup.IsGroupRefingByUser(modelID))
            {
                result = ModelDeleteStatus.UserRef;
            }
            else if (BizBase.dbo.DeleteModel <UserGroupInfo>(cacheUserGroupById))
            {
                BizBase.dbo.ExecSQL(" DROP TABLE " + cacheUserGroupById.TableName);
                CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
                result = ModelDeleteStatus.Success;
            }
            else
            {
                CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
                result = ModelDeleteStatus.Error;
            }
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 更新用户组信息
        /// </summary>
        /// <param name="userGroupInfo">用户组信息</param>
        /// <returns></returns>
        public static bool UpdateUserGroupInfo(UserGroupInfo userGroupInfo)
        {
            int Creditshigher = userGroupInfo.Creditshigher;
            int Creditslower  = userGroupInfo.Creditslower;

            if ((userGroupInfo.Groupid >= 9) && (userGroupInfo.Radminid == 0))
            {
                //当已存在的用户组积分上下限不是当前组的时候,则不允许编辑
                DataTable dt = Discuz.Data.UserGroups.GetUserGroupByCreditsHigherAndLower(Creditshigher, Creditslower);
                if (dt.Rows.Count > 0 && userGroupInfo.Groupid.ToString() != dt.Rows[0][0].ToString())
                {
                    return(false);
                }

                if (!SystemCheckCredits("update", ref Creditshigher, ref Creditslower, userGroupInfo.Groupid))
                {
                    return(false);
                }
            }

            UserGroups.UpdateUserGroup(userGroupInfo);
            Discuz.Data.UserGroups.UpdateOnlineList(userGroupInfo);

            Caches.ReSetAdminGroupList();
            Caches.ReSetUserGroupList();
            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 添加用户组信息
        /// </summary>
        /// <param name="userGroupInfo"></param>
        /// <returns></returns>
        public static bool AddUserGroupInfo(UserGroupInfo userGroupInfo)
        {
            try
            {
                int       Creditshigher = userGroupInfo.Creditshigher;
                int       Creditslower  = userGroupInfo.Creditslower;
                DataTable dt            = Discuz.Data.UserGroups.GetUserGroupByCreditsHigherAndLower(Creditshigher, Creditslower);
                if (dt.Rows.Count > 0)
                {
                    return(false);
                }

                if (userGroupInfo.Radminid == 0 && !SystemCheckCredits("add", ref Creditshigher, ref Creditslower, 0))
                {
                    return(false);
                }

                userGroupInfo.Creditshigher = Creditshigher;
                userGroupInfo.Creditslower  = Creditslower;
                Data.UserGroups.CreateUserGroup(userGroupInfo);
                Data.OnlineUsers.AddOnlineList(userGroupInfo.Grouptitle);

                Caches.ReSetAdminGroupList();
                Caches.ReSetUserGroupList();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 对比指定的论坛版块的新老信息,将作出相应的调整
        /// </summary>
        /// <param name="oldmoderators">老版主名称(注:用","号分割)</param>
        /// <param name="newmoderators">新版主名称(注:用","号分割)</param>
        /// <param name="currentfid">当前论坛版块的fid</param>
        public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid)
        {
            if ((oldmoderators == null) || (oldmoderators == ""))
            {
                return;
            }

            //在新的版主名单中查找老的版主是否存在
            foreach (string oldmoderator in oldmoderators.Split(','))
            {
                if ((oldmoderator != "") &&
                    ("," + newmoderators + ",").IndexOf("," + oldmoderator + ",") < 0)                     //当不存在,则表示当前老的版主已被删除,则执行删除当前老版主
                {
                    DataTable dt = DatabaseProvider.GetInstance().GetUidAdminIdByUsername(oldmoderator);
                    if (dt.Rows.Count > 0)                     //当前用户存在
                    {
                        int uid      = Convert.ToInt32(dt.Rows[0][0].ToString());
                        int radminid = Convert.ToInt32(dt.Rows[0][1].ToString());
                        dt = DatabaseProvider.GetInstance().GetUidInModeratorsByUid(currentfid, uid);

                        //在其他版块未曾设置为版主  注:(当大于0时则表示在其它版还有相应的版主身份,则不作任何处理)
                        if ((dt.Rows.Count == 0) && (radminid != 1))
                        {
                            UserInfo      __userinfo      = Users.GetUserInfo(uid);
                            UserGroupInfo __usergroupinfo = UserCredits.GetCreditsUserGroupID(__userinfo.Credits);

                            DatabaseProvider.GetInstance().UpdateUserOnlineInfo(__usergroupinfo.Groupid, uid);
                            DatabaseProvider.GetInstance().UpdateUserOtherInfo(__usergroupinfo.Groupid, uid);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        private bool SaveData()
        {
            bsGroup.EndEdit();

            if (!CheckInput())
            {
                return(false);
            }

            string strErr = string.Empty;

            if (Basic_Func.SaveUserGroup(ref _group, ref strErr))
            {
                Common.Common_Func.ErrorMessage("用户组保存成功!", "保存成功");
                bsGroup.DataSource = _group;
                InitForm();
                _back = Common.Common_Func.ConvertToModel <UserGroupInfo>(_group);
                return(true);
            }
            else
            {
                Common.Common_Func.ErrorMessage(strErr, "保存失败");
                bsGroup.DataSource = _group;
                return(false);
            }
        }
Exemplo n.º 11
0
        public static IList <UserFieldInfo> GetFieldListWithValue(int intUserID, int intGroupID)
        {
            IList <UserFieldInfo> fieldListByModelID = UserField.GetFieldListByModelID(intGroupID, true);
            IList <UserFieldInfo> usingFieldList     = UserField.GetUsingFieldList(intGroupID);
            UserGroupInfo         cacheUserGroupById = UserGroup.GetCacheUserGroupById(intGroupID);

            if (cacheUserGroupById != null)
            {
                DataTable dataTable = BizBase.dbo.GetDataTable(string.Concat(new object[]
                {
                    "SELECT * FROM cms_User AS A,",
                    cacheUserGroupById.TableName,
                    " AS B WHERE A.AutoID=",
                    intUserID,
                    " AND B.UserID=",
                    intUserID
                }));
                if (dataTable.Rows.Count == 1)
                {
                    foreach (UserFieldInfo current in fieldListByModelID)
                    {
                        if (dataTable.Columns.Contains(current.FieldName))
                        {
                            current.Value = dataTable.Rows[0][current.FieldName].ToString();
                        }
                        else
                        {
                            current.Value = current.DefaultValue;
                        }
                    }
                }
            }
            return(fieldListByModelID);
        }
Exemplo n.º 12
0
        public static bool Delete(int intPrimaryKey)
        {
            bool result;

            if (intPrimaryKey <= 0)
            {
                result = false;
            }
            else
            {
                UserInfo      dataById           = User.GetDataById(intPrimaryKey);
                UserGroupInfo cacheUserGroupById = UserGroup.GetCacheUserGroupById(dataById.GroupID);
                if (BizBase.dbo.DeleteTable("cms_User", "AutoID=" + intPrimaryKey.ToString()))
                {
                    User.Logout();
                    result = BizBase.dbo.DeleteTable(string.Concat(new object[]
                    {
                        "DELETE FROM ",
                        cacheUserGroupById.TableName,
                        " WHERE UserID=",
                        intPrimaryKey
                    }));
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Exemplo n.º 13
0
        public static bool AddCustomContent(UserGroupInfo model, IList <UserFieldInfo> fieldList)
        {
            string commandText = User.GenerateSqlOfInsert(model.TableName, fieldList);

            SqlParameter[] parameters = User.PrepareSqlParameters(fieldList);
            return(DBHelper.ExecuteNonQuery(commandText, parameters) > 0);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 根据积分获得积分用户组所应该匹配的用户组描述 (如果没有匹配项或用户非积分用户组则返回null)
        /// </summary>
        /// <param name="credits">积分</param>
        /// <returns>用户组描述</returns>
        public static UserGroupInfo GetCreditsUserGroupId(float credits)
        {
            List <UserGroupInfo> userGroupInfoList = UserGroups.GetUserGroupList();
            UserGroupInfo        tempUserGroupInfo = null;

            UserGroupInfo maxCreditGroup = null;

            foreach (UserGroupInfo userGroupInfo in userGroupInfoList)
            {
                // 积分用户组的特征是radminid等于0
                if (userGroupInfo.Radminid == 0 && userGroupInfo.System == 0 && (credits >= userGroupInfo.Creditshigher && credits <= userGroupInfo.Creditslower))
                {
                    if (tempUserGroupInfo == null || userGroupInfo.Creditshigher > tempUserGroupInfo.Creditshigher)
                    {
                        tempUserGroupInfo = userGroupInfo;
                    }
                }
                //更新积分上线最高的用户组
                if (maxCreditGroup == null || maxCreditGroup.Creditshigher < userGroupInfo.Creditshigher)
                {
                    maxCreditGroup = userGroupInfo;
                }
            }

            if (maxCreditGroup != null && maxCreditGroup.Creditshigher < credits)
            {
                tempUserGroupInfo = maxCreditGroup;
            }

            return(tempUserGroupInfo == null ? new UserGroupInfo() : tempUserGroupInfo);
        }
Exemplo n.º 15
0
        public bool EditUserGroup(UserGroupInfo userGroupInfo)
        {
            bool ret = Framework.Container.Instance.IVXProtocol.MdfUserGroup(userGroupInfo);

            Framework.Container.Instance.EvtAggregator.GetEvent <EditUserGroupEvent>().Publish(userGroupInfo.UserGroupID);
            return(ret);
        }
Exemplo n.º 16
0
 private void GetQueryMain()
 {
     if (queryMain == null)
     {
         queryMain = new UserGroupInfo();
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// 对比指定的论坛版块的新老信息,将作出相应的调整
        /// </summary>
        /// <param name="oldmoderators">老版主名称(注:用","号分割)</param>
        /// <param name="newmoderators">新版主名称(注:用","号分割)</param>
        /// <param name="currentfid">当前论坛版块的fid</param>
        public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid)
        {
            if ((oldmoderators == null) || (oldmoderators == ""))
            {
                return;
            }

            //在新的版主名单中查找老的版主是否存在
            foreach (string oldmoderator in oldmoderators.Split(','))
            {
                if ((oldmoderator != "") &&
                    ("," + newmoderators + ",").IndexOf("," + oldmoderator + ",") < 0) //当不存在,则表示当前老的版主已被删除,则执行删除当前老版主
                {
                    UserInfo info = Users.GetUserInfo(oldmoderator);
                    if (info != null) //当前用户存在
                    {
                        int       uid      = info.Uid;
                        int       radminid = info.Adminid;
                        DataTable dt       = Discuz.Data.Moderators.GetUidInModeratorsByUid(currentfid, uid);

                        //在其他版块未曾设置为版主  注:(当大于0时则表示在其它版还有相应的版主身份,则不作任何处理)
                        if ((dt.Rows.Count == 0) && (radminid != 1))
                        {
                            UserGroupInfo userGroupInfo = UserCredits.GetCreditsUserGroupId(info.Credits);

                            Discuz.Data.Users.UpdateUserOnlineInfo(userGroupInfo.Groupid, uid);
                            Discuz.Data.Users.UpdateUserOtherInfo(userGroupInfo.Groupid, uid);
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        public GroupPreviewDTO GetDTO(User user, Group group)
        {
            UserGroupInfo info = null;

            if (user != null)
            {
                info = new UserGroupInfo();
                var usergroup = group.Users.FirstOrDefault(x => x.UserId == user.Id);
                if (usergroup != null)
                {
                    info.Member = true;
                    info.Status = usergroup.Status;
                }
                else
                {
                    info.Member = false;
                }
            }
            return(new GroupPreviewDTO
            {
                Id = group.Id,
                Logo = group.Logo,
                Name = group.Name,
                Open = group.Open,
                Status = info,
                Access = new GroupAccessDTO
                {
                    CanCreateElements = SectionRules.CanCreate(user, group),
                    CanDelete = GroupRules.CanDelete(user, group),
                    CanRead = GroupRules.CanRead(user, group),
                    CanUpdate = GroupRules.CanEdit(user, group),
                    CanControlUsers = GroupRules.CanControlUsers(user, group)
                }
            });
        }
Exemplo n.º 19
0
        /// <summary>
        /// 根据积分公式更新用户积分,并且受分数变动影响有可能会更改用户所属的用户组
        /// <param name="uid">用户ID</param>
        /// </summary>
        public static int UpdateUserCredits(int uid)
        {
            ShortUserInfo userInfo = uid > 0 ? Users.GetShortUserInfo(uid) : null;

            if (userInfo != null)
            {
                Discuz.Data.UserCredits.UpdateUserCredits(uid);
                UserGroupInfo tmpUserGroupInfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);

                if (tmpUserGroupInfo != null && (UserGroups.IsCreditUserGroup(tmpUserGroupInfo) || tmpUserGroupInfo.Groupid == 7))//当用户组为积分用户组或者组ID为游客(ID=7)
                {
                    tmpUserGroupInfo = GetCreditsUserGroupId(userInfo.Credits);
                    if (tmpUserGroupInfo.Groupid != userInfo.Groupid)//当用户所属组发生变化时
                    {
                        Discuz.Data.Users.UpdateUserGroup(userInfo.Uid.ToString(), tmpUserGroupInfo.Groupid);
                        Discuz.Data.OnlineUsers.UpdateGroupid(userInfo.Uid, tmpUserGroupInfo.Groupid);
                    }
                }
                //判断操作用户是否是当前用户,如果是则更新dntusertips的cookie
                HttpCookie cookie = HttpContext.Current.Request.Cookies["dnt"];
                if (cookie != null)
                {
                    if (cookie["userid"] == uid.ToString())
                    {
                        ForumUtils.WriteUserCreditsCookie(userInfo, tmpUserGroupInfo.Grouptitle);
                    }
                }
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 根据积分获得积分用户组所应该匹配的用户组描述 (如果没有匹配项或用户非积分用户组则返回null)
        /// </summary>
        /// <param name="Credits">积分</param>
        /// <returns>用户组描述</returns>
        public static UserGroupInfo GetCreditsUserGroupId(float Credits)
        {
            List <UserGroupInfo> usergroupinfo = UserGroups.GetUserGroupList();
            UserGroupInfo        tmpitem       = null;

            UserGroupInfo maxCreditGroup = null;

            foreach (UserGroupInfo infoitem in usergroupinfo)
            {
                // 积分用户组的特征是radminid等于0
                if (infoitem.Radminid == 0 && infoitem.System == 0 && (Credits >= infoitem.Creditshigher && Credits <= infoitem.Creditslower))
                {
                    if (tmpitem == null || infoitem.Creditshigher > tmpitem.Creditshigher)
                    {
                        tmpitem = infoitem;
                    }
                }
                //更新积分上线最高的用户组
                if (maxCreditGroup == null || maxCreditGroup.Creditshigher < infoitem.Creditshigher)
                {
                    maxCreditGroup = infoitem;
                }
            }

            if (maxCreditGroup != null && maxCreditGroup.Creditshigher < Credits)
            {
                tmpitem = maxCreditGroup;
            }

            return(tmpitem == null ? new UserGroupInfo() : tmpitem);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 添加用户组信息
        /// </summary>
        /// <param name="__usergroupinfo"></param>
        /// <returns></returns>
        public static bool AddUserGroupInfo(UserGroupInfo __usergroupinfo)
        {
            try
            {
                int       Creditshigher = __usergroupinfo.Creditshigher;
                int       Creditslower  = __usergroupinfo.Creditslower;
                DataTable dt            = DatabaseProvider.GetInstance().GetUserGroupByCreditsHigherAndLower(Creditshigher, Creditslower);
                if (dt.Rows.Count > 0)
                {
                    return(false);
                }

                if (__usergroupinfo.Radminid == 0)
                {
                    if (!SystemCheckCredits("add", ref Creditshigher, ref Creditslower, 0))
                    {
                        return(false);
                    }
                }

                DatabaseProvider.GetInstance().AddUserGroup(__usergroupinfo, Creditshigher, Creditslower);

                DatabaseProvider.GetInstance().AddOnlineList(__usergroupinfo.Grouptitle);

                AdminCaches.ReSetAdminGroupList();

                AdminCaches.ReSetUserGroupList();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 更新用户组信息
        /// </summary>
        /// <param name="__usergroupinfo"></param>
        /// <returns></returns>
        public static bool UpdateUserGroupInfo(UserGroupInfo __usergroupinfo)
        {
            int Creditshigher = __usergroupinfo.Creditshigher;
            int Creditslower  = __usergroupinfo.Creditslower;

            if ((__usergroupinfo.Groupid >= 9) && (__usergroupinfo.Radminid == 0))
            {
                //当已存在的用户组积分上下限不是当前组的时候,则不允许编辑
                DataTable dt = DatabaseProvider.GetInstance().GetUserGroupByCreditsHigherAndLower(Creditshigher, Creditslower);
                if (dt.Rows.Count > 0)
                {
                    if (__usergroupinfo.Groupid.ToString() != dt.Rows[0][0].ToString())
                    {
                        return(false);
                    }
                }

                if (!SystemCheckCredits("update", ref Creditshigher, ref Creditslower, __usergroupinfo.Groupid))
                {
                    return(false);
                }
            }

            DatabaseProvider.GetInstance().UpdateUserGroup(__usergroupinfo, Creditshigher, Creditslower);

            DatabaseProvider.GetInstance().UpdateOnlineList(__usergroupinfo);

            AdminCaches.ReSetAdminGroupList();

            AdminCaches.ReSetUserGroupList();

            return(true);
        }
Exemplo n.º 23
0
        public bool GetMenuListByUserGroup(ref List <MenuInfo> modelList, UserGroupInfo UserGroup, bool IncludNoCheck, UserInfo user, ref string strError)
        {
            List <MenuInfo> lstModel = new List <MenuInfo>();

            try
            {
                using (SqlDataReader dr = _db.GetMenuListByUserGroupID(UserGroup, IncludNoCheck))
                {
                    while (dr.Read())
                    {
                        lstModel.Add(GetModelFromDataReader(dr));
                    }
                }

                modelList = lstModel;
                return(true);
            }
            catch (Exception ex)
            {
                strError = "获取用户组菜单权限列表失败!" + ex.Message + "\r\n" + ex.TargetSite;
                return(false);
            }
            finally
            {
            }
        }
Exemplo n.º 24
0
        internal SqlDataReader GetMenuListByUserGroupID(UserGroupInfo UserGroup, bool IncludNoCheck)
        {
            string strSql = string.Empty;

            if (UserGroup.ID >= 1)
            {
                strSql = string.Format("SELECT DISTINCT 2 AS IsChecked,T_Menu.* FROM T_Menu WHERE ISDEL <> 2 AND ID IN (SELECT MenuID FROM T_GroupWithMenu WHERE GroupID = {0}) ", UserGroup.ID);
                if (IncludNoCheck)
                {
                    strSql += string.Format("UNION SELECT DISTINCT 1 AS IsChecked,T_Menu.* FROM T_Menu WHERE ISDEL <> 2 AND ID NOT IN (SELECT MenuID FROM T_GroupWithMenu WHERE GroupID = {0}) ", UserGroup.ID);
                }
                strSql = string.Format("SELECT * FROM ({0}) T ORDER BY NodeLevel, NodeSort, ID ", strSql);
            }
            else
            {
                if (IncludNoCheck)
                {
                    strSql = "SELECT DISTINCT 1 AS IsChecked,T_Menu.* FROM T_Menu WHERE ISDEL <> 2 ORDER BY NodeUrl, NodeSort, ID ";
                }
                else
                {
                    strSql = "SELECT DISTINCT 2 AS IsChecked,T_Menu.* FROM T_Menu WHERE 1 = 2";
                }
            }
            return(OperationSql.ExecuteReader(CommandType.Text, strSql, null));
        }
Exemplo n.º 25
0
        public UserGroupInfo AddDefaultGroup()
        {
            var groupInfo = new UserGroupInfo(0, "默认用户组", true, "系统默认用户组", string.Empty);

            groupInfo.GroupId = Insert(groupInfo);
            return(groupInfo);
        }
Exemplo n.º 26
0
        protected override void ShowPage()
        {
            pagetitle = "查看用户信息";

            if (usergroupinfo.Allowviewpro != 1 && userid != id)
            {
                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有查看用户资料的权限", usergroupinfo.Grouptitle));
                if (userid < 1)
                {
                    needlogin = true;
                }

                return;
            }

            if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("username")) && Utils.StrIsNullOrEmpty(DNTRequest.GetString("userid")))
            {
                AddErrLine("错误的URL链接");
                return;
            }



            if (id == -1)
            {
                id = Users.GetUserId(Utils.UrlDecode(DNTRequest.GetString("username")));
            }

            if (id == -1)
            {
                AddErrLine("该用户不存在");
                return;
            }

            user = Users.GetUserInfo(id);
            if (user == null)
            {
                AddErrLine("该用户不存在");
                return;
            }

            //用户设定Email保密时,清空用户的Email属性以避免被显示
            if (user.Showemail != 1 && id != userid)
            {
                user.Email = "";
            }

            //获取积分机制和用户组信息,底层有缓存
            score     = Scoresets.GetValidScoreName();
            group     = UserGroups.GetUserGroupInfo(user.Groupid);
            admininfo = AdminUserGroups.AdminGetAdminGroupInfo(usergroupid);
            score1    = ((decimal)user.Extcredits1).ToString();
            score2    = ((decimal)user.Extcredits2).ToString();
            score3    = ((decimal)user.Extcredits3).ToString();
            score4    = ((decimal)user.Extcredits4).ToString();
            score5    = ((decimal)user.Extcredits5).ToString();
            score6    = ((decimal)user.Extcredits6).ToString();
            score7    = ((decimal)user.Extcredits7).ToString();
            score8    = ((decimal)user.Extcredits8).ToString();
        }
Exemplo n.º 27
0
        public static bool DownloadAttachment(ForumInfo forum, int userid, UserGroupInfo usergroupinfo)
        {
            bool allowdownloadattach = false;

            //当前用户是否有允许下载附件权限
            if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid))
            {
                allowdownloadattach = true;
            }
            else
            {
                if (Utils.StrIsNullOrEmpty(forum.Getattachperm)) //权限设置为空时,根据用户组权限判断
                {
                    // 验证用户是否有有允许下载附件权限
                    if (usergroupinfo.Allowgetattach == 1)
                    {
                        allowdownloadattach = true;
                    }
                }
                else if (Forums.AllowGetAttach(forum.Getattachperm, usergroupinfo.Groupid))
                {
                    allowdownloadattach = true;
                }
            }
            return(allowdownloadattach);
        }
Exemplo n.º 28
0
        public static bool PostReply(ForumInfo forum, int userid, UserGroupInfo usergroupinfo, TopicInfo topic)
        {
            bool canreply = (usergroupinfo.Radminid == 1);

            //是否有回复的权限
            if (topic.Closed == 0)
            {
                if (userid > -1 && Forums.AllowReplyByUserID(forum.Permuserlist, userid))
                {
                    canreply = true;
                }
                else
                {
                    if (Utils.StrIsNullOrEmpty(forum.Replyperm)) //权限设置为空时,根据用户组权限判断
                    {
                        // 验证用户是否有发表主题的权限
                        if (usergroupinfo.Allowreply == 1)
                        {
                            canreply = true;
                        }
                    }
                    else if (Forums.AllowReply(forum.Replyperm, usergroupinfo.Groupid))
                    {
                        canreply = true;
                    }
                }
            }
            return(canreply);
        }
Exemplo n.º 29
0
        public static IList <UserGroupInfo> GetGroupUsers()
        {
            using (AppBLL bll = new AppBLL())
            {
                SortedList <string, UserGroupInfo> sortedList = new SortedList <string, UserGroupInfo>();

                string sql = "select * from tbUserGroupInfo where UserOrGroup='0'";
                IList <UserGroupInfo> userGroups = bll.FillListByText <UserGroupInfo>(sql, null);
                foreach (var userGroup in userGroups)
                {
                    sortedList.Add(userGroup.TeacherID, userGroup);
                }

                sql = "select a.GroupID, b.*  from tbGroupInfo a, tbUserGroupInfo b where a.TeacherID=b.TeacherID";
                IList <UserGroupInfo> users = bll.FillListByText <UserGroupInfo>(sql, null);
                foreach (var userInfo in users)
                {
                    if (!string.IsNullOrEmpty(userInfo.TeacherID) && sortedList.ContainsKey(userInfo.GroupID))
                    {
                        UserGroupInfo group = sortedList[userInfo.GroupID];
                        group.Children.Add(userInfo);
                    }
                }

                return(userGroups);
            }
        }
        public void LoadUserGroupInf(int groupid)
        {
            #region 加载相关组信息

            userGroupInfo = AdminUserGroups.AdminGetUserGroupInfo(groupid);

            groupTitle.Text = Utils.RemoveFontTag(userGroupInfo.Grouptitle);

            stars.Text              = userGroupInfo.Stars.ToString();
            color.Text              = userGroupInfo.Color;
            groupavatar.Text        = userGroupInfo.Groupavatar;
            readaccess.Text         = userGroupInfo.Readaccess.ToString();
            maxprice.Text           = userGroupInfo.Maxprice.ToString();
            maxpmnum.Text           = userGroupInfo.Maxpmnum.ToString();
            maxsigsize.Text         = userGroupInfo.Maxsigsize.ToString();
            maxattachsize.Text      = userGroupInfo.Maxattachsize.ToString();
            maxsizeperday.Text      = userGroupInfo.Maxsizeperday.ToString();
            maxspaceattachsize.Text = userGroupInfo.Maxspaceattachsize.ToString();
            maxspacephotosize.Text  = userGroupInfo.Maxspacephotosize.ToString();
            //maxfriendscount.Text = userGroupInfo.MaxFriendsCount.ToString();

            radminid.SelectedValue = userGroupInfo.Radminid == -1 ? "0" : userGroupInfo.Radminid.ToString();
            ViewState["radminid"]  = userGroupInfo.Radminid;

            //DataTable dt = DbHelper.ExecuteDataset("Select id,extension  From [" + BaseConfigs.GetTablePrefix + "attachtypes]  Order By [id] ASC").Tables[0];
            DataTable dt = Attachments.GetAttachmentType();
            attachextensions.SetSelectByID(userGroupInfo.Attachextensions.Trim());

            //设置用户权限组初始化信息
            //if (__usergroupinfo.Allowvisit == 1) usergroupright.Items[0].Selected = true;
            //if (__usergroupinfo.Allowpost == 1) usergroupright.Items[1].Selected = true;
            //if (__usergroupinfo.Allowreply == 1) usergroupright.Items[2].Selected = true;
            //if (__usergroupinfo.Allowpostpoll == 1) usergroupright.Items[3].Selected = true;
            //if (__usergroupinfo.Allowgetattach == 1) usergroupright.Items[4].Selected = true;
            //if (__usergroupinfo.Allowpostattach == 1) usergroupright.Items[5].Selected = true;
            //if (__usergroupinfo.Allowvote == 1) usergroupright.Items[6].Selected = true;
            //if (__usergroupinfo.Allowsetreadperm == 1) usergroupright.Items[7].Selected = true;
            //if (__usergroupinfo.Allowsetattachperm == 1) usergroupright.Items[8].Selected = true;
            //if (__usergroupinfo.Allowhidecode == 1) usergroupright.Items[9].Selected = true;
            //if (__usergroupinfo.Allowcusbbcode == 1) usergroupright.Items[10].Selected = true;
            //if (__usergroupinfo.Allowsigbbcode == 1) usergroupright.Items[11].Selected = true;
            //if (__usergroupinfo.Allowsigimgcode == 1) usergroupright.Items[12].Selected = true;
            //if (__usergroupinfo.Allowviewpro == 1) usergroupright.Items[13].Selected = true;
            //if (__usergroupinfo.Disableperiodctrl == 1) usergroupright.Items[14].Selected = true;

            //if (__usergroupinfo.Allowsearch.ToString() == "0") allowsearch.Items[0].Selected = true;
            //if (__usergroupinfo.Allowsearch.ToString() == "1") allowsearch.Items[1].Selected = true;
            //if (__usergroupinfo.Allowsearch.ToString() == "2") allowsearch.Items[2].Selected = true;

            //if (__usergroupinfo.Allowavatar >= 0) allowavatar.Items[__usergroupinfo.Allowavatar].Selected = true;

            usergrouppowersetting.Bind(userGroupInfo);
            if (userGroupInfo.System == 1)
            {
                DeleteUserGroupInf.Enabled = false;
            }

            #endregion
        }
Exemplo n.º 31
0
        public List<UserGroupInfo> UserGroup_GetItem(int UserID)
        {
            SQLDataHelper SQLDB = new SQLDataHelper();
            SQLDB.Addparameter("@UserID", UserID);
            SqlDataReader rd = SQLDB.executereader("sp_UserGroup_GetItem", CommandType.StoredProcedure);
            List<UserGroupInfo> list = new List<UserGroupInfo>();
            UserGroupInfo item = null;
            while (rd.Read())
            {
                item = new UserGroupInfo();
                item.UserGroupID = int.Parse(rd["UserGroupID"].ToString());
                item.UserID = int.Parse(rd["UserID"].ToString());
                item.GroupID = int.Parse(rd["GroupID"].ToString());
                item.ExpiryDate = rd["ExpiryDate"].ToString();
                item.EffectiveDate = rd["EffectiveDate"].ToString();
                item.IsTrialUsed = int.Parse(rd["IsTrialUsed"].ToString());

                list.Add(item);
            }
            return list;
        }