private void DoBanUserOperation() { string actions = string.Empty; string reason = DNTRequest.GetString("reason"); if (reason == string.Empty) { AddErrLine("请填写操作原因"); return; } switch (DNTRequest.GetInt("bantype", -1)) { case 0: //正常状态 Discuz.Forum.Users.UpdateUserGroup(operateduid, UserCredits.GetCreditsUserGroupID(operateduser.Credits).Groupid); actions = "解除禁止用户"; AddMsgLine("已根据金币将用户归组, 将返回之前页面"); break; case 1: //禁止发言 Discuz.Forum.Users.UpdateUserGroup(operateduid, 4); actions = "禁止用户发言"; AddMsgLine("已成功禁止所选用户发言, 将返回之前页面"); break; case 2: //禁止发言 Discuz.Forum.Users.UpdateUserGroup(operateduid, 5); actions = "禁止用户访问"; AddMsgLine("已成功禁止所选用户访问, 将返回之前页面"); break; default: AddErrLine("错误的禁止类型"); return; } AdminModeratorLogs.InsertLog(userid.ToString(), username, usergroupid.ToString(), usergroupinfo.Grouptitle, DNTRequest.GetIP(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "0", string.Empty, "0", string.Empty, actions, reason); RedirectURL(); }
private void DoBanUserOperation() { ispost = false; string actions = ""; string title = ""; //判断后台是否设置必须输入理由, 0-不需要 1-必须 if (usergroupinfo.Reasonpm == 1 && Utils.StrIsNullOrEmpty(DNTRequest.GetString("reason"))) { titlemessage = true; AddErrLine("请填写操作原因"); return; } int banexpirynew = DNTRequest.GetFormInt("banexpirynew", -1); string expday = (banexpirynew == 0) ? "29990101" : string.Format("{0:yyyyMMdd}", DateTime.Now.AddDays(banexpirynew)); switch (DNTRequest.GetInt("bantype", -1)) { case 0: //正常状态 //Users.UpdateUserGroup(operateduid, UserCredits.GetCreditsUserGroupId(operateduser.Credits).Groupid); Users.UpdateBanUser(CreditsFacade.GetCreditsUserGroupId(operateduser.Credits).Groupid, "0", operateduid); title = string.Format("取消对 <a href=\"../../userinfo-{1}.aspx\" target=\"_blank\">{0}</a> 的禁止", operatedusername, operateduid); actions = "取消禁止"; break; case 1: //禁止发言 //Users.UpdateUserGroup(operateduid, 4); Users.UpdateBanUser(4, expday, operateduid); title = string.Format("禁止 <a href=\"../../userinfo-{1}.aspx\" target=\"_blank\">{0}</a> 发言", operatedusername, operateduid); actions = "禁止发言"; break; case 2: //禁止访问 //Users.UpdateUserGroup(operateduid, 5); Users.UpdateBanUser(5, expday, operateduid); title = string.Format("禁止 <a href=\"../../userinfo-{1}.aspx\" target=\"_blank\">{0}</a> 访问", operatedusername, operateduid); actions = "禁止访问"; break; default: titlemessage = true; actions = "错误的禁止类型"; AddErrLine("错误的禁止类型"); return; } AdminModeratorLogs.InsertLog(userid.ToString(), username, usergroupid.ToString(), usergroupinfo.Grouptitle, DNTRequest.GetIP(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "0", "", "0", title, actions, DNTRequest.GetString("reason").Trim()); // 收件箱 //if (DNTRequest.GetFormInt("sendmessage", 0) == 1) //{ // PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); // privatemessageinfo.Message = Utils.HtmlEncode(string.Format("这是由论坛系统自动发送的通知短消息。操作理由: {0}\r\n\r\n如果您对本管理操作有异议,请与我取得联系。", DNTRequest.GetString("reason").Trim())); // privatemessageinfo.Subject = Utils.HtmlEncode("您被执行 " + actions + " 操作"); // privatemessageinfo.Msgto = operateduser.Username; // privatemessageinfo.Msgtoid = operateduid; // privatemessageinfo.Msgfrom = username; // privatemessageinfo.Msgfromid = userid; // privatemessageinfo.New = 1; // privatemessageinfo.Postdatetime = Utils.GetDateTime(); // privatemessageinfo.Folder = 0; // PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); //} ispost = true; SetShowBackLink(false); SetUrl(Utils.UrlDecode(ForumUtils.GetReUrl())); SetMetaRefresh(); MsgForward("useradmin_succeed", true); }
private bool DoOperations(ForumInfo forum, AdminGroupInfo admininfo, int reasonpm) { string operationName = ""; string next = DNTRequest.GetFormString("next"); string referer = DNTRequest.GetFormString("referer"); DataTable dt = null; #region DoOperation string reason = DNTRequest.GetString("reason"); if (operation != "identify") { if (reason.Equals("")) { AddErrLine("操作原因不能为空"); return(false); } else { if (reason.Length > 200) { AddErrLine("操作原因不能多于200个字符"); return(false); } } } if ("delete,highlight,close,movecategory".IndexOf(operation) == -1) { AddErrLine("未知的操作参数"); return(false); } //执行提交操作 if (next.Trim() != "") { referer = string.Format("goodsadmin.aspx?action={0}&categoryid={1}&goodsid={2}", next, categoryid, goodslist); } else { referer = string.Format(base.ShowGoodsListAspxRewrite(categoryid, 1)); } #region switch operation switch (operation) { case "delete": operationName = "删除商品"; if (!DoDeleteOperation(forum)) { return(false); } break; case "highlight": //设置高亮 operationName = "设置高亮"; if (!DoHighlightOperation()) { return(false); } break; case "close": operationName = "关闭商品/取消"; if (!DoCloseOperation()) { return(false); } break; case "movecategory": operationName = "移动商品"; if (!DoMoveOperation()) { return(false); } break; default: operationName = "未知操作"; break; } #endregion if (next.CompareTo("") == 0) { AddMsgLine("管理操作成功,现在将转入商品列表"); } else { AddMsgLine("管理操作成功,现在将转入后续操作"); } dt = Goods.GetGoodsList(goodslist); if (config.Modworkstatus == 1) { if (dt != null) { foreach (DataRow dr in dt.Rows) { AdminModeratorLogs.InsertLog(this.userid.ToString(), username, usergroupid.ToString(), this.usergroupinfo.Grouptitle, Utils.GetRealIP(), Utils.GetDateTime(), this.forumid.ToString(), this.forumname, dr["goodsid"].ToString(), dr["title"].ToString(), operationName, reason); if (reasonpm == 1) { int posterid = Utils.StrToInt(dr["selleruid"], -1); if (posterid != -1) //是游客,管理操作就不发短消息了 { if (PrivateMessages.GetPrivateMessageCount(posterid, -1) < UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(posterid).Groupid).Maxpmnum) { PrivateMessageInfo __privatemessageinfo = new PrivateMessageInfo(); string curdatetime = Utils.GetDateTime(); // 收件箱 __privatemessageinfo.Message = Utils.HtmlEncode( string.Format( "这是由论坛系统自动发送的通知短消息。\r\n以下您所发表的商品被 {0} {1} 执行 {2} 操作。\r\n\r\n商品: {3} \r\n操作理由: {4}\r\n\r\n如果您对本管理操作有异议,请与我取得联系。", Utils.RemoveHtml(this.usergroupinfo.Grouptitle), username, operationName, dr["title"].ToString().Trim(), reason)); __privatemessageinfo.Subject = Utils.HtmlEncode("您发表的商品被执行管理操作"); __privatemessageinfo.Msgto = dr["seller"].ToString(); __privatemessageinfo.Msgtoid = posterid; __privatemessageinfo.Msgfrom = username; __privatemessageinfo.Msgfromid = userid; __privatemessageinfo.New = 1; __privatemessageinfo.Postdatetime = curdatetime; __privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(__privatemessageinfo, 0); } } } } dt.Dispose(); } } //执行完某一操作后转到后续操作 SetUrl(referer); if (next != string.Empty) { HttpContext.Current.Response.Redirect(BaseConfigs.GetForumPath + referer, false); } else { AddScript("window.setTimeout('redirectURL()', 2000);function redirectURL() {window.location='" + referer + "';}"); } SetShowBackLink(false); #endregion return(true); }