/******************************************************************* * // MoveForumGroupUpInSortOrder_Click * // * /// <summary> * /// Used to control moving Forum Groups up and down in the sort order * /// </summary> * // ********************************************************************/ private void MoveForumGroupUpInSortOrder_Click(Object sender, ImageClickEventArgs e) { int selectedForumGroup = Convert.ToInt32(forumGroupList.SelectedItem.Value); ForumGroups.ChangeForumGroupSortOrder(selectedForumGroup, true); PopulateListBox(selectedForumGroup); }
/******************************************************************* * // DeleteForumGroup_Click * // * /// <summary> * /// Event raised when the user deletes a forum group name * /// </summary> * /// <param name="sender"></param> * /// <param name="e"></param> * // ********************************************************************/ private void DeleteForumGroup_Click(Object sender, EventArgs e) { // If the page is invalid, simply exit the function if (!Page.IsValid) { return; } // Update ForumGroups.UpdateForumGroup(null, Convert.ToInt32(forumGroupList.SelectedItem.Value)); }
public async Task <ActionResult> CreateGroup(ForumGroups group) { database.ForumGroups.Add(new ForumGroups { AdminUserId = group.AdminUserId, ID = Guid.NewGuid(), Title = group.Title, ParentID = group.ParentID }); await database.SaveChangesAsync(); return(RedirectToAction("Index")); }
// ********************************************************************* // OnPreRender // /// <summary> /// This event handler binds the template to the datalist - this action /// is only carried out if the user DID NOT specify an ItemTemplate. /// In such a case, the default databinding is used. /// </summary> /// // ********************************************************************/ protected override void OnPreRender(EventArgs e) { ForumGroupCollection forumGroups; // Get all forum groups (cached call) if (showAllForumGroups) { forumGroups = ForumGroups.GetAllForumGroups(true, false); } else { forumGroups = ForumGroups.GetAllForumGroups(false, true); } // Have we asked for a particular forum group? if (ForumGroupID > 0) { ForumGroupCollection newForumGroups = new ForumGroupCollection(); // Try to find the requested forum group foreach (ForumGroup f in forumGroups) { if (f.ForumGroupID == ForumGroupID) { newForumGroups.Add(f); } } forumGroups = newForumGroups; } // Databind if we have values if (forumGroups.Count > 0) { DataSource = forumGroups; DataBind(); } else // No forums { Label label; // Set some properties on the label label = new Label(); label.CssClass = "normalTextSmallBold"; label.Text = "Sorry, no forums are available."; // Clear the controls collection and add our label Controls.Clear(); Controls.Add(label); } }
private void RenderGroupsMenu() { ForumGroupCollection groups = ForumGroups.GetAllForumGroups(false, true); string groupMenu = "<div class='popupMenu' style='position: absolute; display: none;' id='" + this.UniqueID + ":groupMenu'>"; groupMenu += "<div class='popupTitle'>Forum Groups</div>"; for (int i = 0; i < groups.Count; i++) { groupMenu += "<div class='popupItem'> <a href='" + UrlShowForumGroup + ((ForumGroup)groups[i]).ForumGroupID + "'>" + ((ForumGroup)groups[i]).Name + "</a> </div>"; } groupMenu += "</div>"; Page.RegisterClientScriptBlock(this.UniqueID + ":groupMenu", groupMenu); }
/******************************************************************* * // PopulateListBox * // * /// <summary> * /// Used to populate the list box that lists the available forum groups * /// </summary> * // ********************************************************************/ public void PopulateListBox(int selectedForumGroupById) { ForumGroupCollection forums = ForumGroups.GetAllForumGroups(true, false); forumGroupList.DataTextField = "Name"; forumGroupList.DataValueField = "ForumGroupId"; forumGroupList.DataSource = forums; forumGroupList.Rows = forums.Count; forumGroupList.DataBind(); forumGroupList.AutoPostBack = true; forumGroupList.SelectedIndexChanged += new System.EventHandler(ForumGroupList_SelectionChange); if (selectedForumGroupById > 0) { forumGroupList.Items.FindByValue(selectedForumGroupById.ToString()).Selected = true; } else { forumGroupList.Items[0].Selected = true; } }
/// <summary> /// Populates the user control containing the form with the initial values for /// creating a new forum. /// </summary> /// <param name="control">An instance of the user control that contains the expected server controls.</param> private void PopulateCreateEditForum(Control control) { DropDownList dropdownlist; Button button; Label label; // Set the title label = (Label)control.FindControl("Title"); if (Mode == CreateEditForumMode.CreateForum) { label.Text = "Create a new forum"; } else { label.Text = "Edit an existing forum"; } // Fill the Forum Group Drop Down dropdownlist = (DropDownList)control.FindControl("ForumGroups"); dropdownlist.DataTextField = "Name"; dropdownlist.DataValueField = "ForumGroupId"; dropdownlist.DataSource = ForumGroups.GetAllForumGroups(true, false); dropdownlist.DataBind(); // Wire up the button click button = (Button)control.FindControl("CreateUpdate"); button.Click += new System.EventHandler(CreateUpdateForum_Click); // Initialize role based security UpdateRoleControls(control); if (Mode == CreateEditForumMode.CreateForum) { button.Text = "Create New Forum"; } else { button.Text = "Update Forum"; } }
/******************************************************************* * // CreateForumGroup_Click * // * /// <summary> * /// Event raised when the user is ready to create a new forum * /// group name * /// </summary> * /// <param name="sender"></param> * /// <param name="e"></param> * // ********************************************************************/ private void CreateForumGroup_Click(Object sender, EventArgs e) { // If the page is invalid, simply exit the function if (!Page.IsValid) { return; } try { if (Mode == CreateEditForumMode.CreateForum) { ForumGroups.AddForumGroup(forumGroupName.Text); } } catch (Exception) { validateForumGroupName.Text = "Forum group name already exists."; validateForumGroupName.IsValid = false; return; } // send the user back to the forum admin page Context.Response.Redirect(this.RedirectUrl); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { repLatestPosts.DataBindByDefault = false; pagerElem.PageControl = repLatestPosts.ID; if (StopProcessing) { // Do nothing } else { if (!String.IsNullOrEmpty(TransformationName)) { // Basic control properties repLatestPosts.HideControlForZeroRows = HideControlForZeroRows; repLatestPosts.ZeroRowsText = ZeroRowsText; // Set data source groupID according to group name if (!String.IsNullOrEmpty(GroupName)) { GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfoByName(GroupName, SiteName); if (gi != null) { forumDataSource.GroupID = ValidationHelper.GetInteger(gi.GetValue("GroupID"), 0); } else { // Do nothing if no group is set forumDataSource.StopProcessing = true; } } if (!forumDataSource.StopProcessing) { // Data source properties forumDataSource.TopN = SelectTopN; forumDataSource.OrderBy = OrderBy; forumDataSource.CacheItemName = CacheItemName; forumDataSource.CacheDependencies = CacheDependencies; forumDataSource.CacheMinutes = CacheMinutes; forumDataSource.SourceFilterName = FilterName; forumDataSource.SelectOnlyApproved = SelectOnlyApproved; forumDataSource.SiteName = SiteName; forumDataSource.SelectedColumns = Columns; forumDataSource.ShowGroupPosts = ShowGroupPosts && String.IsNullOrEmpty(ForumGroups); #region "Repeater template properties" // Apply transformations if they exist repLatestPosts.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName); // Alternating item if (!String.IsNullOrEmpty(AlternatingItemTransformationName)) { repLatestPosts.AlternatingItemTemplate = CMSDataProperties.LoadTransformation(this, AlternatingItemTransformationName); } // Footer if (!String.IsNullOrEmpty(FooterTransformationName)) { repLatestPosts.FooterTemplate = CMSDataProperties.LoadTransformation(this, FooterTransformationName); } // Header if (!String.IsNullOrEmpty(HeaderTransformationName)) { repLatestPosts.HeaderTemplate = CMSDataProperties.LoadTransformation(this, HeaderTransformationName); } // Separator if (!String.IsNullOrEmpty(SeparatorTransformationName)) { repLatestPosts.SeparatorTemplate = CMSDataProperties.LoadTransformation(this, SeparatorTransformationName); } #endregion // UniPager properties pagerElem.PageSize = PageSize; pagerElem.GroupSize = GroupSize; pagerElem.QueryStringKey = QueryStringKey; pagerElem.DisplayFirstLastAutomatically = DisplayFirstLastAutomatically; pagerElem.DisplayPreviousNextAutomatically = DisplayPreviousNextAutomatically; pagerElem.HidePagerForSinglePage = HidePagerForSinglePage; // Set pager mode switch (PagingMode.ToLowerCSafe()) { case "postback": pagerElem.PagerMode = UniPagerMode.PostBack; break; default: pagerElem.PagerMode = UniPagerMode.Querystring; break; } #region "UniPager template properties" // UniPager template properties if (!String.IsNullOrEmpty(PagesTemplate)) { pagerElem.PageNumbersTemplate = CMSDataProperties.LoadTransformation(pagerElem, PagesTemplate); } // Current page if (!String.IsNullOrEmpty(CurrentPageTemplate)) { pagerElem.CurrentPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, CurrentPageTemplate); } // Separator if (!String.IsNullOrEmpty(SeparatorTemplate)) { pagerElem.PageNumbersSeparatorTemplate = CMSDataProperties.LoadTransformation(pagerElem, SeparatorTemplate); } // First page if (!String.IsNullOrEmpty(FirstPageTemplate)) { pagerElem.FirstPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, FirstPageTemplate); } // Last page if (!String.IsNullOrEmpty(LastPageTemplate)) { pagerElem.LastPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, LastPageTemplate); } // Previous page if (!String.IsNullOrEmpty(PreviousPageTemplate)) { pagerElem.PreviousPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, PreviousPageTemplate); } // Next page if (!String.IsNullOrEmpty(NextPageTemplate)) { pagerElem.NextPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, NextPageTemplate); } // Previous group if (!String.IsNullOrEmpty(PreviousGroupTemplate)) { pagerElem.PreviousGroupTemplate = CMSDataProperties.LoadTransformation(pagerElem, PreviousGroupTemplate); } // Next group if (!String.IsNullOrEmpty(NextGroupTemplate)) { pagerElem.NextGroupTemplate = CMSDataProperties.LoadTransformation(pagerElem, NextGroupTemplate); } // Direct page if (!String.IsNullOrEmpty(DirectPageTemplate)) { pagerElem.DirectPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, DirectPageTemplate); } // Layout if (!String.IsNullOrEmpty(LayoutTemplate)) { pagerElem.LayoutTemplate = CMSDataProperties.LoadTransformation(pagerElem, LayoutTemplate); } #endregion #region "Complete where condition" string where = ""; string[] groups = ForumGroups.Split(';'); // Create where condition for all forum groups foreach (string group in groups) { if (group != "") { if (where != "") { where += "OR"; } where += "(GroupName = N'" + SqlHelper.GetSafeQueryString(group, false) + "')"; } } // Add custom where condition if (!string.IsNullOrEmpty(WhereCondition)) { if (string.IsNullOrEmpty(where)) { where = WhereCondition; } else { where = "(" + WhereCondition + ") AND (" + where + ")"; } } #endregion // Set forum data source forumDataSource.WhereCondition = where; forumDataSource.CheckPermissions = true; repLatestPosts.DataSourceControl = forumDataSource; } } pagerElem.RebindPager(); repLatestPosts.DataBind(); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { imgTextHint.ImageUrl = GetImageUrl("Design/Forums/hint.gif"); imgTextHint.AlternateText = "Hint"; ScriptHelper.AppendTooltip(imgTextHint, GetString("ForumSearch.SearchTextHint"), "help"); btnSearch.Text = GetString("general.search"); if (EnableForumSelection) { plcForums.Visible = true; string selected = ";" + QueryHelper.GetString("searchforums", "") + ";"; bool allForums = QueryHelper.GetBoolean("allforums", false); ForumPostsDataSource fpd = new ForumPostsDataSource(); fpd.CacheMinutes = 0; fpd.SelectedColumns = "GroupID, GroupDisplayName, ForumID, ForumDisplayName,GroupOrder, ForumOrder, ForumName "; fpd.Distinct = true; fpd.SelectOnlyApproved = false; fpd.SiteName = SiteContext.CurrentSiteName; string where = "(GroupGroupID IS NULL) AND (GroupName != 'adhocforumgroup') AND (ForumOpen=1)"; // Get only selected forum groups if (!String.IsNullOrEmpty(ForumGroups)) { string groups = ""; foreach (string group in ForumGroups.Split(';')) { groups += " '" + SqlHelper.GetSafeQueryString(group) + "',"; } // Add new part to where condition where += " AND (GroupName IN (" + groups.TrimEnd(',') + "))"; } if (HideForumForUnauthorized) { where = ForumInfoProvider.CombineSecurityWhereCondition(where, 0); } fpd.WhereCondition = where; fpd.OrderBy = "GroupOrder, ForumOrder ASC, ForumName ASC"; DataSet ds = fpd.DataSource as DataSet; if (!DataHelper.DataSourceIsEmpty(ds)) { int oldGroup = -1; foreach (DataRow dr in ds.Tables[0].Rows) { if (oldGroup != ValidationHelper.GetInteger(dr["GroupID"], 0)) { ListItem li = new ListItem(ResHelper.LocalizeString(Convert.ToString(dr["GroupDisplayName"])), ""); li.Attributes.Add("disabled", "disabled"); if (!listForums.Items.Contains(li)) { listForums.Items.Add(li); } oldGroup = ValidationHelper.GetInteger(dr["GroupID"], 0); } string forumId = Convert.ToString(dr["ForumID"]); ListItem lif = new ListItem(" \xA0\xA0\xA0\xA0 " + ResHelper.LocalizeString(Convert.ToString(dr["ForumDisplayName"])), forumId); if ((selected.Contains(";" + forumId + ";")) && (!allForums)) { lif.Selected = true; } // On postback on ASPX if (!listForums.Items.Contains(lif)) { listForums.Items.Add(lif); } } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { if (!String.IsNullOrEmpty(TransformationName)) { repLatestPosts.ItemTemplate = TransformationHelper.LoadTransformation(this, TransformationName); repLatestPosts.HideControlForZeroRows = HideControlForZeroRows; repLatestPosts.ZeroRowsText = ZeroRowsText; // Set data source groupid according to group name if (!String.IsNullOrEmpty(GroupName)) { if (GroupName == PredefinedObjectType.COMMUNITY_CURRENT_GROUP) { forumDataSource.GroupID = ModuleCommands.CommunityGetCurrentGroupID(); } else { GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfoByName(GroupName, SiteName); if (gi != null) { forumDataSource.GroupID = ValidationHelper.GetInteger(gi.GetValue("GroupID"), 0); } else { forumDataSource.StopProcessing = true; } } } if (!forumDataSource.StopProcessing) { forumDataSource.TopN = SelectTopN; forumDataSource.OrderBy = "PostThreadLastPostTime DESC"; forumDataSource.CacheItemName = CacheItemName; forumDataSource.CacheDependencies = CacheDependencies; forumDataSource.CacheMinutes = CacheMinutes; forumDataSource.SelectOnlyApproved = false; forumDataSource.SiteName = SiteName; forumDataSource.ShowGroupPosts = ShowGroupPosts && String.IsNullOrEmpty(ForumGroups); forumDataSource.SelectedColumns = Columns; #region "Complete where condition" string where = ""; // Get groups part of where condition string[] groups = ForumGroups.Split(';'); foreach (string group in groups) { if (group != "") { if (where != "") { where += " OR "; } where += "(GroupName = N'" + SqlHelper.GetSafeQueryString(group, false) + "')"; } } where = "(" + (where == "" ? "(GroupName NOT LIKE 'AdHoc%')" : "(" + where + ")") + " AND (PostLevel = 0))"; // Append where condition and set PostLevel to 0 (only threads are needed) // and filter out AdHoc forums if (!String.IsNullOrEmpty(WhereCondition)) { where += " AND (" + WhereCondition + ")"; } #endregion forumDataSource.WhereCondition = where; forumDataSource.CheckPermissions = true; repLatestPosts.DataSourceControl = forumDataSource; repLatestPosts.DataBind(); } } } }
public ActionResult EditGroup(ForumGroups group) { database.Entry(group).State = EntityState.Modified; database.SaveChanges(); return(RedirectToAction("Index")); }