/// <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); }
/// <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); } }
/// <summary> /// 删除指定用户组 /// </summary> /// <param name="groupid"></param> /// <returns></returns> public static bool DeleteUserGroupInfo(int groupid) { try { if (DatabaseProvider.GetInstance().IsSystemOrTemplateUserGroup(groupid)) { //当为系统初始组或模板组时,则不允许删除 return(false); } //当为用户组时 if (groupid >= 9) { DataTable dt = DatabaseProvider.GetInstance().GetOthersCommonUserGroup(groupid); if (dt.Rows.Count > 1) { if (DatabaseProvider.GetInstance().GetUserGroupRAdminId(groupid) == "0") { dt = DatabaseProvider.GetInstance().GetUserGroupCreditsLowerAndHigher(groupid); int creditshigher = Convert.ToInt32(dt.Rows[0]["creditshigher"].ToString()); int creditslower = Convert.ToInt32(dt.Rows[0]["creditslower"].ToString()); SystemCheckCredits("delete", ref creditshigher, ref creditslower, groupid); } } else { if (dt.Rows.Count == 1) { //当系统删除当前组后只有一个组存在时则直接设置唯一组下限,但不修改唯一组上限的值 DatabaseProvider.GetInstance().UpdateUserGroupLowerAndHigherToLimit(Utils.StrToInt(dt.Rows[0][0], 0)); } else { //系统中用户组只有一个时 opresult = "当前用户组为系统中唯一的用户组,因此系统无法删除"; return(false); } } } DatabaseProvider.GetInstance().DeleteUserGroup(groupid); DatabaseProvider.GetInstance().DeleteAdminGroup(groupid); DatabaseProvider.GetInstance().DeleteOnlineList(groupid); AdminCaches.ReSetAdminGroupList(); AdminCaches.ReSetUserGroupList(); return(true); } catch { return(false); } }
/// <summary> /// 更新当前已设置为指定版块版主的相关用户信息. /// </summary> /// <param name="moderators">相关要设置的版主名称(注:用","号分割)</param> /// <returns>返回不存在用户的字符串</returns> public static string UpdateUserInfoWithModerator(string moderators) { moderators = moderators == null ? "" : moderators; string usernamenoexsit = ""; DataTable dt = new DataTable(); foreach (string moderator in moderators.Split(',')) { if (moderator != "") { //当用户名是系统保留的用户名,请您输入其它的用户名 if (PrivateMessages.SystemUserName == moderator) { continue; } dt = DatabaseProvider.GetInstance().GetModeratorInfo(moderator); if (dt.Rows.Count > 0) { int groupid = Convert.ToInt32(dt.Rows[0]["groupid"].ToString()); if ((groupid <= 3) && (groupid > 0)) { continue; //当为管理员,超级版主,版主时 } else { int radminid = DatabaseProvider.GetInstance().GetRadminidByGroupid(groupid); if (radminid <= 0) { DatabaseProvider.GetInstance().SetModerator(moderator); } else { continue; } } } else { usernamenoexsit = usernamenoexsit + moderator + ","; } } } AdminCaches.ReSetModeratorList(); return(usernamenoexsit); }
/// <summary> /// 向版主列表中插入相关的版主信息 /// </summary> /// <param name="fid">指定的论坛版块</param> /// <param name="moderators">相关要设置的版主名称(注:用","号分割)</param> /// <param name="displayorder">显示顺序</param> /// <param name="inherited">是否使用继承机制</param> public static void InsertForumsModerators(string fid, string moderators, int displayorder, int inherited) { moderators = moderators == null ? "" : moderators; DatabaseProvider.GetInstance().InsertForumsModerators(fid, moderators, displayorder, inherited); AdminCaches.ReSetModeratorList(); }