protected void Send_Click(object sender, EventArgs e) { try { // get "to" user... MembershipUser toUser = UserMembershipHelper.GetMembershipUser(UserID); // send it... SendMail.Send(new System.Net.Mail.MailAddress(PageContext.User.Email, PageContext.User.UserName), new System.Net.Mail.MailAddress(toUser.Email.Trim(), toUser.UserName.Trim()), Subject.Text.Trim(), Body.Text.Trim()); // redirect to profile page... YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.profile, "u={0}", UserID); } catch (Exception x) { YAF.Classes.Data.DB.eventlog_create(PageContext.PageUserID, this, x); if (PageContext.IsAdmin) { PageContext.AddLoadMessage(x.Message); } else { PageContext.AddLoadMessage(GetText("ERROR")); } } }
protected void DeleteSelected_Click(object source, EventArgs e) { long nItemCount = 0; foreach (GridViewRow item in MessagesView.Rows) { if ((( CheckBox )item.FindControl("ItemCheck")).Checked) { if (View == PMView.Outbox) { DB.pmessage_delete(MessagesView.DataKeys [item.RowIndex].Value, true); } else { DB.pmessage_delete(MessagesView.DataKeys [item.RowIndex].Value); } nItemCount++; } } BindData(); if (nItemCount == 1) { PageContext.AddLoadMessage(PageContext.Localization.GetText("msgdeleted1")); } else { PageContext.AddLoadMessage( String.Format(PageContext.Localization.GetText("msgdeleted2"), nItemCount)); } }
/// <summary> /// The send_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Send_Click(object sender, EventArgs e) { object GroupID = null; if (this.ToList.SelectedItem.Value != "0") { GroupID = this.ToList.SelectedValue; } string subject = this.Subject.Text.Trim(); if (subject.IsNotSet()) { PageContext.AddLoadMessage("Subject is Required"); } else { using (DataTable dt = DB.user_emails(PageContext.PageBoardID, GroupID)) { foreach (DataRow row in dt.Rows) { // Wes - Changed to use queue to improve scalability this.Get <YafSendMail>().Queue(PageContext.BoardSettings.ForumEmail, (string)row["Email"], this.Subject.Text.Trim(), this.Body.Text.Trim()); } } this.Subject.Text = string.Empty; this.Body.Text = string.Empty; PageContext.AddLoadMessage("Mails queued."); } }
protected void ArchiveSelected_Click(object source, EventArgs e) { if (this.View != PMView.Inbox) { return; } long archivedCount = 0; foreach (GridViewRow item in MessagesView.Rows) { if ((( CheckBox )item.FindControl("ItemCheck")).Checked) { DB.pmessage_archive(MessagesView.DataKeys [item.RowIndex].Value); archivedCount++; } } BindData(); if (archivedCount == 1) { PageContext.AddLoadMessage(PageContext.Localization.GetText("MSG_ARCHIVED")); } else { PageContext.AddLoadMessage(String.Format(PageContext.Localization.GetText("MSG_ARCHIVED+"), archivedCount)); } }
/// <summary> /// The add_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Add_Click(object sender, EventArgs e) { short sortOrder = 0; if (!ValidationHelper.IsValidPosShort(this.txtExecOrder.Text.Trim())) { PageContext.AddLoadMessage("The sort order value should be a positive integer from 0 to 32767."); return; } if (!short.TryParse(this.txtExecOrder.Text.Trim(), out sortOrder)) { PageContext.AddLoadMessage("You must enter an number value from 0 to 32767 for sort order."); return; } DB.bbcode_save( BBCodeID, PageContext.PageBoardID, this.txtName.Text.Trim(), this.txtDescription.Text, this.txtOnClickJS.Text, this.txtDisplayJS.Text, this.txtEditJS.Text, this.txtDisplayCSS.Text, this.txtSearchRegEx.Text, this.txtReplaceRegEx.Text, this.txtVariables.Text, this.chkUseModule.Checked, this.txtModuleClass.Text, sortOrder); PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.CustomBBCode)); ReplaceRulesCreator.ClearCache(); YafBuildLink.Redirect(ForumPages.admin_bbcode); }
protected void SendEmail_Click(object sender, System.EventArgs e) { if (EmailAddress.Text.Length == 0) { PageContext.AddLoadMessage(GetText("need_email")); return; } try { string senderEmail = null; using (DataTable dt = YAF.Classes.Data.DB.user_list(PageContext.PageBoardID, PageContext.PageUserID, true)) { senderEmail = ( string )dt.Rows [0] ["Email"]; } // send the email... SendMail.Send(senderEmail, EmailAddress.Text.Trim(), Subject.Text.Trim(), Message.Text.Trim()); YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.posts, "t={0}", PageContext.PageTopicID); } catch (Exception x) { YAF.Classes.Data.DB.eventlog_create(PageContext.PageUserID, this, x); PageContext.AddLoadMessage(String.Format(GetText("failed"), x.Message)); } }
protected void Send_Click(object sender, System.EventArgs e) { object GroupID = null; if (ToList.SelectedItem.Value != "0") { GroupID = ToList.SelectedValue; } string subject = Subject.Text.Trim(); if (String.IsNullOrEmpty(subject)) { PageContext.AddLoadMessage("Subject is Required"); } else { using (DataTable dt = YAF.Classes.Data.DB.user_emails(PageContext.PageBoardID, GroupID)) { foreach (DataRow row in dt.Rows) { // Wes - Changed to use queue to improve scalability SendMail.Queue(PageContext.BoardSettings.ForumEmail, ( string )row["Email"], Subject.Text.Trim(), Body.Text.Trim()); } } Subject.Text = ""; Body.Text = ""; PageContext.AddLoadMessage("Mails queued."); } }
/// <summary> /// The list_ item command. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> protected void List_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "edit": // redirect to editing page YafBuildLink.Redirect(ForumPages.admin_editaccessmask, "i={0}", e.CommandArgument); break; case "delete": // attmempt to delete access masks if (DB.accessmask_delete(e.CommandArgument)) { // remove cache of forum moderators PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); BindData(); } else { // used masks cannot be deleted PageContext.AddLoadMessage("You cannot delete this access mask because it is in use."); } // quit switch break; } }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { if (this.Name.Text.Trim().Length == 0) { PageContext.AddLoadMessage("Missing server name."); return; } if (this.Address.Text.Trim().Length == 0) { PageContext.AddLoadMessage("Missing server address."); return; } object nntpServerID = null; if (Request.QueryString.GetFirstOrDefault("s") != null) { nntpServerID = Request.QueryString.GetFirstOrDefault("s"); } DB.nntpserver_save( nntpServerID, PageContext.PageBoardID, this.Name.Text, this.Address.Text, this.Port.Text.Length > 0 ? this.Port.Text : null, this.UserName.Text.Length > 0 ? this.UserName.Text : null, this.UserPass.Text.Length > 0 ? this.UserPass.Text : null); YafBuildLink.Redirect(ForumPages.admin_nntpservers); }
protected void Inbox_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "delete") { if (IsOutbox) { DB.pmessage_delete(e.CommandArgument, true); } else { DB.pmessage_delete(e.CommandArgument); } BindData(); PageContext.AddLoadMessage(GetText("msg_deleted")); } else if (e.CommandName == "reply") { YafBuildLink.Redirect(ForumPages.pmessage, "p={0}&q=0", e.CommandArgument); } else if (e.CommandName == "quote") { YafBuildLink.Redirect(ForumPages.pmessage, "p={0}&q=1", e.CommandArgument); } }
/// <summary> /// Handles post moderation events/buttons. /// </summary> private void List_ItemCommand(object sender, RepeaterCommandEventArgs e) { // which command are we handling switch (e.CommandName.ToLower()) { case "approve": // approve post DB.message_approve(e.CommandArgument); // re-bind data BindData(); // tell user message was approved PageContext.AddLoadMessage(GetText("APPROVED")); // create subscriptions for topic CreateMail.CreateWatchEmail(e.CommandArgument); break; case "delete": // delete message DB.message_delete(e.CommandArgument, true, "", 1, true); // re-bind data BindData(); // tell user message was deleted PageContext.AddLoadMessage(GetText("DELETED")); break; } // see if there are any items left... DataTable dt = DB.message_unapproved(PageContext.PageForumID); if (dt.Rows.Count == 0) { // nope -- redirect back to the moderate main... YafBuildLink.Redirect(ForumPages.moderate_index); } }
protected void Import_OnClick(object sender, System.EventArgs e) { // import selected file (if it's the proper format)... if (importFile.PostedFile.ContentType == "text/xml") { try { int importedCount = YAF.Classes.Data.Import.DataImport.BBCodeExtensionImport(PageContext.PageBoardID, importFile.PostedFile.InputStream); if (importedCount > 0) { PageContext.AddLoadMessageSession(String.Format("{0} new custom bbcode(s) imported successfully.", importedCount)); } else { PageContext.AddLoadMessageSession(String.Format("Nothing imported: no new custom bbcode was found in the upload.", importedCount)); } YafBuildLink.Redirect(ForumPages.admin_bbcode); } catch (Exception x) { PageContext.AddLoadMessage("Failed to import: " + x.Message); } } }
/// <summary> /// Handles click on save group button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void AddGroupSave_Click(object sender, EventArgs e) { // test if there is specified unsername/user id if (this.AvailableGroupList.SelectedIndex < 0) { // no group selected PageContext.AddLoadMessage("Please select user group!"); return; } // save group, if there is no message specified, pass null DB.group_medal_save( this.AvailableGroupList.SelectedValue, Request.QueryString.GetFirstOrDefault("m"), this.GroupMessage.Text.IsNotSet() ? null : this.GroupMessage.Text, this.GroupHide.Checked, this.GroupOnlyRibbon.Checked, this.GroupSortOrder.Text); // disable/hide edit controls AddGroupCancel_Click(sender, e); // re-bind data BindData(); }
/// <summary> /// The watch forum_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void WatchForum_Click(object sender, EventArgs e) { if (!PageContext.ForumReadAccess) { return; } if (PageContext.IsGuest) { PageContext.AddLoadMessage(GetText("WARN_LOGIN_FORUMWATCH")); return; } if (this.WatchForumID.InnerText == string.Empty) { DB.watchforum_add(PageContext.PageUserID, PageContext.PageForumID); PageContext.AddLoadMessage(GetText("INFO_WATCH_FORUM")); } else { int tmpID = Convert.ToInt32(this.WatchForumID.InnerText); DB.watchforum_delete(tmpID); PageContext.AddLoadMessage(GetText("INFO_UNWATCH_FORUM")); } HandleWatchForum(); }
/// <summary> /// The bb code list_ item command. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void bbCodeList_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "add") { YafBuildLink.Redirect(ForumPages.admin_bbcode_edit); } else if (e.CommandName == "edit") { YafBuildLink.Redirect(ForumPages.admin_bbcode_edit, "b={0}", e.CommandArgument); } else if (e.CommandName == "delete") { DB.bbcode_delete(e.CommandArgument); PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.CustomBBCode)); BindData(); } else if (e.CommandName == "export") { List <int> bbCodeIds = GetSelectedBBCodeIDs(); if (bbCodeIds.Count > 0) { // export this list as XML... DataTable dtBBCode = DB.bbcode_list(PageContext.PageBoardID, null); // remove all but required bbcodes... foreach (DataRow row in dtBBCode.Rows) { int id = Convert.ToInt32(row["BBCodeID"]); if (!bbCodeIds.Contains(id)) { // remove from this table... row.Delete(); } } // store delete changes... dtBBCode.AcceptChanges(); // export... dtBBCode.DataSet.DataSetName = "YafBBCodeList"; dtBBCode.TableName = "YafBBCode"; dtBBCode.Columns.Remove("BBCodeID"); dtBBCode.Columns.Remove("BoardID"); Response.ContentType = "text/xml"; Response.AppendHeader("Content-Disposition", "attachment; filename=YafBBCodeExport.xml"); dtBBCode.DataSet.WriteXml(Response.OutputStream); Response.End(); } else { PageContext.AddLoadMessage("Nothing selected to export."); } } else if (e.CommandName == "import") { YafBuildLink.Redirect(ForumPages.admin_bbcode_import); } }
/// <summary> /// Handles find users button click event. /// </summary> protected void FindUsers_Click(object sender, EventArgs e) { if (To.Text.Length < 2) { // need at least 2 latters of user's name PageContext.AddLoadMessage(GetText("NEED_MORE_LETTERS")); return; } // try to find users by user name using (DataTable dt = DB.user_find(PageContext.PageBoardID, true, To.Text, null)) { if (dt.Rows.Count > 0) { // we found a user(s) ToList.DataSource = dt; ToList.DataValueField = "UserID"; ToList.DataTextField = "Name"; ToList.DataBind(); //ToList.SelectedIndex = 0; // hide To text box and show To drop down ToList.Visible = true; To.Visible = false; // find is no more needed FindUsers.Visible = false; // we need clear button displayed now Clear.Visible = true; } // re-bind data to the controls DataBind(); } }
/// <summary> /// The import_ on click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Import_OnClick(object sender, EventArgs e) { // import selected file (if it's the proper format)... if (this.importFile.PostedFile.ContentType == "text/xml") { try { int importedCount = DataImport.FileExtensionImport(PageContext.PageBoardID, this.importFile.PostedFile.InputStream); if (importedCount > 0) { PageContext.LoadMessage.AddSession("{0} new extension(s) imported successfully.".FormatWith(importedCount)); } else { PageContext.LoadMessage.AddSession("Nothing imported: no new extensions were found in the upload.".FormatWith(importedCount)); } YafBuildLink.Redirect(ForumPages.admin_extensions); } catch (Exception x) { PageContext.AddLoadMessage("Failed to import: " + x.Message); } } }
protected void WatchForum_Click(object sender, System.EventArgs e) { if (!PageContext.ForumReadAccess) { return; } if (PageContext.IsGuest) { PageContext.AddLoadMessage(GetText("WARN_LOGIN_FORUMWATCH")); return; } if (WatchForumID.InnerText == "") { YAF.Classes.Data.DB.watchforum_add(PageContext.PageUserID, PageContext.PageForumID); PageContext.AddLoadMessage(GetText("INFO_WATCH_FORUM")); } else { int tmpID = Convert.ToInt32(WatchForumID.InnerText); YAF.Classes.Data.DB.watchforum_delete(tmpID); PageContext.AddLoadMessage(GetText("INFO_UNWATCH_FORUM")); } HandleWatchForum(); }
protected void btnResetPassword_Click(object sender, EventArgs e) { // reset password... try { MembershipUser user = UserMembershipHelper.GetMembershipUserById(CurrentUserID.Value); if (user != null) { // reset the password... user.UnlockUser(); string newPassword = user.ResetPassword(); // email a notification... YafTemplateEmail passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL"); string subject = this.PageContext.Localization.GetText("RECOVER_PASSWORD", "PASSWORDRETRIEVAL_EMAIL_SUBJECT").FormatWith(this.PageContext.BoardSettings.Name); passwordRetrieval.TemplateParams["{username}"] = user.UserName; passwordRetrieval.TemplateParams["{password}"] = newPassword; passwordRetrieval.TemplateParams["{forumname}"] = PageContext.BoardSettings.Name; passwordRetrieval.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL); passwordRetrieval.SendEmail(new System.Net.Mail.MailAddress(user.Email, user.UserName), subject, true); PageContext.AddLoadMessage("User Password Reset and Notification Email Sent"); } } catch (Exception x) { PageContext.AddLoadMessage("Exception: " + x.Message); } }
/// <summary> /// Handles save button click. /// </summary> protected void Save_Click(object sender, System.EventArgs e) { if (MedalImage.SelectedIndex <= 0) { PageContext.AddLoadMessage("Medal image must be specified!"); return; } else if (SmallMedalImage.SelectedIndex <= 0) { PageContext.AddLoadMessage("Small medal image must be specified!"); return; } // data object medalID = null; object imageURL, smallImageURL, ribbonURL = null, smallRibbonURL = null; object ribbonWidth = null, ribbonHeight = null; Size imageSize; MedalFlags flags = new MedalFlags(0); // retrieve medal ID, use null if we are creating new one if (Request.QueryString["m"] != null) { medalID = Request.QueryString["m"]; } // flags flags.ShowMessage = ShowMessage.Checked; flags.AllowRibbon = AllowRibbon.Checked; flags.AllowReOrdering = AllowReOrdering.Checked; flags.AllowHiding = AllowHiding.Checked; // get medal images imageURL = MedalImage.SelectedValue; smallImageURL = SmallMedalImage.SelectedValue; if (RibbonImage.SelectedIndex > 0) { ribbonURL = RibbonImage.SelectedValue; } if (SmallRibbonImage.SelectedIndex > 0) { smallRibbonURL = SmallRibbonImage.SelectedValue; imageSize = GetImageSize(smallRibbonURL.ToString()); ribbonWidth = imageSize.Width; ribbonHeight = imageSize.Height; } // get size of small image imageSize = GetImageSize(smallImageURL.ToString()); // save medal DB.medal_save(PageContext.PageBoardID, medalID, Name.Text, Description.Text, Message.Text, Category.Text, imageURL, ribbonURL, smallImageURL, smallRibbonURL, imageSize.Width, imageSize.Height, ribbonWidth, ribbonHeight, SortOrder.Text, flags.BitValue); // go back to medals administration YafBuildLink.Redirect(ForumPages.admin_medals); }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { string[] ipParts = this.mask.Text.Trim().Split('.'); // do some validation... string ipError = string.Empty; if (ipParts.Length != 4) { ipError += "Invalid IP address."; } // see if they are numbers... ulong number; foreach (string ip in ipParts) { if (!ulong.TryParse(ip, out number)) { if (ip.Trim() != "*") { if (ip.Trim().Length == 0) { ipError += "\r\nOne of the IP section does not have a value. Valid values are 0-255 or \"*\" for a wildcard."; } else { ipError += "\r\n\"{0}\" is not a valid IP section value.".FormatWith(ip); } break; } } else { // try parse succeeded... verify number amount... if (number > 255) { ipError += "\r\n\"{0}\" is not a valid IP section value (must be less then 255).".FormatWith(ip); } } } // show error(s) if not valid... if (ipError.IsSet()) { PageContext.AddLoadMessage(ipError); return; } DB.bannedip_save(Request.QueryString.GetFirstOrDefault("i"), PageContext.PageBoardID, this.mask.Text.Trim(), this.BanReason.Text.Trim(), this.PageContext.PageUserID); // clear cache of banned IPs for this board PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BannedIP)); // go back to banned IP's administration page YafBuildLink.Redirect(ForumPages.admin_bannedip); }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void save_Click(object sender, EventArgs e) { string code = this.Code.Text.Trim(); string emotion = this.Emotion.Text.Trim(); string icon = this.Icon.SelectedItem.Text.Trim(); int sortOrder; if (emotion.Length > 50) { PageContext.AddLoadMessage("An emotion description is too long."); return; } if (code.Length == 0) { PageContext.AddLoadMessage("Please enter the code to use for this emotion."); return; } if (code.Length > 10) { PageContext.AddLoadMessage("The code to use for this emotion should not be more then 10 symbols."); return; } if (!new System.Text.RegularExpressions.Regex(@"\[.+\]").IsMatch(code)) { PageContext.AddLoadMessage("Please enter the code to use for this emotion in square brackets."); return; } if (emotion.Length == 0) { PageContext.AddLoadMessage("Please enter an emotion for this icon."); return; } if (this.Icon.SelectedIndex < 1) { PageContext.AddLoadMessage("Please select an icon to use for this emotion."); return; } // Ederon 9/4/2007 if (!int.TryParse(this.SortOrder.Text, out sortOrder) || sortOrder < 0 || sortOrder > 255) { PageContext.AddLoadMessage("Sort order must be number between 0 and 255."); return; } DB.smiley_save(Request.QueryString.GetFirstOrDefault("s"), PageContext.PageBoardID, code, icon, emotion, sortOrder, 0); // invalidate the cache... PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies)); ReplaceRulesCreator.ClearCache(); YafBuildLink.Redirect(ForumPages.admin_smilies); }
/// <summary> /// The topiclist_ item command. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void topiclist_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "delete") { DB.topic_delete(e.CommandArgument); PageContext.AddLoadMessage(GetText("deleted")); BindData(); } }
protected void save_Click(object sender, EventArgs e) { String [] ipParts = mask.Text.Trim().Split('.'); // do some validation... string ipError = ""; if (ipParts.Length != 4) { ipError += "Invalid IP address."; } // see if they are numbers... ulong number; foreach (string ip in ipParts) { if (!ulong.TryParse(ip, out number)) { if (ip.Trim() != "*") { if (ip.Trim().Length == 0) { ipError += "\r\nOne of the IP section does not have a value. Valid values are 0-255 or \"*\" for a wildcard."; } else { ipError += String.Format("\r\n\"{0}\" is not a valid IP section value.", ip); } break; } } else { // try parse succeeded... verify number amount... if (number > 255) { ipError += String.Format("\r\n\"{0}\" is not a valid IP section value (must be less then 255).", ip); } } } // show error(s) if not valid... if (!String.IsNullOrEmpty(ipError)) { PageContext.AddLoadMessage(ipError); return; } YAF.Classes.Data.DB.bannedip_save(Request.QueryString ["i"], PageContext.PageBoardID, mask.Text.Trim()); // clear cache of banned IPs for this board YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BannedIP)); // go back to banned IP's administration page YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_bannedip); }
/// <summary> /// Handles click on save user button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void AddUserSave_Click(object sender, EventArgs e) { // test if there is specified unsername/user id if (this.UserID.Text.IsNotSet() && this.UserNameList.SelectedValue.IsNotSet() && this.UserName.Text.IsNotSet()) { // no username, nor userID specified PageContext.AddLoadMessage("Please specify valid user!"); return; } else if (this.UserNameList.SelectedValue.IsNotSet() && this.UserID.Text.IsNotSet()) { // only username is specified, we must find id for it var users = DB.UserFind(this.PageContext.PageBoardID, true, this.UserName.Text, null, null, null, null); if (users.Count() > 1) { // more than one user is avalilable for this username PageContext.AddLoadMessage("Ambiguous user name specified!"); return; } else if (!users.Any()) { // no user found PageContext.AddLoadMessage("Please specify valid user!"); return; } else { // save id to the control this.UserID.Text = (users.First().UserID ?? 0).ToString(); } } else if (this.UserID.Text.IsNotSet()) { // user is selected in dropdown, we must get id to UserID control this.UserID.Text = this.UserNameList.SelectedValue; } // save user, if there is no message specified, pass null DB.user_medal_save( this.UserID.Text, Request.QueryString.GetFirstOrDefault("m"), this.UserMessage.Text.IsNotSet() ? null : this.UserMessage.Text, this.UserHide.Checked, this.UserOnlyRibbon.Checked, this.UserSortOrder.Text, null); // disable/hide edit controls AddUserCancel_Click(sender, e); // clear cache... RemoveUserFromCache(Convert.ToInt32(this.UserID.Text)); // re-bind data BindData(); }
protected void EmailTopic_Click(object sender, System.EventArgs e) { if (User == null) { PageContext.AddLoadMessage(GetText("WARN_EMAILLOGIN")); return; } YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.emailtopic, "t={0}", PageContext.PageTopicID); }
protected void NewTopic_Click(object sender, System.EventArgs e) { if (_forumFlags.IsLocked) { PageContext.AddLoadMessage(GetText("WARN_FORUM_LOCKED")); return; } YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.postmessage, "f={0}", PageContext.PageForumID); }
private void SearchBindData(bool newSearch) { try { if (newSearch && !CheckSearchRequest()) { return; } else if (newSearch || Mession.SearchData == null) { SearchWhatFlags sw = (SearchWhatFlags)System.Enum.Parse(typeof(SearchWhatFlags), listSearchWhat.SelectedValue); SearchWhatFlags sfw = (SearchWhatFlags)System.Enum.Parse(typeof(SearchWhatFlags), listSearchFromWho.SelectedValue); int forumID = int.Parse(listForum.SelectedValue); DataTable searchDataTable = YAF.Classes.Data.DB.GetSearchResult(txtSearchStringWhat.Text, txtSearchStringFromWho.Text, sfw, sw, forumID, PageContext.PageUserID, PageContext.PageBoardID, PageContext.BoardSettings.ReturnSearchMax, PageContext.BoardSettings.UseFullTextSearch); Pager.CurrentPageIndex = 0; Pager.PageSize = int.Parse(listResInPage.SelectedValue); Pager.Count = searchDataTable.DefaultView.Count; Mession.SearchData = searchDataTable; bool bResults = (searchDataTable.DefaultView.Count > 0) ? true : false; SearchRes.Visible = bResults; NoResults.Visible = !bResults; } PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.DataSource = Mession.SearchData.DefaultView; pds.PageSize = Pager.PageSize; pds.CurrentPageIndex = Pager.CurrentPageIndex; UpdateHistory.AddEntry(Pager.CurrentPageIndex.ToString() + "|" + Pager.PageSize); SearchRes.DataSource = pds; SearchRes.DataBind(); } catch (Exception x) { YAF.Classes.Data.DB.eventlog_create(PageContext.PageUserID, this, x); CreateMail.CreateLogEmail(x); if (PageContext.IsAdmin) { PageContext.AddLoadMessage(string.Format("{0}", x)); } else { PageContext.AddLoadMessage("An error occured while searching."); } } }
protected void Save_Click(object sender, System.EventArgs e) { if (Name.Text.Trim().Length == 0) { PageContext.AddLoadMessage("You must enter a name for the board."); return; } if (BoardID == null && CreateAdminUser.Checked) { if (UserName.Text.Trim().Length == 0) { PageContext.AddLoadMessage("You must enter the name of a administrator user."); return; } if (UserEmail.Text.Trim().Length == 0) { PageContext.AddLoadMessage("You must enter the email address of the administrator user."); return; } if (UserPass1.Text.Trim().Length == 0) { PageContext.AddLoadMessage("You must enter a password for the administrator user."); return; } if (UserPass1.Text != UserPass2.Text) { PageContext.AddLoadMessage("The passwords don't match."); return; } } if (BoardID != null) { // Save current board settings YAF.Classes.Data.DB.board_save(BoardID, Name.Text.Trim(), AllowThreaded.Checked); } else { // Create board // MEK says : Purposefully set MembershipAppName without including RolesAppName yet, as the current providers don't support different Appnames. if (CreateAdminUser.Checked) { this.CreateBoard(UserName.Text.Trim(), UserPass1.Text, UserEmail.Text.Trim(), UserPasswordQuestion.Text.Trim(), UserPasswordAnswer.Text.Trim(), Name.Text.Trim(), BoardMembershipAppName.Text.Trim(), BoardMembershipAppName.Text.Trim(), true); } else { // create admin user from logged in user... this.CreateBoard(null, null, null, null, null, Name.Text.Trim(), BoardMembershipAppName.Text.Trim(), BoardMembershipAppName.Text.Trim(), false); } } // Done PageContext.BoardSettings = null; YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_boards); }
protected void CreateUserWizard1_CreateUserError(object sender, CreateUserErrorEventArgs e) { string createUserError = ""; // find the type of error switch (e.CreateUserError) { case MembershipCreateStatus.DuplicateEmail: createUserError = GetText("ALREADY_REGISTERED"); break; case MembershipCreateStatus.DuplicateUserName: createUserError = GetText("ALREADY_REGISTERED"); break; case MembershipCreateStatus.InvalidEmail: createUserError = GetText("BAD_EMAIL"); break; case MembershipCreateStatus.InvalidPassword: createUserError = GetText("BAD_PASSWORD"); break; case MembershipCreateStatus.InvalidQuestion: createUserError = GetText("INVALID_QUESTION"); break; case MembershipCreateStatus.InvalidUserName: createUserError = GetText("INVALID_USERNAME"); break; case MembershipCreateStatus.InvalidAnswer: createUserError = GetText("INVALID_ANSWER"); break; case MembershipCreateStatus.InvalidProviderUserKey: createUserError = "Invalid provider user key."; break; case MembershipCreateStatus.DuplicateProviderUserKey: createUserError = "Duplicate provider user key."; break; case MembershipCreateStatus.ProviderError: createUserError = "Provider Error"; break; case MembershipCreateStatus.UserRejected: createUserError = "User creation failed: Reason is defined by the provider."; break; } PageContext.AddLoadMessage(createUserError); //Display the failure message in a client-side alert box //Page.ClientScript.RegisterStartupScript(Page.GetType(), "CreateUserError", String.Format("alert('{0}');", createUserError.Replace("'", "\'")), true); }