public void RemoveTabAndLastSet(TabItemViewModel vm) { RemoveTab(vm); if (vm is VideoViewModel && VideoTabs.Count > 0) { SelectedTab = VideoTabs.FirstOrDefault(); } else if (vm is UserViewModel && UserTabs.Count > 0) { SelectedTab = UserTabs.FirstOrDefault(); } else if (vm is PublicMylistViewModel && MylistTabs.Count > 0) { SelectedTab = MylistTabs.FirstOrDefault(); } else if (vm is CommunityViewModel && CommunityTabs.Count > 0) { SelectedTab = CommunityTabs.FirstOrDefault(); } else if (vm is LiveViewModel && LiveTabs.Count > 0) { SelectedTab = LiveTabs.FirstOrDefault(); } else if (vm is PlayListViewModel && PlayListTabs.Count > 0) { SelectedTab = PlayListTabs.FirstOrDefault(); } else { SelectedTab = TabItems.Last(); } }
public void AddTab(TabItemViewModel vm) { if (vm is VideoViewModel) { VideoTabs.Add(vm); } else if (vm is UserViewModel) { UserTabs.Add(vm); } else if (vm is PublicMylistViewModel) { MylistTabs.Add(vm); } else if (vm is CommunityViewModel) { CommunityTabs.Add(vm); } else if (vm is LiveViewModel) { LiveTabs.Add(vm); } else if (vm is PlayListViewModel) { PlayListTabs.Add(vm); } else { TabItems.Add(vm); } }
protected void Page_Load(object sender, EventArgs e) { _membershipHelper = new MembershipHelper(UmbracoContext.Current); 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); } } var userCulture = UserExtensions.GetUserCulture(u.Language, Services.TextService); // Populate ui language lsit foreach (var lang in Services.TextService.GetSupportedCultures()) { var regionCode = Services.TextService.ConvertToRegionCodeFromSupportedCulture(lang); var li = new ListItem(lang.DisplayName, regionCode); if (Equals(lang, userCulture)) { 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; //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(ppAccess); userInfo.Controls.Add(ppNodes); userInfo.Controls.Add(ppModules); 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"; sectionValidator.Style.Add("color", "red"); SetupForm(); SetupChannel(); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadUsers>().Tree.Alias) .SyncTree(UID.ToString(), IsPostBack); }
private void SetupChannel() { Channel userChannel; try { userChannel = new Channel(u.Id); } catch { userChannel = new Channel(); } // Populate dropdowns foreach (DocumentType dt in DocumentType.GetAllAsList()) { cDocumentType.Items.Add( new ListItem(dt.Text, dt.Alias) ); } // populate fields ArrayList fields = new ArrayList(); cDescription.ID = "cDescription"; cCategories.ID = "cCategories"; cExcerpt.ID = "cExcerpt"; cDescription.Items.Add(new ListItem(ui.Text("choose"), "")); cCategories.Items.Add(new ListItem(ui.Text("choose"), "")); cExcerpt.Items.Add(new ListItem(ui.Text("choose"), "")); foreach (PropertyType pt in PropertyType.GetAll()) { if (!fields.Contains(pt.Alias)) { cDescription.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias)); cCategories.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias)); cExcerpt.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias)); fields.Add(pt.Alias); } } // Handle content and media pickers PlaceHolder medias = new PlaceHolder(); cMediaPicker.AppAlias = Constants.Applications.Media; cMediaPicker.TreeAlias = "media"; if (userChannel.MediaFolder > 0) { cMediaPicker.Value = userChannel.MediaFolder.ToString(); } else { cMediaPicker.Value = "-1"; } medias.Controls.Add(cMediaPicker); PlaceHolder content = new PlaceHolder(); cContentPicker.AppAlias = Constants.Applications.Content; cContentPicker.TreeAlias = "content"; if (userChannel.StartNode > 0) { cContentPicker.Value = userChannel.StartNode.ToString(); } else { cContentPicker.Value = "-1"; } content.Controls.Add(cContentPicker); // Setup the panes Pane ppInfo = new Pane(); ppInfo.addProperty(ui.Text("name", UmbracoUser), cName); ppInfo.addProperty(ui.Text("user", "startnode", UmbracoUser), content); ppInfo.addProperty(ui.Text("user", "searchAllChildren", UmbracoUser), cFulltree); ppInfo.addProperty(ui.Text("user", "mediastartnode", UmbracoUser), medias); Pane ppFields = new Pane(); ppFields.addProperty(ui.Text("user", "documentType", UmbracoUser), cDocumentType); ppFields.addProperty(ui.Text("user", "descriptionField", UmbracoUser), cDescription); ppFields.addProperty(ui.Text("user", "categoryField", UmbracoUser), cCategories); ppFields.addProperty(ui.Text("user", "excerptField", UmbracoUser), cExcerpt); TabPage channelInfo = UserTabs.NewTabPage(ui.Text("user", "contentChannel", UmbracoUser)); channelInfo.Controls.Add(ppInfo); channelInfo.Controls.Add(ppFields); if (!IsPostBack) { cName.Text = userChannel.Name; cDescription.SelectedValue = userChannel.FieldDescriptionAlias; cCategories.SelectedValue = userChannel.FieldCategoriesAlias; cExcerpt.SelectedValue = userChannel.FieldExcerptAlias; cDocumentType.SelectedValue = userChannel.DocumentTypeAlias; cFulltree.Checked = userChannel.FullTree; } }
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"); } // 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(); 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()); setupForm(); setupChannel(); if (!IsPostBack) { ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadUsers>().Tree.Alias) .SyncTree(UID.ToString(), false); } }