void AccountSongsManage_Add(object sender, ModuleModeEventArgs e) { SetTemplate("account_song_edit"); if (e.Mode == "edit") { Song song = null; try { song = new Song(core, core.Functions.RequestLong("id", 0)); } catch (InvalidSongException) { core.Display.ShowMessage("Error", "Cannot edit the song"); return; } template.Parse("S_TITLE", song.Title); template.Parse("S_LYRICS", song.Lyrics); template.Parse("S_MODE", "edit"); template.Parse("S_ID", song.Id.ToString()); core.Display.ParseLicensingBox(template, "S_LICENSE", song.LicenseId); } else { template.Parse("S_MODE", "add"); core.Display.ParseLicensingBox(template, "S_LICENSE", 0); } SaveMode(AccountSongsManage_Save); }
void AccountForumManage_Delete(object sender, ModuleModeEventArgs e) { SetTemplate("account_forum_delete"); long id = core.Functions.RequestLong("id", 0); template.Parse("S_ID", id); }
void AccountSecurity_Disable(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); LoggedInMember.UserInfo.TwoFactorAuthVerified = false; LoggedInMember.UserInfo.Update(); SetRedirectUri(BuildUri("security")); }
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 AccountMembersManage_Leave(object sender, ModuleModeEventArgs e) { MusicianMember member = new MusicianMember(core, (Musician)Owner, core.Functions.RequestLong("id", 0)); if (member.Musician.Id != Owner.Id) { return; } if (member.Id == LoggedInMember.Id) { } }
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()); }
void AccountForumRanks_Add(object sender, ModuleModeEventArgs e) { SetTemplate("account_forum_rank_edit"); /* Title TextBox */ TextBox titleTextBox = new TextBox("rank-title"); /* Minimum Posts (to attain rank) TextBox */ TextBox minPostsTextBox = new TextBox("min-posts"); /* Special Rank TextBox */ CheckBox specialCheckBox = new CheckBox("special"); if (e.Mode == "edit") { template.Parse("EDIT", "TRUE"); long id = core.Functions.RequestLong("id", 0); if (id == 0) { core.Functions.Generate404(); return; } try { ForumMemberRank fmr = new ForumMemberRank(core, id); titleTextBox.Value = fmr.RankTitleText; minPostsTextBox.Value = fmr.RankPosts.ToString(); specialCheckBox.IsChecked = fmr.RankSpecial; template.Parse("S_ID", fmr.RankId.ToString()); } catch (InvalidForumMemberRankException) { core.Functions.Generate404(); return; } } /* Parse the form fields */ template.Parse("S_TITLE", titleTextBox); template.Parse("S_MINIMUM_POSTS", minPostsTextBox); template.Parse("S_SPECIAL", specialCheckBox); }
void AccountNavigationTabs_Add(object sender, ModuleModeEventArgs e) { SetTemplate("account_navigation_tab_add"); Pages myPages = new Pages(core, Owner); List<Page> pagesList = myPages.GetPages(false, true); Dictionary<string, string> pages = new Dictionary<string, string>(); List<string> disabledItems = new List<string>(); foreach (Page page in pagesList) { pages.Add(page.Id.ToString(), page.FullPath); } ParseSelectBox("S_PAGE_LIST", "page-id", pages, ""); }
void AccountDiscographyManage_Edit(object sender, ModuleModeEventArgs e) { SetTemplate("account_discography_album_edit"); /* */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 63; /* */ SelectBox releaseTypeSelectBox = new SelectBox("release-type"); releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Demo).ToString(), "Demo")); releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Single).ToString(), "Single")); releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Album).ToString(), "Album")); releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.EP).ToString(), "EP")); releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.DVD).ToString(), "DVD")); releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Compilation).ToString(), "Compilation")); switch (e.Mode) { case "add": releaseTypeSelectBox.SelectedKey = ((byte)ReleaseType.Demo).ToString(); break; case "edit": long releaseId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); Release release = null; try { release = new Release(core, releaseId); titleTextBox.Value = release.Title; releaseTypeSelectBox.SelectedKey = ((byte)release.ReleaseType).ToString(); } catch (InvalidReleaseException) { return; } break; } template.Parse("S_TITLE", titleTextBox); SaveMode(AccountDiscographyManage_EditSave); }
void AccountEnterpriseResourcePlanningDocumentTemplates_Edit(object sender, ModuleModeEventArgs e) { SetTemplate("account_erp_document_templates_edit"); SaveMode(AccountEnterpriseResourcePlanningDocumentTemplates_Edit_Save); TextBox titleTextBox = new TextBox("title"); TextBox descriptionTextBox = new TextBox("description"); descriptionTextBox.Lines = 5; switch (e.Mode) { case "add": break; case "edit": long templateId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); DocumentTemplate documentTemplate = null; try { documentTemplate = new DocumentTemplate(core, templateId); } catch { core.Functions.Generate404(); return; } if (documentTemplate != null) { if (!documentTemplate.Owner.Equals(Owner)) { core.Functions.Generate403(); } titleTextBox.Value = documentTemplate.Title; descriptionTextBox.Value = documentTemplate.Description; template.Parse("S_ID", documentTemplate.Id); } break; } template.Parse("S_TITLE", titleTextBox); template.Parse("S_DESCRIPTION", descriptionTextBox); }
void McpMain_Delete(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); long topicId = core.Functions.FormLong("t", 0); long updated = 0; ForumTopic topic = null; if (topicId > 0) { try { topic = new ForumTopic(core, topicId); } catch (InvalidTopicException) { return; } if (topic.Forum.Access.Can("DELETE_TOPICS")) { // TODO: statistics updating //topic.Delete(); } } else { // Not deleting a single topic, locking from the MCP List<long> topicIds = core.Functions.FormLongArray("checkbox"); } core.Display.ShowMessage("Locked", "The selected topics (" + updated.ToString() + ") have been deleted."); SetRedirectUri(BuildUri()); }
void AccountContactManage_EditAddress(object sender, ModuleModeEventArgs e) { SetTemplate("account_address_edit"); User user = LoggedInMember; /* */ TextBox addressLine1TextBox = new TextBox("address-1"); addressLine1TextBox.Value = user.Profile.AddressLine1; /* */ TextBox addressLine2TextBox = new TextBox("address-2"); addressLine2TextBox.Value = user.Profile.AddressLine2; /* */ TextBox townTextBox = new TextBox("town"); townTextBox.Value = user.Profile.AddressTown; /* */ TextBox stateTextBox = new TextBox("state"); stateTextBox.Value = user.Profile.AddressState; /* */ TextBox postCodeTextBox = new TextBox("post-code"); postCodeTextBox.MaxLength = 5; postCodeTextBox.Value = user.Profile.AddressPostCode; /* */ SelectBox countrySelectBox = new SelectBox("country"); List<Country> countries = new List<Country>(); SelectQuery query = Item.GetSelectQueryStub(core, typeof(Country)); query.AddSort(SortOrder.Ascending, "country_name"); DataTable countryDataTable = db.Query(query); foreach (DataRow dr in countryDataTable.Rows) { countries.Add(new Country(core, dr)); } foreach (Country country in countries) { countrySelectBox.Add(new SelectBoxItem(country.Iso, country.Name)); } if (user.Profile.CountryIso != null) { countrySelectBox.SelectedKey = user.Profile.CountryIso; } template.Parse("S_ADDRESS_LINE_1", addressLine1TextBox); template.Parse("S_ADDRESS_LINE_2", addressLine2TextBox); template.Parse("S_TOWN", townTextBox); template.Parse("S_STATE", stateTextBox); template.Parse("S_POST_CODE", postCodeTextBox); template.Parse("S_COUNTRY", countrySelectBox); }
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 AccountContactManage_AddLink(object sender, ModuleModeEventArgs e) { SetTemplate("account_link_edit"); /**/ TextBox linkAddressTextBox = new TextBox("link-address"); /* */ TextBox linkTitleTextBox = new TextBox("link-title"); switch (e.Mode) { case "add-link": break; case "edit-link": long linkId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); UserLink link = null; if (linkId > 0) { try { link = new UserLink(core, linkId); //phoneNumberTextBox.IsDisabled = true; linkAddressTextBox.Value = link.LinkAddress; linkAddressTextBox.IsDisabled = true; linkTitleTextBox.Value = link.Title; template.Parse("S_ID", link.Id.ToString()); } catch (InvalidUserLinkException) { } } template.Parse("EDIT", "TRUE"); break; } template.Parse("S_LINK", linkAddressTextBox); template.Parse("S_TITLE", linkTitleTextBox); }
void AccountEnterpriseResourcePlanningDocumentTemplates_Edit_Save(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); }
private void AccountCompose_Reply(object sender, ModuleModeEventArgs e) { SaveMode(AccountCompose_ReplySave); }
void AccountGalleriesManage_New(object sender, ModuleModeEventArgs e) { SetTemplate("account_galleries_add"); long galleryId = core.Functions.RequestLong("id", 0); bool edit = false; if (e.Mode == "edit") { edit = true; } List<string> permissions = new List<string>(); permissions.Add("Can Read"); permissions.Add("Can Comment"); if (!edit) { if (galleryId > 0) { try { Gallery pg = new Gallery(core, Owner, galleryId); Dictionary<string, string> licenses = new Dictionary<string, string>(); DataTable licensesTable = db.Query("SELECT license_id, license_title FROM licenses"); } catch (InvalidGalleryException) { core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser."); return; } } else { // New Gallery } } else { // edit template.Parse("EDIT", "TRUE"); try { Gallery ug = new Gallery(core, Owner, galleryId); template.Parse("S_TITLE", ug.GalleryTitle); template.Parse("S_DESCRIPTION", ug.GalleryAbstract); Dictionary<string, string> licenses = new Dictionary<string, string>(); DataTable licensesTable = db.Query("SELECT license_id, license_title FROM licenses"); } catch (InvalidGalleryException) { core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser."); return; } } template.Parse("S_GALLERY_ID", galleryId.ToString()); Save(new EventHandler(AccountGalleriesManage_Save)); }
void AccountForumManage_Move(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); long forumId = core.Functions.RequestLong("id", 0); Forum forum; try { forum = new Forum(core, forumId); } catch (InvalidForumException) { DisplayGenericError(); return; } switch (e.Mode) { case "move-up": forum.MoveUp(); core.Display.ShowMessage("Forum moved up", "You have moved the forum up in the list."); break; case "move-down": forum.MoveDown(); core.Display.ShowMessage("Forum moved down", "You have moved the forum down in the list."); break; } }
void AccountBlogRoll_New(object sender, ModuleModeEventArgs e) { SetTemplate("account_blog_roll_new"); BlogRollEntry bre = null; long id = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); string title = core.Http.Form["title"]; string uri = core.Http.Form["uri"]; if (e.Mode == "new") { } else if (e.Mode == "edit") { if (id > 0) { try { bre = new BlogRollEntry(core, id); title = bre.Title; uri = bre.EntryUri; template.Parse("S_ID", id.ToString()); template.Parse("EDIT", "TRUE"); } catch (InvalidBlogEntryException) { DisplayGenericError(); return; } } else { DisplayGenericError(); return; } } template.Parse("S_TITLE", title); template.Parse("S_URI", uri); SaveItemMode(new ItemModuleModeHandler(AccountBlogRoll_SaveNew), bre); }
void AccountNavigationTabs_Move(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); long tabId = core.Functions.RequestLong("id", 0); try { NagivationTab tab = new NagivationTab(core, tabId); switch (e.Mode) { case "move-up": tab.MoveUp(); SetRedirectUri(BuildUri()); core.Display.ShowMessage("Tab Moved", "You have successfully moved the tab up one place."); break; case "move-down": tab.MoveDown(); SetRedirectUri(BuildUri()); core.Display.ShowMessage("Tab Moved", "You have successfully moved the tab down one place."); break; } } catch (InvalidNavigationTabException) { DisplayGenericError(); } }
void AccountNavigationTabs_Delete(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); long tabId = core.Functions.RequestLong("id", core.Functions.FormLong("id", 0)); Dictionary<string, string> hiddenFields = new Dictionary<string, string>(); hiddenFields.Add("key", ModuleKey); hiddenFields.Add("sub", Key); hiddenFields.Add("mode", "delete"); if (core.Display.ShowConfirmBox(core.Hyperlink.AppendSid(Owner.AccountUriStub, true), "Delete?", "Are you sure you want to delete this tab?", hiddenFields) == ConfirmBoxResult.Yes) { try { NagivationTab tab = new NagivationTab(core, tabId); tab.Delete(); SetRedirectUri(BuildUri()); core.Display.ShowMessage("Tab Deleted", "You have successfully deleted the navigation tab."); } catch (InvalidNavigationTabException) { DisplayGenericError(); } } else { SetRedirectUri(BuildUri()); core.Display.ShowMessage("Tab Not Deleted", "You have aborted deleting the navigation tab."); } }
void AccountCompose_ReplySave(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); bool ajax = false; try { ajax = bool.Parse(core.Http["ajax"]); } catch { } long messageId = core.Functions.FormLong("id", 0); long newestId = core.Functions.FormLong("newest-id", 0); string text = core.Http.Form["message"]; Message threadStart = new Message(core, messageId); Message newMessage = Message.Reply(core, LoggedInMember, threadStart, text); if (ajax) { Template template = new Template(core.CallingApplication.Assembly, "pane_message"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); MessageRecipient recipient = new MessageRecipient(core, core.Session.LoggedInMember, messageId); template.Parse("S_ID", threadStart.Id.ToString()); List<Message> messages = threadStart.GetMessages(newestId, true); // IF NOT DELETED THEN foreach (Message message in messages) { AccountMessage.RenderMessage(core, template, message); newestId = message.Id; } threadStart.MarkRead(); Dictionary<string, string> returnValues = new Dictionary<string, string>(); returnValues.Add("update", "true"); returnValues.Add("message", newMessage.Text); returnValues.Add("template", template.ToString()); returnValues.Add("newest-id", newestId.ToString()); core.Response.SendDictionary("replySent", returnValues); } else { SetRedirectUri(BuildUri("inbox")); core.Display.ShowMessage("Message sent", "Your mail message has been sent."); } }
void AccountContactManage_VerifyEmail(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); UserEmail email = new UserEmail(core, core.Functions.RequestLong("id", 0)); if (email.UserId == LoggedInMember.Id) { if (!email.IsActivated) { string activateKey = User.GenerateActivationSecurityToken(); string activateUri = string.Format("http://" + Hyperlink.Domain + "/register/?mode=activate-email&id={0}&key={1}", email.Id, activateKey); UpdateQuery query = new UpdateQuery(typeof(UserEmail)); query.AddField("email_activate_code", activateKey); query.AddCondition("email_id", email.Id); core.Db.Query(query); Template emailTemplate = new Template(core.Http.TemplateEmailPath, "email_activation.html"); emailTemplate.Parse("TO_NAME", Owner.DisplayName); emailTemplate.Parse("U_ACTIVATE", activateUri); emailTemplate.Parse("USERNAME", ((User)Owner).UserName); core.Email.SendEmail(email.Email, core.Settings.SiteTitle + " email activation", emailTemplate); SetRedirectUri(BuildUri()); core.Display.ShowMessage("Verification e-mail send", "A verification code has been sent to the e-mail address along with verification instructions."); } else { SetRedirectUri(BuildUri()); core.Display.ShowMessage("Already verified", "You have already verified your email address."); } } else { SetRedirectUri(BuildUri()); core.Display.ShowMessage("Error", "An error has occured."); } }
void AccountSongsManage_Save(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); if (e.Mode == "edit") { Song song = null; try { song = new Song(core, core.Functions.FormLong("id", 0)); } catch (InvalidSongException) { core.Display.ShowMessage("Error", "Cannot edit the song"); return; } song.Title = core.Http.Form["title"]; song.Lyrics = core.Http.Form["lyrics"]; song.LicenseId = core.Functions.GetLicenseId(); try { song.Update(); } catch (UnauthorisedToUpdateItemException) { core.Display.ShowMessage("Unauthorised", "Unauthorised to update song"); return; } this.SetRedirectUri(BuildUri("songs")); core.Display.ShowMessage("Song Saved", "The song has been updated in the database."); } else { Song song = Song.Create(core, (Musician)Owner, core.Http.Form["title"], core.Http.Form["lyrics"], core.Functions.GetLicenseId()); this.SetRedirectUri(BuildUri("songs")); core.Display.ShowMessage("Song Saved", "The song has been saved in the database."); } }
void AccountContactManage_VerifyPhone(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); SetTemplate("account_phone_verify"); UserPhoneNumber phoneNumber = new UserPhoneNumber(core, core.Functions.RequestLong("id", 0)); if (phoneNumber.UserId == LoggedInMember.Id) { if (!phoneNumber.Validated) { string activateKey = User.GeneratePhoneActivationToken(); UpdateQuery query = new UpdateQuery(typeof(UserPhoneNumber)); query.AddField("phone_activate_code", activateKey); query.AddCondition("phone_id", phoneNumber.Id); core.Db.Query(query); core.Sms.SendSms(phoneNumber.PhoneNumber, string.Format("Your {0} security code is {1}.", core.Settings.SiteTitle, activateKey)); TextBox verifyTextBox = new TextBox("verify-code"); verifyTextBox.Type = InputType.Telephone; template.Parse("S_ID", phoneNumber.Id.ToString()); template.Parse("PHONE_NUMBER", phoneNumber.PhoneNumber); template.Parse("S_VERIFY_CODE", verifyTextBox); } else { SetRedirectUri(BuildUri()); core.Display.ShowMessage("Already verified", "You have already verified your phone number."); } } else { SetRedirectUri(BuildUri()); core.Display.ShowMessage("Error", "An error has occured."); } }
void AccountForumManage_New(object sender, ModuleModeEventArgs e) { SetTemplate("account_forum_edit"); long id = core.Functions.RequestLong("id", 0); /* Forum Types SelectBox */ SelectBox forumTypesSelectBox = new SelectBox("type"); Dictionary<string, string> forumTypes = new Dictionary<string, string>(); forumTypesSelectBox.Add(new SelectBoxItem("FORUM", "Forum")); forumTypesSelectBox.Add(new SelectBoxItem("CAT", "Category")); //forumTypes.Add("LINK", "Link"); /* Forum Types SelectBox */ SelectBox forumParentSelectBox = new SelectBox("parent"); /* Title TextBox */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* Description TextBox */ TextBox descriptionTextBox = new TextBox("description"); descriptionTextBox.IsFormatted = true; descriptionTextBox.Lines = 6; /* Rules TextBox */ TextBox rulesTextBox = new TextBox("rules"); rulesTextBox.IsFormatted = true; rulesTextBox.Lines = 6; ForumSettings settings = new ForumSettings(core, Owner); List<Forum> forums = settings.GetForums(); forumParentSelectBox.Add(new SelectBoxItem("0", "")); foreach (Forum forum in forums) { string levelString = string.Empty; for (int i = 0; i < forum.Level; i++) { levelString += "--"; } SelectBoxItem item = new SelectBoxItem(forum.Id.ToString(), levelString + " " + forum.Title); if (forum.Id == id && e.Mode == "edit") { item.Selectable = false; } forumParentSelectBox.Add(item); } switch (e.Mode) { case "new": forumTypesSelectBox.SelectedKey = "FORUM"; template.Parse("S_ID", id.ToString()); forumParentSelectBox.SelectedKey = id.ToString(); break; case "edit": try { Forum forum = new Forum(core, id); string type = "FORUM"; if (forum.IsCategory) { type = "CAT"; } titleTextBox.Value = forum.Title; forumParentSelectBox.SelectedKey = forum.ParentId.ToString(); descriptionTextBox.Value = forum.Description; rulesTextBox.Value = forum.Rules; template.Parse("S_ID", forum.Id.ToString()); List<string> disabledItems = new List<string>(); forumTypesSelectBox["FORUM"].Selectable = false; forumTypesSelectBox["CAT"].Selectable = false; //forumTypesSelectBox["LINK"].Selectable = false; forumTypesSelectBox.SelectedKey = type; template.Parse("EDIT", "TRUE"); } catch (InvalidForumException) { DisplayGenericError(); } break; } /* Parse the form fields */ template.Parse("S_TITLE", titleTextBox); template.Parse("S_DESCRIPTION", descriptionTextBox); template.Parse("S_RULES", rulesTextBox); template.Parse("S_FORUM_TYPE", forumTypesSelectBox); template.Parse("S_FORUM_PARENT", forumParentSelectBox); }
void AccountCalendarEventInvite_StatusChanged(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); long eventId = core.Functions.RequestLong("id", 0); if (eventId > 0) { Event calendarEvent = new Event(core, eventId); EventInvite invite = new EventInvite(core, eventId, LoggedInMember); UpdateQuery uQuery = new UpdateQuery(typeof(EventInvite)); UpdateQuery uEventQuery = new UpdateQuery(typeof(Event)); uEventQuery.AddCondition("event_id", eventId); switch (e.Mode) { case "accept": uQuery.AddField("invite_accepted", true); uQuery.AddField("invite_status", (byte)EventAttendance.Yes); switch (invite.InviteStatus) { case EventAttendance.Yes: break; case EventAttendance.Maybe: uEventQuery.AddField("event_maybes", new QueryOperation("event_maybes", QueryOperations.Subtraction, 1)); break; default: break; } if (invite.InviteStatus != EventAttendance.Yes) { uEventQuery.AddField("event_attendees", new QueryOperation("event_attendees", QueryOperations.Addition, 1)); } break; case "reject": uQuery.AddField("invite_accepted", false); uQuery.AddField("invite_status", (byte)EventAttendance.No); switch (invite.InviteStatus) { case EventAttendance.Yes: uEventQuery.AddField("event_attendees", new QueryOperation("event_attendees", QueryOperations.Subtraction, 1)); break; case EventAttendance.Maybe: uEventQuery.AddField("event_maybes", new QueryOperation("event_maybes", QueryOperations.Subtraction, 1)); break; default: break; } break; case "maybe": uQuery.AddField("invite_accepted", false); uQuery.AddField("invite_status", (byte)EventAttendance.Maybe); switch (invite.InviteStatus) { case EventAttendance.Yes: uEventQuery.AddField("event_attendees", new QueryOperation("event_attendees", QueryOperations.Subtraction, 1)); break; default: break; } if (invite.InviteStatus != EventAttendance.Maybe) { uEventQuery.AddField("event_maybes", new QueryOperation("event_maybes", QueryOperations.Addition, 1)); } break; default: DisplayGenericError(); return; } // TODO: look into this uQuery.AddCondition("event_id", eventId); uQuery.AddCondition("item_id", LoggedInMember.Id); uQuery.AddCondition("item_type_id", LoggedInMember.TypeId); db.BeginTransaction(); db.Query(uQuery); db.Query(uEventQuery); SetRedirectUri(calendarEvent.Uri); switch (e.Mode) { case "accept": core.Display.ShowMessage("Invitation Accepted", "You have accepted the invitation to this event."); break; case "maybe": core.Display.ShowMessage("Invitation Acknowledged", "You have indicated you may go to this event."); break; case "reject": core.Display.ShowMessage("Invitation Rejected", "You have rejected the invitation to this event."); break; } return; } else { core.Display.ShowMessage("Invalid submission", "You have made an invalid form submission."); return; } }
void AccountDiscographyManage_EditSave(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); string title = Functions.TrimStringToWord(core.Http.Form["title"], 63); ReleaseType releaseType = (ReleaseType)core.Functions.FormByte("release-type", (byte)ReleaseType.Demo); Release release = null; switch (e.Mode) { case "add": // TODO: release = Release.Create(core, (Musician)Owner, releaseType, title, -1); SetRedirectUri(BuildUri()); break; case "edit": long releaseId = core.Functions.FormLong("id", 0); try { release = new Release(core, releaseId); } catch (InvalidReleaseException) { // TODO: throw exception return; } if (release.Musician.Id != Owner.Id) { // TODO: throw exception return; } release.Title = title; release.ReleaseType = releaseType; release.Update(); SetInformation("Release information updated"); break; } }
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 AccountDiscographyManage_Delete(object sender, ModuleModeEventArgs e) { }