protected void Page_Load(object sender, EventArgs e) { int UID = int.Parse(Request.QueryString["id"]); u = BusinessLogic.User.GetUser(UID); // do initial check for edit rights if (u.Id == 0 && CurrentUser.Id != 0) { throw new Exception("Only the root user can edit the 'root' user (id:0)"); } else if (u.IsAdmin() && !CurrentUser.IsAdmin()) { throw new Exception("Admin users can only be edited by admins"); } // check if canvas editing is enabled DefaultToLiveEditing.Visible = UmbracoSettings.EnableCanvasEditing; // Populate usertype list foreach (UserType ut in UserType.getAll) { if (CurrentUser.IsAdmin() || ut.Alias != "admin") { ListItem li = new ListItem(ui.Text("user", ut.Name.ToLower(), base.getUser()), ut.Id.ToString()); if (ut.Id == u.UserType.Id) li.Selected = true; userType.Items.Add(li); } } // Populate ui language lsit foreach ( string f in Directory.GetFiles(IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang"), "*.xml") ) { XmlDocument x = new XmlDocument(); x.Load(f); ListItem li = new ListItem(x.DocumentElement.Attributes.GetNamedItem("intName").Value, x.DocumentElement.Attributes.GetNamedItem("alias").Value); if (x.DocumentElement.Attributes.GetNamedItem("alias").Value == u.Language) li.Selected = true; userLanguage.Items.Add(li); } // Console access and disabling NoConsole.Checked = u.NoConsole; Disabled.Checked = u.Disabled; DefaultToLiveEditing.Checked = u.DefaultToLiveEditing; PlaceHolder medias = new PlaceHolder(); mediaPicker.AppAlias = "media"; mediaPicker.TreeAlias = "media"; if (u.StartMediaId > 0) mediaPicker.Value = u.StartMediaId.ToString(); else mediaPicker.Value = "-1"; medias.Controls.Add(mediaPicker); PlaceHolder content = new PlaceHolder(); contentPicker.AppAlias = "content"; contentPicker.TreeAlias = "content"; if (u.StartNodeId > 0) contentPicker.Value = u.StartNodeId.ToString(); else contentPicker.Value = "-1"; content.Controls.Add(contentPicker); // Add password changer passw.Controls.Add(new UserControl().LoadControl(SystemDirectories.Umbraco + "/controls/passwordChanger.ascx")); pp.addProperty(ui.Text("user", "username", base.getUser()), uname); pp.addProperty(ui.Text("user", "loginname", base.getUser()), lname); pp.addProperty(ui.Text("user", "password", base.getUser()), passw); pp.addProperty(ui.Text("email", base.getUser()), email); pp.addProperty(ui.Text("user", "usertype", base.getUser()), userType); pp.addProperty(ui.Text("user", "language", base.getUser()), userLanguage); //Media / content root nodes Pane ppNodes = new Pane(); ppNodes.addProperty(ui.Text("user", "startnode", base.getUser()), content); ppNodes.addProperty(ui.Text("user", "mediastartnode", base.getUser()), medias); //Generel umrbaco access Pane ppAccess = new Pane(); if (UmbracoSettings.EnableCanvasEditing) { ppAccess.addProperty(ui.Text("user", "defaultToLiveEditing", base.getUser()), DefaultToLiveEditing); } ppAccess.addProperty(ui.Text("user", "noConsole", base.getUser()), NoConsole); ppAccess.addProperty(ui.Text("user", "disabled", base.getUser()), Disabled); //access to which modules... Pane ppModules = new Pane(); ppModules.addProperty(ui.Text("user", "modules", base.getUser()), lapps); ppModules.addProperty(" ", sectionValidator); TabPage userInfo = UserTabs.NewTabPage(u.Name); userInfo.Controls.Add(pp); userInfo.Controls.Add(ppNodes); userInfo.Controls.Add(ppAccess); userInfo.Controls.Add(ppModules); userInfo.Style.Add("text-align", "center"); userInfo.HasMenu = true; ImageButton save = userInfo.Menu.NewImageButton(); save.ImageUrl = SystemDirectories.Umbraco + "/images/editor/save.gif"; save.Click += new ImageClickEventHandler(saveUser_Click); sectionValidator.ServerValidate += new ServerValidateEventHandler(sectionValidator_ServerValidate); sectionValidator.ControlToValidate = lapps.ID; sectionValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatoryWithoutTab", ui.Text("user", "modules", base.getUser()), base.getUser()); sectionValidator.CssClass = "error"; setupForm(); setupChannel(); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadUsers>().Tree.Alias) .SyncTree(UID.ToString(), IsPostBack); }
protected void Page_Load(object sender, EventArgs e) { int UID = int.Parse(Request.QueryString["id"]); u = BusinessLogic.User.GetUser(UID); //the true admin can only edit the true admin if (u.Id == 0 && CurrentUser.Id != 0) { throw new Exception("Only the root user can edit the 'root' user (id:0)"); } //only another admin can edit another admin (who is not the true admin) if (u.IsAdmin() && CurrentUser.IsAdmin() == false) { throw new Exception("Admin users can only be edited by admins"); } // Populate usertype list foreach (UserType ut in UserType.getAll) { if (CurrentUser.IsAdmin() || ut.Alias != "admin") { ListItem li = new ListItem(ui.Text("user", ut.Name.ToLower(), UmbracoUser), ut.Id.ToString()); if (ut.Id == u.UserType.Id) li.Selected = true; userType.Items.Add(li); } } // Populate ui language lsit foreach ( string f in Directory.GetFiles(IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang"), "*.xml") ) { XmlDocument x = new XmlDocument(); x.Load(f); ListItem li = new ListItem(x.DocumentElement.Attributes.GetNamedItem("intName").Value, x.DocumentElement.Attributes.GetNamedItem("alias").Value); if (x.DocumentElement.Attributes.GetNamedItem("alias").Value == u.Language) li.Selected = true; userLanguage.Items.Add(li); } // Console access and disabling NoConsole.Checked = u.NoConsole; Disabled.Checked = u.Disabled; PlaceHolder medias = new PlaceHolder(); mediaPicker.AppAlias = Constants.Applications.Media; mediaPicker.TreeAlias = "media"; if (u.StartMediaId > 0) mediaPicker.Value = u.StartMediaId.ToString(); else mediaPicker.Value = "-1"; medias.Controls.Add(mediaPicker); PlaceHolder content = new PlaceHolder(); contentPicker.AppAlias = Constants.Applications.Content; contentPicker.TreeAlias = "content"; if (u.StartNodeId > 0) contentPicker.Value = u.StartNodeId.ToString(); else contentPicker.Value = "-1"; content.Controls.Add(contentPicker); // Add password changer var passwordChanger = (passwordChanger) LoadControl(SystemDirectories.Umbraco + "/controls/passwordChanger.ascx"); passwordChanger.MembershipProviderName = UmbracoSettings.DefaultBackofficeProvider; //This is a hack to allow the admin to change a user's password to whatever they want - this will only work if we are using the // default umbraco membership provider. // See the notes below in the ChangePassword method. if (BackOfficeProvider is UsersMembershipProvider) { passwordChanger.ShowOldPassword = false; } //Add a custom validation message for the password changer var passwordValidation = new CustomValidator { ID = "PasswordChangerValidator" }; var validatorContainer = new HtmlGenericControl("div") { Visible = false, EnableViewState = false }; validatorContainer.Attributes["class"] = "alert alert-error"; validatorContainer.Style.Add(HtmlTextWriterStyle.MarginTop, "10px"); validatorContainer.Style.Add(HtmlTextWriterStyle.Width, "300px"); var validatorContainer2 = new HtmlGenericControl("p"); validatorContainer.Controls.Add(validatorContainer2); validatorContainer2.Controls.Add(passwordValidation); passw.Controls.Add(passwordChanger); passw.Controls.Add(validatorContainer); pp.addProperty(ui.Text("user", "username", UmbracoUser), uname); pp.addProperty(ui.Text("user", "loginname", UmbracoUser), lname); pp.addProperty(ui.Text("user", "password", UmbracoUser), passw); pp.addProperty(ui.Text("email", UmbracoUser), email); pp.addProperty(ui.Text("user", "usertype", UmbracoUser), userType); pp.addProperty(ui.Text("user", "language", UmbracoUser), userLanguage); //Media / content root nodes Pane ppNodes = new Pane(); ppNodes.addProperty(ui.Text("user", "startnode", UmbracoUser), content); ppNodes.addProperty(ui.Text("user", "mediastartnode", UmbracoUser), medias); //Generel umrbaco access Pane ppAccess = new Pane(); ppAccess.addProperty(ui.Text("user", "noConsole", UmbracoUser), NoConsole); ppAccess.addProperty(ui.Text("user", "disabled", UmbracoUser), Disabled); //access to which modules... Pane ppModules = new Pane(); ppModules.addProperty(ui.Text("user", "modules", UmbracoUser), lapps); ppModules.addProperty(" ", sectionValidator); TabPage userInfo = UserTabs.NewTabPage(u.Name); userInfo.Controls.Add(pp); userInfo.Controls.Add(ppNodes); userInfo.Controls.Add(ppAccess); userInfo.Controls.Add(ppModules); userInfo.Style.Add("text-align", "center"); userInfo.HasMenu = true; var save = userInfo.Menu.NewButton(); save.Click += SaveUser_Click; save.ID = "save"; save.ToolTip = ui.Text("save"); save.Text = ui.Text("save"); save.ButtonType = MenuButtonType.Primary; sectionValidator.ServerValidate += new ServerValidateEventHandler(sectionValidator_ServerValidate); sectionValidator.ControlToValidate = lapps.ID; sectionValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatoryWithoutTab", ui.Text("user", "modules", UmbracoUser), UmbracoUser); sectionValidator.CssClass = "error"; SetupForm(); SetupChannel(); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadUsers>().Tree.Alias) .SyncTree(UID.ToString(), IsPostBack); }
/// <summary> /// Appends the user to the XML document. /// </summary> /// <param name="xd">The XML document.</param> /// <param name="user">The user.</param> internal static void AppendUser(XmlDocument xd, User user) { var node = XmlHelper.AddTextNode(xd, "User", string.Empty); node.Attributes.Append(XmlHelper.AddAttribute(xd, "id", user.Id.ToString())); node.Attributes.Append(XmlHelper.AddAttribute(xd, "name", user.Name)); node.Attributes.Append(XmlHelper.AddAttribute(xd, "loginName", user.LoginName)); node.Attributes.Append(XmlHelper.AddAttribute(xd, "email", user.Email)); node.Attributes.Append(XmlHelper.AddAttribute(xd, "language", user.Language)); node.Attributes.Append(XmlHelper.AddAttribute(xd, "userTypeAlias", user.UserType.Alias)); node.Attributes.Append(XmlHelper.AddAttribute(xd, "isAdmin", user.IsAdmin().ToString())); node.Attributes.Append(XmlHelper.AddAttribute(xd, "startNodeId", user.StartNodeId.ToString())); node.Attributes.Append(XmlHelper.AddAttribute(xd, "startMediaId", user.StartMediaId.ToString())); // add the user node to the XmlDocument. if (xd.DocumentElement != null) { xd.DocumentElement.AppendChild(node); } else { xd.AppendChild(node); } }
protected void Page_Load(object sender, EventArgs e) { //set the user and check access SimpleFormsCore.Authorize(); currentUser = umbraco.BusinessLogic.User.GetCurrent(); userCanPublish = currentUser.GetPermissions(formDocument.Path).Contains('R'); //handle any postbacks if (Page.IsPostBack) { HandlePostback(); } //get the form schema formSchema = new FormSchema(template.Alias); h2 = new HtmlGenericControl("h2"); h2.InnerHtml = "<a class='formFields' href='#'>" + t("Form Fields") + "</a>"; if (currentUser.IsAdmin()) { settings.Controls.Add(h2); BuildFieldTable(); } formIDBox.Text = formSchema.ID.ToString(); formName.Text = formSchema.Name; BuildDocumentButtons(); //update the url string niceurl = umbraco.library.NiceUrl(formDocument.Id); string url = "<a target='_blank' href='" + niceurl + "'>" + niceurl + "</a>"; urlTD.InnerHtml = url; BuildSubmissionsUI(); BuildSubmissionsTable(); }