Example #1
0
 public static int SetAdminGroupInfo(AdminGroupInfo admingroupsInfo, int userGroupId)
 {
     if (AdminGroups.GetAdminGroupInfo(userGroupId) != null)
     {
         return(Discuz.Data.AdminGroups.SetAdminGroupInfo(admingroupsInfo));
     }
     return(AdminGroups.CreateAdminGroupInfo(admingroupsInfo));
 }
Example #2
0
        /// <summary>
        /// 删除指定用户组
        /// </summary>
        /// <param name="groupid"></param>
        /// <returns></returns>
        new public static bool DeleteUserGroupInfo(int groupid)
        {
            try
            {
                if (Discuz.Data.UserGroups.IsSystemOrTemplateUserGroup(groupid))
                {
                    //当为系统初始组或模板组时,则不允许删除
                    return(false);
                }

                //当为用户组时
                if (groupid >= 9)
                {
                    DataTable dt = UserGroups.GetUserGroupExceptGroupid(groupid);
                    if (dt.Rows.Count > 1)
                    {
                        UserGroupInfo info = UserGroups.GetUserGroupInfo(groupid);
                        if (info.Radminid == 0)
                        {
                            int creditshigher = info.Creditshigher;
                            int creditslower  = info.Creditslower;
                            SystemCheckCredits("delete", ref creditshigher, ref creditslower, groupid);
                        }
                    }
                    else
                    {
                        if (dt.Rows.Count == 1)
                        {
                            //当系统删除当前组后只有一个组存在时则直接设置唯一组下限,但不修改唯一组上限的值
                            Data.UserGroups.UpdateUserGroupLowerAndHigherToLimit(Utils.StrToInt(dt.Rows[0][0], 0));
                        }
                        else
                        {                         //系统中用户组只有一个时
                            opresult = "当前用户组为系统中唯一的用户组,因此系统无法删除";
                            return(false);
                        }
                    }
                }
                UserGroups.DeleteUserGroupInfo(groupid);
                AdminGroups.DeleteAdminGroupInfo(short.Parse(groupid.ToString()));
                Data.OnlineUsers.DeleteOnlineByUserGroup(groupid);
                Caches.ReSetAdminGroupList();
                Caches.ReSetUserGroupList();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #3
0
 /// <summary>
 /// 设置管理组信息
 /// </summary>
 /// <param name="__admingroupsInfo">管理组信息</param>
 /// <returns>更改记录数</returns>
 public static int SetAdminGroupInfo(AdminGroupInfo admingroupsInfo, int userGroupId)
 {
     //当已有记录时
     if (AdminGroups.GetAdminGroupInfo(userGroupId) != null)
     {
         //更新相应的管理组
         return(Discuz.Data.AdminGroups.SetAdminGroupInfo(admingroupsInfo));
     }
     else
     {
         //建立相应的用户组
         return(CreateAdminGroupInfo(admingroupsInfo));
     }
 }
Example #4
0
 public static AdminGroupInfo GetAdminGroupInfo(int admingid)
 {
     if (admingid > 0)
     {
         AdminGroupInfo[] adminGroupList = AdminGroups.GetAdminGroupList();
         AdminGroupInfo[] array          = adminGroupList;
         for (int i = 0; i < array.Length; i++)
         {
             AdminGroupInfo adminGroupInfo = array[i];
             if ((int)adminGroupInfo.Admingid == admingid)
             {
                 return(adminGroupInfo);
             }
         }
     }
     return(null);
 }
Example #5
0
 /// <summary>
 /// 得到管理组字段信息
 /// </summary>
 /// <param name="groupid"></param>
 /// <returns></returns>
 public static AdminGroupInfo AdminGetAdminGroupInfo(int groupid)
 {
     return(AdminGroups.GetAdminGroupInfo(groupid));
 }