void AccountTourManage_Edit(object sender, ModuleModeEventArgs e) { SetTemplate("account_tour_edit"); Tour tour = null; /* */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* */ SelectBox yearSelectBox = new SelectBox("year"); /* */ TextBox abstractTextBox = new TextBox("abstract"); abstractTextBox.Lines = 5; abstractTextBox.IsFormatted = true; for (int i = 1980; i < DateTime.UtcNow.Year + 5; i++) { yearSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } switch (e.Mode) { case "add": yearSelectBox.SelectedKey = core.Tz.Now.Year.ToString(); break; case "edit": long tourId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); try { tour = new Tour(core, tourId); } catch (InvalidTourException) { return; } titleTextBox.Value = tour.Title; abstractTextBox.Value = tour.TourAbstract; if (yearSelectBox.ContainsKey(tour.StartYear.ToString())) { yearSelectBox.SelectedKey = tour.StartYear.ToString(); } if (core.Http.Form["title"] != null) { titleTextBox.Value = core.Http.Form["title"]; } yearSelectBox.SelectedKey = core.Functions.FormShort("year", short.Parse(yearSelectBox.SelectedKey)).ToString(); template.Parse("S_ID", tour.Id.ToString()); template.Parse("EDIT", "TRUE"); break; } template.Parse("S_TITLE", titleTextBox); template.Parse("S_ABSTRACT", abstractTextBox); template.Parse("S_YEAR", yearSelectBox); SaveItemMode(AccountTourManage_EditSave, tour); }
void AccountContactManage_AddEmail(object sender, ModuleModeEventArgs e) { SetTemplate("account_email_edit"); /**/ TextBox emailTextBox = new TextBox("email-address"); /**/ SelectBox emailTypeSelectBox = new SelectBox("phone-type"); emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Personal).ToString(), "Personal")); emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Business).ToString(), "Business")); emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Student).ToString(), "Student")); emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Other).ToString(), "Other")); switch (e.Mode) { case "add-email": break; case "edit-email": long emailId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); UserEmail email = null; if (emailId > 0) { try { email = new UserEmail(core, emailId); emailTextBox.IsDisabled = true; emailTextBox.Value = email.Email; if (emailTypeSelectBox.ContainsKey(((byte)email.EmailType).ToString())) { emailTypeSelectBox.SelectedKey = ((byte)email.EmailType).ToString(); } template.Parse("S_ID", email.Id.ToString()); } catch (InvalidUserEmailException) { return; } } else { return; } template.Parse("EDIT", "TRUE"); break; } template.Parse("S_EMAIL", emailTextBox); template.Parse("S_EMAIL_TYPE", emailTypeSelectBox); }
void AccountContactManage_AddPhone(object sender, ModuleModeEventArgs e) { SetTemplate("account_phone_edit"); /**/ TextBox phoneNumberTextBox = new TextBox("phone-number"); /* */ SelectBox phoneTypeSelectBox = new SelectBox("phone-type"); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Home).ToString(), "Home")); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Mobile).ToString(), "Mobile")); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Business).ToString(), "Business")); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.BusinessMobile).ToString(), "BusinessMobile")); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.VoIP).ToString(), "VoIP")); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Fax).ToString(), "Fax")); phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Other).ToString(), "Other")); switch (e.Mode) { case "add-phone": break; case "edit-phone": long phoneNumberId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); UserPhoneNumber phoneNumber = null; if (phoneNumberId > 0) { try { phoneNumber = new UserPhoneNumber(core, phoneNumberId); //phoneNumberTextBox.IsDisabled = true; phoneNumberTextBox.Value = phoneNumber.PhoneNumber; if (phoneTypeSelectBox.ContainsKey(((byte)phoneNumber.PhoneType).ToString())) { phoneTypeSelectBox.SelectedKey = ((byte)phoneNumber.PhoneType).ToString(); } template.Parse("S_ID", phoneNumber.Id.ToString()); } catch (InvalidUserPhoneNumberException) { } } template.Parse("EDIT", "TRUE"); break; } template.Parse("S_PHONE_NUMBER", phoneNumberTextBox); template.Parse("S_PHONE_TYPE", phoneTypeSelectBox); }
void AccountPagesWrite_Show(object sender, EventArgs e) { SetTemplate("account_write"); VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list"); javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js"); VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list"); styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css"); core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute); long pageId = 0; long pageParentId = 0; byte licenseId = 0; ushort pagePermissions = 4369; string pageTitle = (core.Http.Form["title"] != null) ? core.Http.Form["title"] : ""; string pageSlug = (core.Http.Form["slug"] != null) ? core.Http.Form["slug"] : ""; string pageText = (core.Http.Form["post"] != null) ? core.Http.Form["post"] : ""; string pagePath = ""; Classifications pageClassification = Classifications.Everyone; try { if (core.Http.Form["license"] != null) { licenseId = core.Functions.GetLicenseId(); } if (core.Http.Form["id"] != null) { pageId = long.Parse(core.Http.Form["id"]); } if (core.Http.Form["page-parent"] != null) { pageParentId = long.Parse(core.Http.Form["page-parent"]); } } catch { } if (core.Http.Query["id"] != null) { try { pageId = long.Parse(core.Http.Query["id"]); } catch { } } if (pageId > 0) { if (core.Http.Query["mode"] == "edit") { try { Page page = new Page(core, Owner, pageId); pageParentId = page.ParentId; pageTitle = page.Title; pageSlug = page.Slug; //pagePermissions = page.Permissions; licenseId = page.LicenseId; pageText = page.Body; pagePath = page.FullPath; pageClassification = page.Classification; } catch (PageNotFoundException) { DisplayGenericError(); } } } Pages myPages = new Pages(core, Owner); List<Page> pagesList = myPages.GetPages(false, true); SelectBox pagesSelectBox = new SelectBox("page-parent"); pagesSelectBox.Add(new SelectBoxItem("0", "/")); foreach (Page page in pagesList) { SelectBoxItem item = new SelectBoxItem(page.Id.ToString(), page.FullPath); pagesSelectBox.Add(item); if (pageId > 0) { if (page.FullPath.StartsWith(pagePath, StringComparison.Ordinal)) { item.Selectable = false; } } } List<string> permissions = new List<string>(); permissions.Add("Can Read"); if (pageId > 0 && pagesSelectBox.ContainsKey(pageId.ToString())) { pagesSelectBox[pageId.ToString()].Selectable = false; } pagesSelectBox.SelectedKey = pageParentId.ToString(); core.Display.ParseLicensingBox(template, "S_PAGE_LICENSE", licenseId); core.Display.ParseClassification(template, "S_PAGE_CLASSIFICATION", pageClassification); template.Parse("S_PAGE_PARENT", pagesSelectBox); //core.Display.ParsePermissionsBox(template, "S_PAGE_PERMS", pagePermissions, permissions); template.Parse("S_TITLE", pageTitle); template.Parse("S_SLUG", pageSlug); template.Parse("S_PAGE_TEXT", pageText); template.Parse("S_ID", pageId.ToString()); Save(new EventHandler(AccountPagesWrite_Save)); if (core.Http.Form["publish"] != null) { AccountPagesWrite_Save(this, new EventArgs()); } }
public static SelectBox BuildForumJumpBox(Core core, Primitive owner, long currentForum) { SelectBox sb = new SelectBox("forum"); sb.Add(new SelectBoxItem("", core.Prose.GetString("SELECT_A_FORUM"))); sb.Add(new SelectBoxItem("", "--------------------")); SelectQuery query = Item.GetSelectQueryStub(core, typeof(Forum)); query.AddCondition("forum_item_id", owner.Id); query.AddCondition("forum_item_type_id", owner.TypeId); query.AddSort(SortOrder.Ascending, "forum_order"); DataTable forumsTable = core.Db.Query(query); foreach (DataRow dr in forumsTable.Rows) { Forum forum; if (owner is UserGroup) { forum = new Forum(core, (UserGroup)owner, dr); } else { forum = new Forum(core, dr); } if (forum != null) { if (forum.Access.Can("VIEW")) { sb.Add(new SelectBoxItem(forum.Id.ToString(), forum.Title)); } } } if (sb.ContainsKey(currentForum.ToString())) { sb.SelectedKey = currentForum.ToString(); } return sb; }
void AccountForumMemberManage_Edit(object sender, ModuleModeEventArgs e) { SetTemplate("account_forum_member_edit"); long id = core.Functions.RequestLong("id", 0); ForumMember member = null; /* Signature TextBox */ TextBox signatureTextBox = new TextBox("signature"); signatureTextBox.IsFormatted = true; //signatureTextBox.IsDisabled = true; signatureTextBox.Lines = 7; /* Ranks SelectBox */ SelectBox ranksSelectBox = new SelectBox("ranks"); try { member = new ForumMember(core, Owner, id, UserLoadOptions.All); } catch (InvalidForumMemberException) { core.Functions.Generate404(); } catch (InvalidUserException) { core.Functions.Generate404(); } ranksSelectBox.Add(new SelectBoxItem("0", "None")); Dictionary<long, ForumMemberRank> ranks = ForumMemberRank.GetRanks(core, Owner); foreach (ForumMemberRank rank in ranks.Values) { ranksSelectBox.Add(new SelectBoxItem(rank.Id.ToString(), rank.RankTitleText)); } if (ranksSelectBox.ContainsKey(member.ForumRankId.ToString())) { ranksSelectBox.SelectedKey = member.ForumRankId.ToString(); } signatureTextBox.Value = member.ForumSignature; /* Parse the form fields */ template.Parse("S_USERNAME", member.UserName); template.Parse("S_RANK", ranksSelectBox); template.Parse("S_SIGNATURE", signatureTextBox); template.Parse("S_ID", id.ToString()); }