protected void Btn_Search_Click(object sender, EventArgs e) { if (role.SelectedValue == "用户编号") { if (TxtContent.Text.Trim() == "") { Response.Write("<script>alert('用户名不能为空!')</script>"); } else { string sql = "select ID 用户编号,userName 用户名,userRole 用户权限 from [Tb_User_Login] where ID='" + TxtContent.Text.Trim() + "'"; user Search = new user(); SqlDataReader myreader = Search.Login(sql); User_List.DataSource = myreader; User_List.DataBind(); } } else { if (TxtContent.Text.Trim() == "") { Response.Write("<script>alert('用户名不能为空!')</script>"); } else { string sql = "select ID 用户编号,userName 用户名,userRole 用户权限 from [Tb_User_Login] where userName='******'"; user Search = new user(); SqlDataReader myreader = Search.Login(sql); User_List.DataSource = myreader; User_List.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { LiHyperLink.SetNameToCompare(Context, "UserManagement"); IGraffitiUser currentUser = GraffitiUsers.Current; if (Request.QueryString["user"] != null) { if (!IsPostBack) { user = GraffitiUsers.GetUser(Request.QueryString["user"]); if (user == null) { throw new Exception("This user does not exist or cannot be edited."); } if (!GraffitiUsers.IsAdmin(currentUser) && user.Name != currentUser.Name) { throw new SecurityException("You do not have permission to edit this user"); } if (Request.QueryString["new"] != null && !IsPostBack) { Message.Text = "The user <strong>" + user.Name + "</strong> was created."; Message.Type = StatusType.Success; } PageText.Text = "Update " + user.ProperName + "'s profile."; AdminUserLinks.Visible = true; PasswordLink.NavigateUrl = string.Format("~/graffiti-admin/user-management/users/changepassword.aspx?user={0}", Request.QueryString["user"]); if (GraffitiUsers.CanRenameUsers && GraffitiUsers.IsAdmin(GraffitiUsers.Current)) { AdminUserLinksDelim.Visible = true; RenameLink.Visible = true; RenameLink.NavigateUrl = string.Format("javascript:Telligent_Modal.Open('RenameUser.aspx?user={0}', 400, 200, null);", Request.QueryString["user"]); } txtExistingUserName.Text = Server.HtmlDecode(user.Name); txtProperName.Text = Server.HtmlDecode(user.ProperName); txtExistingEmail.Text = user.Email; txtAvatar.Text = user.Avatar; Editor.Text = user.Bio; txtWebsite.Text = string.IsNullOrEmpty(user.WebSite) ? new Macros().FullUrl(new Urls().Home) : Server.HtmlEncode(user.WebSite); bool isAdmin = GraffitiUsers.IsUserInRole(GraffitiUsers.Current.Name, GraffitiUsers.AdminRole); role_section.Visible = isAdmin; AllRoles.Visible = isAdmin; if (!isAdmin) { Cancel_Edit.NavigateUrl = "~/graffiti-admin/"; } if (isAdmin) { RolePermissionsCollection rp = RolePermissionManager.GetRolePermissions(); RolePermissionsCollection newrp = new RolePermissionsCollection(); newrp.AddRange(rp); RolePermissions temp = newrp.Find(delegate(RolePermissions r) { return(r.RoleName == GraffitiUsers.EveryoneRole); }); if (temp != null) { newrp.Remove(temp); } newrp.Sort(delegate(RolePermissions rp1, RolePermissions rp2) { return(Comparer <string> .Default.Compare(rp1.RoleName, rp2.RoleName)); }); Roles.DataSource = newrp; Roles.DataBind(); foreach (string role in user.Roles) { if (role == GraffitiUsers.AdminRole) { chkAdmin.Checked = true; if (GraffitiUsers.Current.Name == user.Name) { chkAdmin.Enabled = false; } } } } } new_user_container.Visible = false; User_List.Visible = false; user_edit_form.Visible = true; } else { if (!GraffitiUsers.IsUserInRole(currentUser.Name, GraffitiUsers.AdminRole)) { Response.Redirect("?user="******"*"); User_List.DataSource = users; User_List.DataBind(); // filter out everyone if they are not a content publisher for licensing List <IGraffitiUser> filteredUsers = new List <IGraffitiUser>(); filteredUsers.AddRange(users); bool isEveryonePublisher = RolePermissionManager.IsEveryoneAContentPublisher(); if (!isEveryonePublisher) { foreach (IGraffitiUser user in users) { if (user.Roles != null && user.Roles[0] == GraffitiUsers.EveryoneRole) { filteredUsers.Remove(user); } } } } }