/// <summary> /// Provides operations necessary to create and store new cms file. /// </summary> /// <param name="args">Upload arguments.</param> /// <param name="context">HttpContext instance.</param> private void HandleForumUpload(UploaderHelper args, HttpContext context) { ForumInfo fi = null; try { args.IsExtensionAllowed(); if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.forums", CMSAdminControl.PERMISSION_MODIFY)) { throw new Exception("Current user is not granted with modify permission per 'cms.forums' resource."); } fi = ForumInfoProvider.GetForumInfo(args.ForumArgs.PostForumID); if (fi != null) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { ForumAttachmentInfo fai = new ForumAttachmentInfo(args.FilePath, 0, 0, 0) { AttachmentPostID = args.ForumArgs.PostID, AttachmentSiteID = fgi.GroupSiteID }; ForumAttachmentInfoProvider.SetForumAttachmentInfo(fai); } } } catch (Exception ex) { args.Message = ex.Message; // Log the error EventLogProvider.LogException("MultiFileUploader", "UPLOADFORUM", ex); } finally { if (!string.IsNullOrEmpty(args.AfterSaveJavascript)) { args.AfterScript = String.Format(@" if (window.{0} != null) {{ window.{0}() }} else if ((window.parent != null) && (window.parent.{0} != null)) {{ window.parent.{0}() }}", args.AfterSaveJavascript); } else { args.AfterScript = String.Format(@" if (window.InitRefresh_{0}) {{ window.InitRefresh_{0}('{1}', false, false); }} else {{ if ('{1}' != '') {{ alert('{1}'); }} }}", args.ParentElementID, ScriptHelper.GetString(args.Message.Trim(), false)); } args.AddEventTargetPostbackReference(); context.Response.Write(args.AfterScript); context.Response.Flush(); } }
/// <summary> /// PreRender action on which security settings are set. /// </summary> private void Page_PreRender(object sender, EventArgs e) { if ((Form == null) || !mDocumentSaved) { return; } TreeNode editedNode = Form.EditedObject as TreeNode; // Create or rebuild department content index CreateDepartmentContentSearchIndex(editedNode); if ((editedNode == null) || !editedNode.NodeIsACLOwner) { return; } ForumInfo fi = ForumInfoProvider.GetForumInfo("Default_department_" + editedNode.NodeGUID, SiteContext.CurrentSiteID); MediaLibraryInfo mi = MediaLibraryInfoProvider.GetMediaLibraryInfo("Department_" + editedNode.NodeGUID, SiteContext.CurrentSiteName); // Check if forum of media library exists if ((fi == null) && (mi == null)) { return; } // Get allowed roles ID int aclID = ValidationHelper.GetInteger(editedNode.GetValue("NodeACLID"), 0); DataSet listRoles = AclItemInfoProvider.GetAllowedRoles(aclID, NodePermissionsEnum.Read, "RoleID"); IList <int> roleIds = null; if (!DataHelper.DataSourceIsEmpty(listRoles)) { roleIds = DataHelper.GetIntegerValues(listRoles.Tables[0], "RoleID") as List <int>; } // Set permissions for forum if (fi != null) { // Get resource object ResourceInfo resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); // Get permissions IDs var forumPermissions = PermissionNameInfoProvider.GetPermissionNames() .Column("PermissionID") .WhereEquals("ResourceID", resForums.ResourceID) .WhereNotEquals("PermissionName", CMSAdminControl.PERMISSION_READ) .WhereNotEquals("PermissionName", CMSAdminControl.PERMISSION_MODIFY); // Delete old permissions apart attach file permission ForumRoleInfoProvider.DeleteAllRoles(new WhereCondition().WhereEquals("ForumID", fi.ForumID).WhereIn("PermissionID", forumPermissions)); // Set forum permissions ForumRoleInfoProvider.SetPermissions(fi.ForumID, roleIds, forumPermissions.Select(p => p.PermissionId).ToArray()); // Log staging task SynchronizationHelper.LogObjectChange(fi, TaskTypeEnum.UpdateObject); } // Set permissions for media library if (mi == null) { return; } // Get resource object ResourceInfo resMediaLibs = ResourceInfoProvider.GetResourceInfo("CMS.MediaLibrary"); // Get permissions IDs DataSet dsMediaLibPerm = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resMediaLibs.ResourceID + " AND (PermissionName = 'LibraryAccess' OR PermissionName = 'FileCreate')", null, 0, "PermissionID"); IList <int> mediaLibPermissionsIds = null; if (!DataHelper.DataSourceIsEmpty(dsMediaLibPerm)) { mediaLibPermissionsIds = DataHelper.GetIntegerValues(dsMediaLibPerm.Tables[0], "PermissionID"); } var deleteWhere = new WhereCondition() .WhereEquals("LibraryID", mi.LibraryID) .WhereIn("PermissionID", mediaLibPermissionsIds); // Delete old permissions only for Create file and See library content permissions MediaLibraryRolePermissionInfoProvider.DeleteAllRoles(deleteWhere.ToString(true)); MediaLibraryRolePermissionInfoProvider.SetPermissions(mi.LibraryID, roleIds, mediaLibPermissionsIds); // Log staging task; SynchronizationHelper.LogObjectChange(mi, TaskTypeEnum.UpdateObject); }
/// <summary> /// Generates the permission matrix for the current forum. /// </summary> private void CreateMatrix() { // Get forum resource info if (resForums == null) { resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); } // Get forum object if ((forum == null) && (ForumID > 0)) { forum = ForumInfoProvider.GetForumInfo(ForumID); } if ((resForums != null) && (forum != null)) { // Get permission matrix for roles of the current site/group int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Get permissions for the current forum resource DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resForums.ResourceId); if (DataHelper.DataSourceIsEmpty(permissions)) { ShowInformation(GetString("general.emptymatrix")); } else { TableRow headerRow = new TableRow(); headerRow.CssClass = "UniGridHead"; TableCell newCell = new TableCell(); TableHeaderCell newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = " "; newHeaderCell.Attributes["style"] = "width:200px;"; headerRow.Cells.Add(newHeaderCell); foreach (string permission in allowedPermissions) { DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'"); if ((drArray != null) && (drArray.Length > 0)) { DataRow dr = drArray[0]; newHeaderCell = new TableHeaderCell(); newHeaderCell.Attributes["style"] = "text-align:center;white-space:nowrap;"; newHeaderCell.Text = dr["PermissionDisplayName"].ToString(); newHeaderCell.ToolTip = dr["PermissionDescription"].ToString(); newHeaderCell.HorizontalAlign = HorizontalAlign.Center; headerRow.Cells.Add(newHeaderCell); } else { throw new Exception("[Security matrix] Column '" + permission + "' cannot be found."); } } newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = " "; headerRow.Cells.Add(newHeaderCell); tblMatrix.Rows.Add(headerRow); // Render forum access permissions object[,] accessNames = new object[5, 2]; accessNames[0, 0] = GetString("security.nobody"); accessNames[0, 1] = SecurityAccessEnum.Nobody; accessNames[1, 0] = GetString("security.allusers"); accessNames[1, 1] = SecurityAccessEnum.AllUsers; accessNames[2, 0] = GetString("security.authenticated"); accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers; accessNames[3, 0] = GetString("security.groupmembers"); accessNames[3, 1] = SecurityAccessEnum.GroupMembers; accessNames[4, 0] = GetString("security.authorizedroles"); accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles; TableRow newRow = null; int rowIndex = 0; for (int access = 0; access <= accessNames.GetUpperBound(0); access++) { SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]); // If the security isn't displayed as part of group section if ((currentAccess == SecurityAccessEnum.GroupMembers) && (!IsGroupForum)) { // Do not render this access item } else { // Generate cell holding access item name newRow = new TableRow(); newRow.CssClass = ((rowIndex % 2 == 0) ? "EvenRow" : "OddRow"); newCell = new TableCell(); newCell.Text = accessNames[access, 0].ToString(); newCell.Wrap = false; newCell.CssClass = "MatrixHeader"; newCell.Width = new Unit(28, UnitType.Percentage); newRow.Cells.Add(newCell); rowIndex++; // Render the permissions access items bool isAllowed = false; bool isDisabled = true; int permissionIndex = 0; for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 2); permission++) { newCell = new TableCell(); // Check if the currently processed access is applied for permission isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text); isDisabled = ((currentAccess == SecurityAccessEnum.AllUsers) && (permission == 1)) || (!Enable); // Disable column in roles grid if needed if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed) { gridMatrix.DisableColumn(permissionIndex); } // Insert the radio button for the current permission string permissionText = tblMatrix.Rows[0].Cells[permission + 1].Text; string elemId = ClientID + "_" + permission + "_" + access; newCell.Text = "<label style=\"display:none;\" for=\"" + elemId + "\">" + permissionText + "</label><input type=\"radio\" id=\"" + elemId + "\" name=\"" + permissionText + "\" onclick=\"" + ControlsHelper.GetPostBackEventReference(this, permission.ToString() + ";" + Convert.ToInt32(currentAccess).ToString()) + "\" " + ((isAllowed) ? "checked = \"checked\"" : "") + ((isDisabled) ? " disabled=\"disabled\"" : "") + "/>"; newCell.Wrap = false; newCell.Width = new Unit(12, UnitType.Percentage); newCell.HorizontalAlign = HorizontalAlign.Center; newRow.Cells.Add(newCell); permissionIndex++; } newCell = new TableCell(); newCell.Text = " "; newRow.Cells.Add(newCell); // Add the access row to the table tblMatrix.Rows.Add(newRow); } } // Check if forum has some roles assigned mNoRolesAvailable = !gridMatrix.HasData; // Get permission matrix for current forum resource if (!mNoRolesAvailable) { // Security - Role separator newRow = new TableRow(); newCell = new TableCell(); newCell.Text = " "; newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count)); newRow.Controls.Add(newCell); tblMatrix.Rows.Add(newRow); // Security - Role separator text newRow = new TableRow(); newCell = new TableCell(); newCell.CssClass = "MatrixLabel"; newCell.Text = GetString("SecurityMatrix.RolesAvailability"); newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count)); newRow.Controls.Add(newCell); tblMatrix.Rows.Add(newRow); } } } }
/// <summary> /// Creates group forum. /// </summary> /// <param name="group">Particular group info object</param> private void CreateGroupForum(GroupInfo group) { #region "Create forum group" // Get forum group code name string forumGroupCodeName = "Forums_group_" + group.GroupGUID; // Check if forum group with given name already exists if (ForumGroupInfoProvider.GetForumGroupInfo(forumGroupCodeName, SiteContext.CurrentSiteID) != null) { return; } // Create forum base URL string baseUrl = null; TreeNode groupDocument = TreeProvider.SelectSingleNode(group.GroupNodeGUID, DocumentContext.CurrentDocumentCulture.CultureCode, SiteContext.CurrentSiteName); if (groupDocument != null) { baseUrl = DocumentURLProvider.GetUrl(groupDocument.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS); } ForumGroupInfo forumGroupObj = new ForumGroupInfo(); const string suffix = " forums"; forumGroupObj.GroupDisplayName = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix; forumGroupObj.GroupName = forumGroupCodeName; forumGroupObj.GroupOrder = 0; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupGroupID = group.GroupID; forumGroupObj.GroupSiteID = SiteContext.CurrentSiteID; forumGroupObj.GroupBaseUrl = baseUrl; // Additional settings forumGroupObj.GroupEnableCodeSnippet = true; forumGroupObj.GroupEnableFontBold = true; forumGroupObj.GroupEnableFontColor = true; forumGroupObj.GroupEnableFontItalics = true; forumGroupObj.GroupEnableFontStrike = true; forumGroupObj.GroupEnableFontUnderline = true; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupEnableURL = true; forumGroupObj.GroupEnableImage = true; // Set forum group info ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj); #endregion #region "Create forum" string codeName = "General_discussion_group_" + group.GroupGUID; // Check if forum with given name already exists if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSiteID, group.GroupID) != null) { return; } // Create new forum object ForumInfo forumObj = new ForumInfo(); forumObj.ForumSiteID = SiteContext.CurrentSiteID; forumObj.ForumIsLocked = false; forumObj.ForumOpen = true; forumObj.ForumDisplayEmails = false; forumObj.ForumRequireEmail = false; forumObj.ForumDisplayName = "General discussion"; forumObj.ForumName = codeName; forumObj.ForumGroupID = forumGroupObj.GroupID; forumObj.ForumCommunityGroupID = group.GroupID; forumObj.ForumModerated = false; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = false; forumObj.SetValue("ForumHTMLEditor", null); // Set security forumObj.AllowAccess = SecurityAccessEnum.GroupMembers; forumObj.AllowAttachFiles = SecurityAccessEnum.GroupMembers; forumObj.AllowMarkAsAnswer = SecurityAccessEnum.GroupMembers; forumObj.AllowPost = SecurityAccessEnum.GroupMembers; forumObj.AllowReply = SecurityAccessEnum.GroupMembers; forumObj.AllowSubscribe = SecurityAccessEnum.GroupMembers; if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); } #endregion }
/// <summary> /// Generates the permission matrix for the current forum. /// </summary> private void CreateMatrix() { // Get forum resource info if (resForums == null) { resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); } // Get forum object if ((forum == null) && (ForumID > 0)) { forum = ForumInfoProvider.GetForumInfo(ForumID); } if ((resForums != null) && (forum != null)) { // Get permissions for the current forum resource DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resForums.ResourceID); if (DataHelper.DataSourceIsEmpty(permissions)) { ShowInformation(GetString("general.emptymatrix")); } else { TableHeaderRow headerRow = new TableHeaderRow(); headerRow.CssClass = "unigrid-head"; headerRow.TableSection = TableRowSection.TableHeader; TableCell newCell = new TableCell(); TableHeaderCell newHeaderCell = new TableHeaderCell(); newHeaderCell.CssClass = "first-column"; headerRow.Cells.Add(newHeaderCell); foreach (string permission in allowedPermissions) { DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'"); if (drArray.Length > 0) { DataRow dr = drArray[0]; newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = dr["PermissionDisplayName"].ToString(); newHeaderCell.ToolTip = dr["PermissionDescription"].ToString(); headerRow.Cells.Add(newHeaderCell); } else { throw new Exception("[Security matrix] Column '" + permission + "' cannot be found."); } } tblMatrix.Rows.Add(headerRow); // Render forum access permissions object[,] accessNames = new object[5, 2]; accessNames[0, 0] = GetString("security.nobody"); accessNames[0, 1] = SecurityAccessEnum.Nobody; accessNames[1, 0] = GetString("security.allusers"); accessNames[1, 1] = SecurityAccessEnum.AllUsers; accessNames[2, 0] = GetString("security.authenticated"); accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers; accessNames[3, 0] = GetString("security.groupmembers"); accessNames[3, 1] = SecurityAccessEnum.GroupMembers; accessNames[4, 0] = GetString("security.authorizedroles"); accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles; TableRow newRow = null; for (int access = 0; access <= accessNames.GetUpperBound(0); access++) { SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]); // If the security isn't displayed as part of group section if ((currentAccess == SecurityAccessEnum.GroupMembers) && (!IsGroupForum)) { // Do not render this access item } else { // Generate cell holding access item name newRow = new TableRow(); newCell = new TableCell(); newCell.Text = accessNames[access, 0].ToString(); newCell.CssClass = "matrix-header"; newRow.Cells.Add(newCell); // Render the permissions access items bool isAllowed = false; bool isEnabled = true; int permissionIndex = 0; for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++) { newCell = new TableCell(); // Check if the currently processed access is applied for permission isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text); isEnabled = ((currentAccess != SecurityAccessEnum.AllUsers) || (permission != 1)) && Enable; // Disable column in roles grid if needed if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed) { gridMatrix.DisableColumn(permissionIndex); } // Insert the radio button for the current permission var radio = new CMSRadioButton { Checked = isAllowed, Enabled = isEnabled, }; radio.Attributes.Add("onclick", ControlsHelper.GetPostBackEventReference(this, permission + ";" + Convert.ToInt32(currentAccess))); newCell.Controls.Add(radio); newRow.Cells.Add(newCell); permissionIndex++; } // Add the access row to the table tblMatrix.Rows.Add(newRow); } } // Check if forum has some roles assigned headTitle.Visible = gridMatrix.HasData; } } }
protected void Page_Load(object sender, EventArgs e) { bool process = true; if (!this.Visible || StopProcessing) { process = false; } fi = ForumInfoProvider.GetForumInfo(this.ForumID); replyPi = ForumPostInfoProvider.GetForumPostInfo(this.ReplyToPostID); editPi = ForumPostInfoProvider.GetForumPostInfo(this.EditPostID); if ((fi == null) && (editPi != null)) { fi = ForumInfoProvider.GetForumInfo(editPi.PostForumID); this.ForumID = fi.ForumID; } // Check whether the post still exists if (EditPostID > 0) { EditedObject = editPi; } // Check whether the post still exists if ((ForumID > 0) && (fi == null)) { RedirectToInformation("editedobject.notexists"); } #region "HTML Edtitor properties" // Set HTML editor properties htmlTemplateBody.AutoDetectLanguage = false; htmlTemplateBody.DefaultLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; htmlTemplateBody.EditorAreaCSS = ""; htmlTemplateBody.ToolbarSet = "Forum"; htmlTemplateBody.DisableObjectResizing = true; // Disable image resizing htmlTemplateBody.RemovePlugin("contextmenu"); // Disable context menu htmlTemplateBody.IsLiveSite = this.IsLiveSite; htmlTemplateBody.MediaDialogConfig.UseFullURL = true; htmlTemplateBody.LinkDialogConfig.UseFullURL = true; #endregion // Regular expression to validate email (e-mail is not required) rfvEmail.ValidationExpression = @"^([\w0-9_\-\+]+(\.[\w0-9_\-\+]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$"; if (fi != null) { if ((fi.ForumType == 0) && (replyPi == null)) { plcThreadType.Visible = true; } if (fi.ForumRequireEmail) { rfvEmailRequired.Enabled = true; rfvEmailRequired.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.emailRequireErrorMsg"); } #region "Forum text" rfvText.Enabled = !fi.ForumHTMLEditor; htmlTemplateBody.Visible = fi.ForumHTMLEditor; ucBBEditor.Visible = !fi.ForumHTMLEditor; if (fi.ForumHTMLEditor) { // Define customizable shortcuts Hashtable keystrokes = new Hashtable() { { "link", "CKEDITOR.CTRL + 76 /*L*/" }, { "bold", "CKEDITOR.CTRL + 66 /*B*/" }, { "italic", "CKEDITOR.CTRL + 73 /*I*/" }, { "underline", "CKEDITOR.CTRL + 85 /*U*/" } }; // Register script for HTML Editor forum buttons control if (!fi.ForumEnableURL) { htmlTemplateBody.RemoveButton("InsertUrl"); if (!fi.ForumEnableAdvancedURL) { // Remove the keyborad shortcut for the link insertion keystrokes.Remove("link"); } } if (!fi.ForumEnableImage) { htmlTemplateBody.RemoveButton("InsertImage"); } if (!fi.ForumEnableQuote) { htmlTemplateBody.RemoveButton("InsertQuote"); } if (!fi.ForumEnableAdvancedURL) { htmlTemplateBody.RemoveButton("InsertLink"); } if (!fi.ForumEnableAdvancedImage) { htmlTemplateBody.RemoveButton("InsertImageOrMedia"); } if (!fi.ForumEnableFontBold) { htmlTemplateBody.RemoveButton("Bold"); keystrokes.Remove("bold"); } if (!fi.ForumEnableFontItalics) { htmlTemplateBody.RemoveButton("Italic"); keystrokes.Remove("italic"); } if (!fi.ForumEnableFontUnderline) { htmlTemplateBody.RemoveButton("Underline"); keystrokes.Remove("underline"); } if (!fi.ForumEnableFontStrike) { htmlTemplateBody.RemoveButton("Strike"); } if (!fi.ForumEnableFontColor) { htmlTemplateBody.RemoveButton("TextColor"); htmlTemplateBody.RemoveButton("BGColor"); } // Generate keystrokes string for the CK Editor StringBuilder sb = new StringBuilder("[ [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ], [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], [ CKEDITOR.ALT + ( CKEDITOR.env.ie || CKEDITOR.env.webkit ? 189 : 109 ) /*-*/, 'toolbarCollapse' ], [ CKEDITOR.ALT + 48 /*0*/, 'a11yHelp' ]"); string format = ", [ {0}, '{1}' ]"; foreach (DictionaryEntry entry in keystrokes) { sb.Append(String.Format(format, entry.Value, entry.Key)); } sb.Append("]"); htmlTemplateBody.Keystrokes = sb.ToString(); } else { ucBBEditor.IsLiveSite = this.IsLiveSite; ucBBEditor.ShowImage = fi.ForumEnableImage; ucBBEditor.ShowQuote = fi.ForumEnableQuote; ucBBEditor.ShowBold = fi.ForumEnableFontBold; ucBBEditor.ShowItalic = fi.ForumEnableFontItalics; ucBBEditor.ShowUnderline = fi.ForumEnableFontUnderline; ucBBEditor.ShowStrike = fi.ForumEnableFontStrike; ucBBEditor.ShowCode = fi.ForumEnableCodeSnippet; ucBBEditor.ShowColor = fi.ForumEnableFontColor; ucBBEditor.ShowURL = fi.ForumEnableURL; ucBBEditor.ShowAdvancedImage = fi.ForumEnableAdvancedImage; ucBBEditor.ShowAdvancedURL = fi.ForumEnableAdvancedURL; // WAI validation lblText.AssociatedControlClientID = ucBBEditor.TextArea.ClientID; } #endregion } // Do not show subscribe checkbox if no post can't be added under the post if ((replyPi != null) && (replyPi.PostLevel >= ForumPostInfoProvider.MaxPostLevel - 1)) { plcSubscribe.Visible = false; } #region "Resources" rfvEmail.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.emailErrorMsg"); rfvSubject.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.subjectErrorMsg"); lblText.Text = GetString("Forums_WebInterface_ForumNewPost.text"); rfvText.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.textErrorMsg"); rfvUserName.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.usernameErrorMsg"); btnOk.Text = GetString("general.ok"); btnCancel.Text = GetString("general.cancel"); btnPreview.Text = GetString("Forums_WebInterface_ForumNewPost.Preview"); lblSubscribe.Text = GetString("Forums_WebInterface_ForumNewPost.Subscription"); lblSignature.Text = GetString("Forums_WebInterface_ForumNewPost.Signature"); lblPostIsAnswerLabel.Text = GetString("ForumPost_Edit.PostIsAnswer"); lblPostIsNotAnswerLabel.Text = GetString("ForumPost_Edit.PostIsNotAnswer"); #endregion if (!this.IsLiveSite && !RequestHelper.IsPostBack() && process) { ReloadData(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Visible) { EnableViewState = false; } pnlGeneral.GroupingText = GetString("general.general"); pnlAdvanced.GroupingText = GetString("forums.advancedsettings"); pnlSecurity.GroupingText = GetString("forums.securitysettings"); pnlEditor.GroupingText = GetString("forums.editorsettings"); pnlOptIn.GroupingText = GetString("general.OptIn"); txtForumDisplayName.IsLiveSite = IsLiveSite; txtForumDescription.IsLiveSite = IsLiveSite; txtOptInURL.IsLiveSite = IsLiveSite; // Hide code name in simple mode if (DisplayMode == ControlDisplayModeEnum.Simple) { plcCodeName.Visible = false; plcUseHtml.Visible = false; } // Control initializations rfvForumDisplayName.ErrorMessage = GetString("Forum_General.EmptyDisplayName"); rfvForumName.ErrorMessage = GetString("Forum_General.EmptyCodeName"); // Get strings for labels lblForumOpen.Text = GetString("Forum_Edit.ForumOpenLabel"); lblForumLocked.Text = GetString("Forum_Edit.ForumLockedLabel"); lblForumDisplayEmails.Text = GetString("Forum_Edit.ForumDisplayEmailsLabel"); lblForumRequireEmail.Text = GetString("Forum_Edit.ForumRequireEmailLabel"); lblForumDisplayName.Text = GetString("Forum_Edit.ForumDisplayNameLabel"); lblForumName.Text = GetString("Forum_Edit.ForumNameLabel"); lblUseHTML.Text = GetString("Forum_Edit.UseHtml"); lblBaseUrl.Text = GetString("Forum_Edit.lblBaseUrl"); lblCaptcha.Text = GetString("Forum_Edit.useCaptcha"); lblUnsubscriptionUrl.Text = GetString("Forum_Edit.lblUnsubscriptionUrl"); chkInheritBaseUrl.Text = GetString("Forum_Edit.InheritBaseUrl"); chkInheritUnsubscribeUrl.Text = GetString("Forum_Edit.InheritUnsupscriptionUrl"); chkEnableOptIn.NotSetChoice.Text = chkSendOptInConfirmation.NotSetChoice.Text = chkForumRequireEmail.NotSetChoice.Text = chkForumDisplayEmails.NotSetChoice.Text = chkUseHTML.NotSetChoice.Text = chkCaptcha.NotSetChoice.Text = chkAuthorEdit.NotSetChoice.Text = chkAuthorDelete.NotSetChoice.Text = GetString("forum.settings.inheritfromgroup") + DEFAULT_SUFFIX; string currentForum = GetString("Forum_Edit.NewItemCaption"); // Create scripts script = @" function LoadOption(clientId, value) { var obj = document.getElementById(clientId); if(obj!=null) { obj.checked = value; } } function LoadSetting(clientId, value, enabled, type) { SetInheritance(clientId, value, type); var obj = document.getElementById(clientId); if (obj != null) { obj.disabled = enabled; } } function SetInheritance(clientIds, values, type) { var idArray = clientIds.split(';'); var valueArray = values.toString().split(';'); for(var i = 0;i<idArray.length;i++) { var clientId = idArray[i]; var value = valueArray[i]; var obj = document.getElementById(clientId); if (obj != null) { obj.disabled = !obj.disabled; if (obj.disabled) { if (type == 'txt') { obj.value = value; } else { obj.checked = (value == 'true'); } } } } } "; ltrScript.Text += ScriptHelper.GetScript(script); script = ""; // Load object info from database ForumInfo forumObj = ForumInfoProvider.GetForumInfo(mForumId); if (forumObj != null) { currentForum = forumObj.ForumName; groupId = forumObj.ForumGroupID; if (!IsLiveSite && !RequestHelper.IsPostBack()) { ReloadData(forumObj); } else { // Handle base and unsubscription URLs txtBaseUrl.Enabled = !chkInheritBaseUrl.Checked; txtUnsubscriptionUrl.Enabled = !chkInheritUnsubscribeUrl.Checked; txtMaxAttachmentSize.Enabled = !chkInheritMaxAttachmentSize.Checked; txtIsAnswerLimit.Enabled = !chkInheritIsAnswerLimit.Checked; txtImageMaxSideSize.Enabled = !chkInheritMaxSideSize.Checked; } ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forumObj.ForumGroupID); // Set default values if (fgi != null) { chkForumRequireEmail.SetDefaultValue(fgi.GroupRequireEmail); chkForumDisplayEmails.SetDefaultValue(fgi.GroupDisplayEmails); chkUseHTML.SetDefaultValue(fgi.GroupHTMLEditor); chkCaptcha.SetDefaultValue(fgi.GroupUseCAPTCHA); chkAuthorDelete.SetDefaultValue(fgi.GroupAuthorDelete); chkAuthorEdit.SetDefaultValue(fgi.GroupAuthorEdit); chkEnableOptIn.SetDefaultValue(fgi.GroupEnableOptIn); chkSendOptInConfirmation.SetDefaultValue(fgi.GroupSendOptInConfirmation); } } ltrScript.Text += ScriptHelper.GetScript(script); // Show/hide URL textboxes plcBaseAndUnsubUrl.Visible = (DisplayMode != ControlDisplayModeEnum.Simple); }
/// <summary> /// Creates department forum group. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentForumGroup(TreeNode departmentNode) { // Set general values string departmentName = departmentNode.GetDocumentName(); string suffix = ""; #region "Create forum group" // Get forum group code name string groupCodeName = "Department_" + departmentNode.NodeGUID; // Check if forum group with given name already exists if (ForumGroupInfoProvider.GetForumGroupInfo(groupCodeName, SiteContext.CurrentSiteID) != null) { return; } // Create base URL for forums string baseUrl = DocumentURLProvider.GetUrl(departmentNode.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS); ForumGroupInfo forumGroupObj = new ForumGroupInfo(); forumGroupObj.GroupDescription = "Forum group for " + departmentName + " department."; suffix = " forum group"; forumGroupObj.GroupDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumGroupObj.GroupName = groupCodeName; forumGroupObj.GroupOrder = 0; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupSiteID = SiteContext.CurrentSiteID; forumGroupObj.GroupBaseUrl = baseUrl; // Additional settings forumGroupObj.GroupEnableCodeSnippet = true; forumGroupObj.GroupEnableFontBold = true; forumGroupObj.GroupEnableFontColor = true; forumGroupObj.GroupEnableFontItalics = true; forumGroupObj.GroupEnableFontStrike = true; forumGroupObj.GroupEnableFontUnderline = true; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupEnableURL = true; forumGroupObj.GroupEnableImage = true; ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj); #endregion #region "Create forum" string codeName = "Default_department_" + departmentNode.NodeGUID; // Check if forum with given name already exists if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSite.SiteID) != null) { return; } ForumInfo forumObj = new ForumInfo(); forumObj.ForumSiteID = SiteContext.CurrentSiteID; forumObj.ForumIsLocked = false; forumObj.ForumOpen = true; forumObj.ForumDisplayEmails = false; forumObj.ForumDescription = "Forum for " + departmentName + " department."; forumObj.ForumRequireEmail = false; suffix = " forum"; forumObj.ForumDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumObj.ForumName = codeName; forumObj.ForumGroupID = forumGroupObj.GroupID; forumObj.ForumModerated = false; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = false; forumObj.SetValue("ForumHTMLEditor", null); // Set security forumObj.AllowAccess = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowAttachFiles = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowMarkAsAnswer = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowPost = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowReply = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowSubscribe = SecurityAccessEnum.AuthorizedRoles; if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); } #endregion }
protected void Page_Load(object sender, EventArgs e) { DataSet results = GetSearchDataSet(); // Bind the results to the control displaying it if (!DataHelper.DataSourceIsEmpty(results)) { this.uniForumPosts.DataSource = results; this.uniForumPosts.DataBind(); #region "Results info" string path = String.Empty; string[] splited = null; // Search in threads if (this.SearchInThreads != String.Empty) { splited = this.SearchInThreads.Split(new string[1] { ";" }, StringSplitOptions.RemoveEmptyEntries); if ((splited != null) && (splited.Length == 1)) { // Get post info ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(splited[0], 0)); if (fpi != null) { // Path is post subject path = HTMLHelper.HTMLEncode(fpi.PostSubject); // Get forum info ForumInfo fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID); if (fi != null) { // Path is forum display name and post subject path = HTMLHelper.HTMLEncode(fi.ForumDisplayName) + pathSeparator + path; // Get forum group info ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { // Path is combination of forum group display name, forum display name and post subject path = HTMLHelper.HTMLEncode(fgi.GroupDisplayName) + pathSeparator + path; } } path = GetString("ForumSearch.InThread") + path; } } } // Search in forums else if (this.SearchInForums != String.Empty) { splited = this.SearchInForums.Split(new string[1] { ";" }, StringSplitOptions.RemoveEmptyEntries); if ((splited != null) && (splited.Length == 1)) { // Get forum info ForumInfo fi = ForumInfoProvider.GetForumInfo(ValidationHelper.GetInteger(splited[0], 0)); if (fi != null) { // Path is forum display name path = HTMLHelper.HTMLEncode(fi.ForumDisplayName); // Get forum group info ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { // Path is from group display name and forum group display name path = HTMLHelper.HTMLEncode(fgi.GroupDisplayName) + pathSeparator + path; } path = GetString("ForumSearch.InForum") + path; } } } // Search in forum groups else if (this.SearchInGroups != null) { splited = this.SearchInGroups.Split(new string[1] { ";" }, StringSplitOptions.RemoveEmptyEntries); if ((splited != null) && (splited.Length == 1)) { // Get forum group info ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(splited[0], this.SiteID, this.CommunityGroupID); if (fgi != null) { // Path is forum group display name path = HTMLHelper.HTMLEncode(fgi.GroupDisplayName); path = GetString("ForumSearch.InForumGroup") + path; } } } // Format results info ltlResultsInfo.Text = "<div class=\"ForumSearchResultsInfo\">" + String.Format(GetString("ForumSearch.SearchResultsInfo"), HTMLHelper.HTMLEncode(QueryHelper.GetString("searchtext", "")), path, results.Tables[0].Rows.Count) + "</div>"; #endregion } else { // No results lblNoResults.Visible = true; plcResults.Visible = false; lblNoResults.Text = this.SearchNoResults; } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check MODIFY permission if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } // Check required fields string errorMessage = new Validator().NotEmpty(txtForumDisplayName.Text, GetString("Forum_General.EmptyDisplayName")).Result; if ((errorMessage == String.Empty) && (DisplayMode != ControlDisplayModeEnum.Simple)) { errorMessage = new Validator().NotEmpty(txtForumName.Text, GetString("Forum_General.EmptyCodeName")).IsCodeName(txtForumName.Text.Trim(), GetString("general.errorcodenameinidentifierformat")).Result; } if (!String.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return; } // Forum must be on some site if (CMSContext.CurrentSite != null) { int communityGroupId = 0; ForumInfo fi = ForumInfoProvider.GetForumInfo(mForumId); if (fi != null) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { communityGroupId = fgi.GroupGroupID; } } ForumInfo forumObj = ForumInfoProvider.GetForumInfo(txtForumName.Text.Trim(), CMSContext.CurrentSiteID, communityGroupId); // If forum exists if ((forumObj == null) || (forumObj.ForumID == mForumId)) { if (forumObj == null) { forumObj = ForumInfoProvider.GetForumInfo(mForumId); } if (forumObj != null) { if (txtForumDisplayName.Text.Trim() != forumObj.ForumDisplayName) { // Refresh a breadcrumb if used in the tabs layout ScriptHelper.RefreshTabHeader(Page, GetString("general.general")); } // Set properties forumObj.ForumIsLocked = chkForumLocked.Checked; forumObj.ForumOpen = chkForumOpen.Checked; chkForumDisplayEmails.SetThreeStateValue(forumObj, "ForumDisplayEmails"); forumObj.ForumDescription = txtForumDescription.Text.Trim(); chkForumRequireEmail.SetThreeStateValue(forumObj, "ForumRequireEmail"); forumObj.ForumDisplayName = txtForumDisplayName.Text.Trim(); chkCaptcha.SetThreeStateValue(forumObj, "ForumUseCAPTCHA"); // If display mode is default set other properties if (DisplayMode != ControlDisplayModeEnum.Simple) { chkUseHTML.SetThreeStateValue(forumObj, "ForumHTMLEditor"); forumObj.ForumName = txtForumName.Text.Trim(); // Base URL if (chkInheritBaseUrl.Checked) { forumObj.SetValue("ForumBaseUrl", null); } else { forumObj.ForumBaseUrl = txtBaseUrl.Text; } // Unsubcription URL if (chkInheritUnsubscribeUrl.Checked) { forumObj.SetValue("ForumUnsubscriptionUrl", null); } else { forumObj.ForumUnsubscriptionUrl = txtUnsubscriptionUrl.Text.Trim(); } } // Author can delete own posts chkAuthorDelete.SetThreeStateValue(forumObj, "ForumAuthorDelete"); // Author can delete own posts chkAuthorEdit.SetThreeStateValue(forumObj, "ForumAuthorEdit"); // Image max side size if (chkInheritMaxSideSize.Checked) { forumObj.SetValue("ForumImageMaxSideSize", null); } else { forumObj.ForumImageMaxSideSize = ValidationHelper.GetInteger(txtImageMaxSideSize.Text, 400); } // Answer limit if (chkInheritIsAnswerLimit.Checked) { forumObj.SetValue("ForumIsAnswerLimit", null); } else { forumObj.ForumIsAnswerLimit = ValidationHelper.GetInteger(txtIsAnswerLimit.Text, 5); } // Forum type if (chkInheritType.Checked) { forumObj.SetValue("ForumType", null); } else { forumObj.ForumType = (radTypeChoose.Checked ? 0 : (radTypeDiscussion.Checked ? 1 : 2)); } // Inherited values if (chkInheritBaseUrl.Checked) { forumObj.ForumBaseUrl = null; } if (chkInheritUnsubscribeUrl.Checked) { forumObj.ForumUnsubscriptionUrl = null; } if (chkInheritMaxAttachmentSize.Checked) { forumObj.ForumAttachmentMaxFileSize = -1; } else { forumObj.ForumAttachmentMaxFileSize = ValidationHelper.GetInteger(txtMaxAttachmentSize.Text, 0); } // Double opt-in forumObj.ForumOptInApprovalURL = chkInheritOptInURL.Checked ? null : txtOptInURL.Text.Trim(); chkEnableOptIn.SetThreeStateValue(forumObj, "ForumEnableOptIn"); chkSendOptInConfirmation.SetThreeStateValue(forumObj, "ForumSendOptInConfirmation"); // Only if on-line marketing is available if (plcOnline.Visible) { if (chkInheritLogActivity.Checked) { forumObj.SetValue("ForumLogActivity", null); } else { forumObj.ForumLogActivity = chkLogActivity.Checked; } } #region "Discussion" if (chkInheritDiscussion.Checked) { // Inherited forumObj.SetValue("ForumDiscussionActions", null); } else { // Set discussion properties forumObj.ForumEnableQuote = chkEnableQuote.Checked; forumObj.ForumEnableFontBold = chkEnableBold.Checked; forumObj.ForumEnableFontItalics = chkEnableItalic.Checked; forumObj.ForumEnableFontUnderline = chkEnableUnderline.Checked; forumObj.ForumEnableFontStrike = chkEnableStrike.Checked; forumObj.ForumEnableFontColor = chkEnableColor.Checked; forumObj.ForumEnableCodeSnippet = chkEnableCode.Checked; forumObj.ForumEnableAdvancedImage = radImageAdvanced.Checked; forumObj.ForumEnableAdvancedURL = radUrlAdvanced.Checked; forumObj.ForumEnableImage = radImageSimple.Checked; forumObj.ForumEnableURL = radUrlSimple.Checked; } #endregion ForumInfoProvider.SetForumInfo(forumObj); ReloadData(); RaiseOnSaved(); ShowChangesSaved(); } else { // Forum does not exist ShowError(GetString("Forum_Edit.ForumDoesNotExist")); } } else { // Forum already exists ShowError(GetString("Forum_Edit.ForumAlreadyExists")); } } }
protected void Page_Load(object sender, EventArgs e) { EnsureEditedObject(); // Show back link if is opened from listing if (!String.IsNullOrEmpty(ListingPost) && (PostInfo != null)) { mListingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(ListingPost); } mThreadMove = Page.LoadUserControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; mThreadMove.ID = "ctrlThreadMove"; mThreadMove.IsLiveSite = IsLiveSite; plcThreadMove.Controls.Add(mThreadMove); if (!Visible) { EnableViewState = false; } PostEdit1.OnCancelClick += ForumNewPost1_OnCancelClick; PostEdit1.OnCheckPermissions += PostEdit1_OnCheckPermissions; PostEdit1.IsLiveSite = false; if (Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = PostID; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { //New thread if (NewForumPostIsBeingCreated) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { // ReSharper disable once PossibleNullReferenceException - edited object is ensured => no null reference is possible ForumInfo fi = ForumInfoProvider.GetForumInfo(PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + mListingParameter + "' }}\n")); } InitializeMenu(); ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = ForumID; ForumPost1.PostID = PostID; ForumPost1.DisplayOnly = true; if (PostInfo.PostAttachmentCount > 0) { ReloadAttachmentData(PostID); } } } }
protected void Page_Load(object sender, EventArgs e) { // Show back link if is opened from listing if (!String.IsNullOrEmpty(ListingPost) && (PostInfo != null)) { listingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(ListingPost); lnkBackListing.Text = GetString("Forums.BackToListing"); lnkBackListing.NavigateUrl = "javascript:BackToListing();"; pnlListing.Visible = true; pnlListing.Attributes.Add("style", "border-bottom:1px solid #CCCCCC;font-size:12px; padding:5px 10px;"); } ThreadMove1 = Page.LoadUserControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; ThreadMove1.ID = "ctrlThreadMove"; ThreadMove1.IsLiveSite = IsLiveSite; plcThreadMove.Controls.Add(ThreadMove1); if (!Visible) { EnableViewState = false; } PostEdit1.OnCancelClick += new EventHandler(ForumNewPost1_OnCancelClick); PostEdit1.OnCheckPermissions += new CheckPermissionsEventHandler(PostEdit1_OnCheckPermissions); PostEdit1.IsLiveSite = false; if (Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); NewThreadTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/newthread.png"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = PostID; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += new EventHandler(ForumNewPost1_OnInsertPost); } else { //New thread if (ForumID != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); NewThreadTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/newthread.png"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += new EventHandler(ForumNewPost1_OnInsertPost); } else { // Selected post PostTitle.TitleText = GetString("ForumPost_View.PostTitleText"); PostTitle.TitleImage = GetImageUrl("Objects/Forums_ForumPost/object.png"); PostAttachmentTitle.TitleText = GetString("ForumPost_View.PostAttachmentTitle"); PostAttachmentTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/attachments.png"); if (BrowserHelper.IsIE()) { upload.Style.Add("height", "24px;"); } if (PostInfo == null) { pnlMenu.Visible = false; return; } ForumInfo fi = ForumInfoProvider.GetForumInfo(PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + listingParameter + "' }}\n")); } //Create menu using inserted skmMenu control InitializeMenu(); ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = ForumID; ForumPost1.PostID = PostID; ForumPost1.DisplayOnly = true; if ((PostInfo != null) && (PostInfo.PostAttachmentCount > 0)) { ReloadAttachmentData(PostID); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Visible) { this.EnableViewState = false; } txtForumDisplayName.IsLiveSite = this.IsLiveSite; txtForumDescription.IsLiveSite = this.IsLiveSite; // Hide code name in simple mode if (DisplayMode == ControlDisplayModeEnum.Simple) { this.plcCodeName.Visible = false; this.plcUseHtml.Visible = false; } // Control initializations this.rfvForumDisplayName.ErrorMessage = GetString("Forum_General.EmptyDisplayName"); this.rfvForumName.ErrorMessage = GetString("Forum_General.EmptyCodeName"); // Get strings for labels this.lblForumOpen.Text = GetString("Forum_Edit.ForumOpenLabel"); this.lblForumLocked.Text = GetString("Forum_Edit.ForumLockedLabel"); this.lblForumDisplayEmails.Text = GetString("Forum_Edit.ForumDisplayEmailsLabel"); this.lblForumRequireEmail.Text = GetString("Forum_Edit.ForumRequireEmailLabel"); this.lblForumDisplayName.Text = GetString("Forum_Edit.ForumDisplayNameLabel"); this.lblForumName.Text = GetString("Forum_Edit.ForumNameLabel"); this.lblUseHTML.Text = GetString("Forum_Edit.UseHtml"); this.lblBaseUrl.Text = GetString("Forum_Edit.lblBaseUrl"); this.lblCaptcha.Text = GetString("Forum_Edit.useCaptcha"); this.lblUnsubscriptionUrl.Text = GetString("Forum_Edit.lblUnsubscriptionUrl"); this.chkInheritBaseUrl.Text = GetString("Forum_Edit.InheritBaseUrl"); this.chkInheritUnsubscribeUrl.Text = GetString("Forum_Edit.InheritUnsupscriptionUrl"); this.btnOk.Text = GetString("General.OK"); string currentForum = GetString("Forum_Edit.NewItemCaption"); // Create scripts script = @" function LoadOption(clientId, value) { var obj = document.getElementById(clientId); if(obj!=null) { obj.checked = value; } } function LoadSetting(clientId, value, enabled, type) { SetInheritance(clientId, value, type); var obj = document.getElementById(clientId); if (obj != null) { obj.disabled = enabled; } } function SetInheritance(clientIds, values, type) { var idArray = clientIds.split(';'); var valueArray = values.toString().split(';'); for(var i = 0;i<idArray.length;i++) { var clientId = idArray[i]; var value = valueArray[i]; var obj = document.getElementById(clientId); if (obj != null) { obj.disabled = !obj.disabled; if (obj.disabled) { if (type == 'txt') { obj.value = value; } else { obj.checked = (value == 'true'); } } } } } "; this.ltrScript.Text += ScriptHelper.GetScript(script); script = ""; // Load object info from database ForumInfo forumObj = ForumInfoProvider.GetForumInfo(this.mForumId); if (forumObj != null) { currentForum = forumObj.ForumName; groupId = forumObj.ForumGroupID; if (!this.IsLiveSite && !RequestHelper.IsPostBack()) { ReloadData(forumObj); } else { // Handle base and unsubscription urls txtBaseUrl.Enabled = !chkInheritBaseUrl.Checked; txtUnsubscriptionUrl.Enabled = !chkInheritUnsubscribeUrl.Checked; this.txtMaxAttachmentSize.Enabled = !chkInheritMaxAttachmentSize.Checked; this.txtIsAnswerLimit.Enabled = !chkInheritIsAnswerLimit.Checked; this.txtImageMaxSideSize.Enabled = !chkInheritMaxSideSize.Checked; } } this.ltrScript.Text += ScriptHelper.GetScript(script); // Show/hide URL textboxes plcBaseAndUnsubUrl.Visible = (DisplayMode != ControlDisplayModeEnum.Simple); }
/// <summary> /// Creates tree node. /// </summary> /// <param name="sourceNode">Node with source data</param> /// <param name="index">Node index</param> protected TreeNode CreateNode(ForumPostTreeNode sourceNode, int index) { if (sourceNode == null) { return(null); } // Create tree node TreeNode newNode = new TreeNode(); DataRow dr = (DataRow)sourceNode.ItemData; // Check whether item data are defined, if not it is root node if (dr != null) { int sourceNodeId = (int)dr["PostID"]; int nodeLevel = (int)dr["PostLevel"]; // Check on maximum post in tree if (!UseMaxPostNodes || (index < MaxPostNodes) || (MaxPostNodes <= 0)) { #region "Set node values and appearance" newNode.Value = sourceNodeId.ToString(); newNode.SelectAction = TreeNodeSelectAction.None; bool isApproved = ValidationHelper.GetBoolean(dr["PostApproved"], false); string postSubject = (string)dr["PostSubject"]; string cssClass = ItemCssClass; // Add CSS class for unapproved posts if (HighlightUnApprove && !isApproved) { cssClass += " PostUnApproved"; } string statusIcons = ""; if (OnGetStatusIcons != null) { statusIcons = OnGetStatusIcons(sourceNode); } // Set by display mode switch (ShowMode) { // Dynamic detail mode case ShowModeEnum.DynamicDetailMode: newNode.Text = CreateDynamicDetailModeNode(dr, cssClass, statusIcons, postSubject); break; // Detail mode case ShowModeEnum.DetailMode: newNode.Text = CreateDetailModeNode(dr); break; // Tree mode default: if (Selected == sourceNodeId) { cssClass = SelectedItemCssClass; string spanId = String.Empty; if (AdministrationMode) { spanId = "id=\"treeSelectedNode\""; } newNode.Text = String.Format("<span {0} class=\"{1}\" onclick=\"ShowPost({2}); SelectForumNode(this);\"><span class=\"Name\">{4}{3}</span></span>", spanId, cssClass, newNode.Value, statusIcons, HTMLHelper.HTMLEncode(postSubject)); } else { newNode.Text = String.Format("<span class=\"{0}\" onclick=\"ShowPost({1}); SelectForumNode(this);\"><span class=\"Name\">{3}{2}</span></span>", cssClass, newNode.Value, statusIcons, HTMLHelper.HTMLEncode(postSubject)); } break; } #endregion if (!ExpandTree) { #region "Populate deeper levels on demand" // Check if can expand string childCountColumn = "PostThreadPosts"; // Check if unapproved posts can be included if (AdministrationMode || UserIsModerator) { childCountColumn = "PostThreadPostsAbsolute"; } int childNodesCount = ValidationHelper.GetInteger(dr[childCountColumn], 0); // If the post is thread(level = 0) then childnodes count 1 means no real child-post if ((childNodesCount == 0) || ((childNodesCount == 1) && (nodeLevel == 0))) { newNode.PopulateOnDemand = false; // No children -> expand newNode.Expanded = true; } else { if (!sourceNode.ChildNodesLoaded) { newNode.PopulateOnDemand = true; newNode.Expanded = false; } } #endregion #region "Expand nodes on the current path" // If preselect is set = first load if (RegularLoad) { string currentNodePath = (string)dr["PostIDPath"]; string currentSelectedPath = String.Empty; if (SelectedPost != null) { currentSelectedPath = SelectedPost.PostIDPath; } // Expand if node is on the path if (currentSelectedPath.StartsWithCSafe(currentNodePath)) { // Raise OnTreeNodePopulate newNode.PopulateOnDemand = true; newNode.Expanded = true; } else { newNode.Expanded = false; } } #endregion } else { // Populate will be called on each node newNode.PopulateOnDemand = true; newNode.Expanded = true; } } else { string parentNodeId = ValidationHelper.GetString(dr["PostParentID"], ""); newNode.Value = sourceNodeId.ToString(); newNode.Text = MaxTreeNodeText.Replace("##PARENTNODEID##", parentNodeId); newNode.SelectAction = TreeNodeSelectAction.None; } } // Root node populate by default else { // Root node as forum display name ForumInfo fi = ForumInfoProvider.GetForumInfo(ForumID); if (fi != null) { newNode.Text = "<span class=\"" + ItemCssClass + "\" onclick=\"ShowPost('-1'); SelectForumNode(this); \"><span class=\"Name\">" + HTMLHelper.HTMLEncode(fi.ForumDisplayName) + "</span></span>"; newNode.Value = "0"; newNode.SelectAction = TreeNodeSelectAction.None; } newNode.PopulateOnDemand = true; newNode.Expanded = true; } return(newNode); }
/// <summary> /// Loads the forums DropDownList for topic move. /// </summary> private void LoadMoveTopicDropdown() { if (drpMoveToForum.Items.Count > 0) { return; } ForumPostInfo fpi = ForumContext.CurrentThread; if ((fpi == null) && (CurrentThread > 0)) { fpi = ForumPostInfoProvider.GetForumPostInfo(CurrentThread); } if (fpi != null) { bool isOk = AdminMode || ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID == fpi.PostForumID)); if (isOk) { var currentForumId = fpi.PostForumID; ForumInfo fi = ForumInfoProvider.GetForumInfo(currentForumId); if (fi != null) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { var whereCondition = new WhereCondition().WhereNotStartsWith("GroupName", "AdHoc").WhereEquals("GroupSiteID", SiteID); if (fgi.GroupGroupID > 0) { whereCondition.WhereEquals("GroupGroupID", fgi.GroupGroupID); } else { whereCondition.WhereNull("GroupGroupID"); } DataSet dsGroups = ForumGroupInfoProvider.GetForumGroups().Where(whereCondition).OrderBy("GroupDisplayName").Columns("GroupID, GroupDisplayName"); if (!DataHelper.DataSourceIsEmpty(dsGroups)) { Hashtable forums = new Hashtable(); // Get all forums for selected groups var groupWhereCondition = new WhereCondition().WhereIn("ForumGroupID", new ObjectQuery <ForumGroupInfo>().Where(whereCondition).Column("GroupID")); DataSet dsForums = ForumInfoProvider.GetForums() .WhereEquals("ForumOpen", 1) .WhereNotEquals("ForumID", currentForumId) .Where(groupWhereCondition) .OrderBy("ForumDisplayName") .Columns("ForumID, ForumDisplayName, ForumGroupID") .TypedResult; if (!DataHelper.DataSourceIsEmpty(dsForums)) { // Load forums into hash table foreach (DataRow drForum in dsForums.Tables[0].Rows) { int groupId = Convert.ToInt32(drForum["ForumGroupID"]); List <string[]> forumNames = forums[groupId] as List <string[]> ?? new List <string[]>(); forumNames.Add(new[] { Convert.ToString(drForum["ForumDisplayName"]), Convert.ToString(drForum["ForumID"]) }); forums[groupId] = forumNames; } } foreach (DataRow dr in dsGroups.Tables[0].Rows) { int groupId = Convert.ToInt32(dr["GroupId"]); List <string[]> forumNames = forums[groupId] as List <string[]>; if (forumNames != null) { // Add forum group item if some forum ListItem li = new ListItem(Convert.ToString(dr["GroupDisplayName"]), "0"); li.Attributes.Add("disabled", "disabled"); drpMoveToForum.Items.Add(li); // Add forum items foreach (string[] forum in forumNames) { // Add forum to DDL drpMoveToForum.Items.Add(new ListItem(" \xA0\xA0\xA0\xA0 " + forum[0], forum[1])); } } } // Display message if no forum exists if (drpMoveToForum.Items.Count == 0) { plcMoveInner.Visible = false; ShowInformation(GetString("Forums.NoForumToMoveIn")); } } } } } } }
/// <summary> /// PreRender action on which security settings are set. /// </summary> private void Page_PreRender(object sender, EventArgs e) { if ((Form == null) || !mDocumentSaved) { return; } TreeNode editedNode = Form.EditedObject as TreeNode; // Create or rebuild department content index CreateDepartmentContentSearchIndex(editedNode); if ((editedNode == null) || !editedNode.NodeIsACLOwner) { return; } ForumInfo fi = ForumInfoProvider.GetForumInfo("Default_department_" + editedNode.NodeGUID, SiteContext.CurrentSiteID); MediaLibraryInfo mi = MediaLibraryInfoProvider.GetMediaLibraryInfo("Department_" + editedNode.NodeGUID, SiteContext.CurrentSiteName); // Check if forum of media library exists if ((fi == null) && (mi == null)) { return; } // Get allowed roles ID int aclID = ValidationHelper.GetInteger(editedNode.GetValue("NodeACLID"), 0); DataSet listRoles = AclItemInfoProvider.GetAllowedRoles(aclID, NodePermissionsEnum.Read, "RoleID"); string roleIDs = null; if (!DataHelper.DataSourceIsEmpty(listRoles)) { IList <string> roles = DataHelper.GetStringValues(listRoles.Tables[0], "RoleID"); roleIDs = TextHelper.Join(";", roles); } // Set permissions for forum if (fi != null) { // Get resource object ResourceInfo resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); // Get permissions IDs DataSet dsForumPerm = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resForums.ResourceID + " AND (PermissionName != '" + CMSAdminControl.PERMISSION_READ + "' AND PermissionName != '" + CMSAdminControl.PERMISSION_MODIFY + "')", null, 0, "PermissionID"); string forumPermissions = null; if (!DataHelper.DataSourceIsEmpty(dsForumPerm)) { foreach (DataRow drForumPerm in dsForumPerm.Tables[0].Rows) { forumPermissions += drForumPerm["PermissionID"] + ";"; } forumPermissions = forumPermissions.TrimEnd(';'); } // Delete old permissions apart attach file permission ForumRoleInfoProvider.DeleteAllRoles("ForumID = " + fi.ForumID + " AND PermissionID IN (" + forumPermissions.Replace(";", ", ") + ")"); // Set forum permissions ForumRoleInfoProvider.SetPermissions(fi.ForumID, roleIDs, forumPermissions); // Log staging task SynchronizationHelper.LogObjectChange(fi, TaskTypeEnum.UpdateObject); } // Set permissions for media library if (mi == null) { return; } // Get resource object ResourceInfo resMediaLibs = ResourceInfoProvider.GetResourceInfo("CMS.MediaLibrary"); // Get permissions IDs DataSet dsMediaLibPerm = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resMediaLibs.ResourceID + " AND (PermissionName = 'LibraryAccess' OR PermissionName = 'FileCreate')", null, 0, "PermissionID"); string mediaLibPermissions = null; if (!DataHelper.DataSourceIsEmpty(dsMediaLibPerm)) { foreach (DataRow drMediaLibPerm in dsMediaLibPerm.Tables[0].Rows) { mediaLibPermissions += drMediaLibPerm["PermissionID"] + ";"; } mediaLibPermissions = mediaLibPermissions.TrimEnd(';'); } // Delete old permissions only for Create file and See library content permissions MediaLibraryRolePermissionInfoProvider.DeleteAllRoles("LibraryID = " + mi.LibraryID + " AND PermissionID IN (" + mediaLibPermissions.Replace(";", ", ") + ")"); // Set media library permissions MediaLibraryRolePermissionInfoProvider.SetPermissions(mi.LibraryID, roleIDs, mediaLibPermissions); // Log staging task SynchronizationHelper.LogObjectChange(mi, TaskTypeEnum.UpdateObject); }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check MODIFY permission for forums if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } string codeName = txtForumName.Text.Trim(); // Get safe code name for simple display mode if (DisplayMode == ControlDisplayModeEnum.Simple) { codeName = ValidationHelper.GetCodeName(txtForumDisplayName.Text.Trim(), 50) + "_group_" + CommunityGroupGUID; } // Check required fields string errorMessage = new Validator().NotEmpty(txtForumDisplayName.Text, GetString("Forum_General.EmptyDisplayName")).NotEmpty(codeName, GetString("Forum_General.EmptyCodeName")).Result; if (errorMessage == String.Empty && !ValidationHelper.IsCodeName(codeName)) { errorMessage = GetString("general.errorcodenameinidentifierformat"); } if (String.IsNullOrEmpty(errorMessage)) { if (CMSContext.CurrentSite != null) { // If forum with given name already exists show error message if (ForumInfoProvider.GetForumInfo(codeName, CMSContext.CurrentSiteID, CommunityGroupID) != null) { ShowError(GetString("Forum_Edit.ForumAlreadyExists")); return; } // Create new object ForumInfo forumObj = new ForumInfo(); // Set new properties forumObj.ForumSiteID = CMSContext.CurrentSite.SiteID; forumObj.ForumIsLocked = chkForumLocked.Checked; forumObj.ForumOpen = chkForumOpen.Checked; chkForumDisplayEmails.SetThreeStateValue(forumObj, "ForumDisplayEmails"); forumObj.ForumDescription = txtForumDescription.Text.Trim(); chkForumRequireEmail.SetThreeStateValue(forumObj, "ForumRequireEmail"); forumObj.ForumDisplayName = txtForumDisplayName.Text.Trim(); forumObj.ForumName = codeName; forumObj.ForumGroupID = mGroupId; forumObj.ForumModerated = chkForumModerated.Checked; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; chkCaptcha.SetThreeStateValue(forumObj, "ForumUseCAPTCHA"); forumObj.ForumCommunityGroupID = CommunityGroupID; // For simple display mode skip some properties if (DisplayMode != ControlDisplayModeEnum.Simple) { forumObj.ForumBaseUrl = txtBaseUrl.Text.Trim(); forumObj.ForumUnsubscriptionUrl = txtUnsubscriptionUrl.Text.Trim(); chkUseHTML.SetThreeStateValue(forumObj, "ForumHTMLEditor"); if (chkInheritBaseUrl.Checked) { forumObj.ForumBaseUrl = null; } if (chkInheritUnsubscribeUrl.Checked) { forumObj.ForumUnsubscriptionUrl = null; } } // Check license if (ForumInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Forums, VersionActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); mForumId = forumObj.ForumID; RaiseOnSaved(); } else { ShowError(GetString("LicenseVersionCheck.Forums")); } } } else { ShowError(errorMessage); } }
protected void Page_Load(object sender, EventArgs e) { process = true; if (!Visible || StopProcessing) { EnableViewState = false; process = false; } chkChangeName.CheckedChanged += chkChangeName_CheckedChanged; if (ForumID > 0) { // Get information on current forum forum = ForumInfoProvider.GetForumInfo(ForumID); // Check whether the forum still exists EditedObject = forum; } // Get forum resource resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); if ((resForums != null) && (forum != null)) { QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ID", resForums.ResourceID); parameters.Add("@ForumID", forum.ForumID); parameters.Add("@SiteID", SiteContext.CurrentSiteID); string where = string.Empty; int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Build where condition if (groupId > 0) { where = "RoleGroupID=" + groupId + " AND PermissionDisplayInMatrix = 0"; } else { where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0"; } // Setup matrix control gridMatrix.IsLiveSite = IsLiveSite; gridMatrix.QueryParameters = parameters; gridMatrix.WhereCondition = where; gridMatrix.CssClass = "permission-matrix"; gridMatrix.OnItemChanged += gridMatrix_OnItemChanged; // Disable permission matrix if user has no MANAGE rights if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { Enable = false; gridMatrix.Enabled = false; ShowError(String.Format(GetString("general.accessdeniedonpermissionname"), "Manage")); } } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check MODIFY permission for forums if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { return; } // Get community group identificators int communityGroupId = 0; Guid communityGroupGuid = Guid.Empty; if ((ForumGroup != null) && LicenseKeyInfoProvider.IsFeatureAvailable(FeatureEnum.Groups)) { BaseInfo communityGroup = ModuleCommands.CommunityGetGroupInfo(ForumGroup.GroupGroupID); if (communityGroup != null) { communityGroupId = communityGroup.Generalized.ObjectID; communityGroupGuid = communityGroup.Generalized.ObjectGUID; } } string codeName = txtForumName.Text.Trim(); // Get safe code name for simple display mode if (DisplayMode == ControlDisplayModeEnum.Simple) { codeName = ValidationHelper.GetCodeName(txtForumDisplayName.Text.Trim(), 50) + "_group_" + communityGroupGuid; } // Check required fields string errorMessage = new Validator().NotEmpty(txtForumDisplayName.Text, GetString("Forum_General.EmptyDisplayName")).NotEmpty(codeName, GetString("Forum_General.EmptyCodeName")).Result; if (errorMessage == String.Empty && !ValidationHelper.IsCodeName(codeName)) { errorMessage = GetString("general.errorcodenameinidentifierformat"); } if (String.IsNullOrEmpty(errorMessage)) { if (SiteContext.CurrentSite != null) { // If forum with given name already exists show error message if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSiteID, communityGroupId) != null) { ShowError(GetString("Forum_Edit.ForumAlreadyExists")); return; } // Set properties to newly created object Forum.ForumSiteID = SiteContext.CurrentSite.SiteID; Forum.ForumIsLocked = chkForumLocked.Checked; Forum.ForumOpen = chkForumOpen.Checked; chkForumDisplayEmails.SetThreeStateValue(Forum, "ForumDisplayEmails"); Forum.ForumDescription = txtForumDescription.Text.Trim(); chkForumRequireEmail.SetThreeStateValue(Forum, "ForumRequireEmail"); Forum.ForumDisplayName = txtForumDisplayName.Text.Trim(); Forum.ForumName = codeName; Forum.ForumGroupID = mGroupId; Forum.ForumModerated = chkForumModerated.Checked; Forum.ForumAccess = 40000; Forum.ForumPosts = 0; Forum.ForumThreads = 0; Forum.ForumPostsAbsolute = 0; Forum.ForumThreadsAbsolute = 0; Forum.ForumOrder = 0; chkCaptcha.SetThreeStateValue(Forum, "ForumUseCAPTCHA"); Forum.ForumCommunityGroupID = communityGroupId; // For simple display mode skip some properties if (DisplayMode != ControlDisplayModeEnum.Simple) { Forum.ForumBaseUrl = txtBaseUrl.Text.Trim(); Forum.ForumUnsubscriptionUrl = txtUnsubscriptionUrl.Text.Trim(); chkUseHTML.SetThreeStateValue(Forum, "ForumHTMLEditor"); if (chkInheritBaseUrl.Checked) { Forum.ForumBaseUrl = null; } if (chkInheritUnsubscribeUrl.Checked) { Forum.ForumUnsubscriptionUrl = null; } } // Check license if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(Forum); mForumId = Forum.ForumID; RaiseOnSaved(); } else { ShowError(GetString("LicenseVersionCheck.Forums")); } } } else { ShowError(errorMessage); } }
/// <summary> /// Reload data. /// </summary> public override void ReloadData() { ForumPostInfo fpi = null; ForumInfo fi; #region "Load data" if (PostData != null) { fpi = ForumPostInfo.New(PostData); } if (fpi == null) { fpi = PostInfo; } if (fpi != null) { PostData = fpi; fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID); } else { return; } #endregion if (fi.ForumEnableAdvancedImage) { ltlText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS; } else { ltlText.AllowedControls = "none"; } lnkUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName); // Display converted datetime for live site lblDate.Text = " (" + TimeZoneMethods.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString() + ")"; lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject); DiscussionMacroResolver dmh = new DiscussionMacroResolver(); dmh.EnableBold = fi.ForumEnableFontBold; dmh.EnableItalics = fi.ForumEnableFontItalics; dmh.EnableStrikeThrough = fi.ForumEnableFontStrike; dmh.EnableUnderline = fi.ForumEnableFontUnderline; dmh.EnableCode = fi.ForumEnableCodeSnippet; dmh.EnableColor = fi.ForumEnableFontColor; dmh.EnableImage = fi.ForumEnableImage || fi.ForumEnableAdvancedImage; dmh.EnableQuote = fi.ForumEnableQuote; dmh.EnableURL = fi.ForumEnableURL || fi.ForumEnableAdvancedURL; dmh.MaxImageSideSize = fi.ForumImageMaxSideSize; dmh.QuotePostText = GetString("DiscussionMacroResolver.QuotePostText"); if (fi.ForumHTMLEditor) { dmh.EncodeText = false; dmh.ConvertLineBreaksToHTML = false; } else { dmh.EncodeText = true; dmh.ConvertLineBreaksToHTML = true; } ltlText.Text = "<div class=\"PostText\">" + dmh.ResolveMacros(fpi.PostText) + "</div>"; userAvatar.Text = AvatarImage(fpi); if (DisplayBadgeInfo) { if (fpi.PostUserID > 0) { UserInfo ui = UserInfoProvider.GetUserInfo(fpi.PostUserID); if ((ui != null) && !ui.IsPublic()) { BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(ui.UserSettings.UserBadgeID); if (bi != null) { ltlBadge.Text = "<div class=\"Badge\">" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "</div>"; } } } // Set public badge if no badge is set if (String.IsNullOrEmpty(ltlBadge.Text)) { ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>"; } } if (EnableSignature) { if (fpi.PostUserSignature.Trim() != "") { plcSignature.Visible = true; ltrSignature.Text = HTMLHelper.HTMLEncode(fpi.PostUserSignature); } } if (!DisplayOnly) { string threadId = ForumPostInfoProvider.GetPostRootFromIDPath(ValidationHelper.GetString(GetData(PostData, "PostIdPath"), "")).ToString(); // Reply if (IsAvailable(PostData, ForumActionType.Reply)) { lnkReply.Visible = true; lnkReply.Text = GetString("Forums_WebInterface_ForumPost.replyLinkText"); lnkReply.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Reply), "threadid", threadId); } else { lnkReply.Visible = false; } // Quote if (IsAvailable(PostData, ForumActionType.Quote)) { lnkQuote.Visible = true; lnkQuote.Text = GetString("Forums_WebInterface_ForumPost.quoteLinkText"); lnkQuote.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Quote), "threadid", threadId); } else { lnkQuote.Visible = false; } // Display subscribe link if (IsAvailable(PostData, ForumActionType.SubscribeToPost)) { lnkSubscribe.Visible = true; lnkSubscribe.Text = GetString("Forums_WebInterface_ForumPost.Subscribe"); lnkSubscribe.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.SubscribeToPost), "threadid", threadId); } else { lnkSubscribe.Visible = false; } lnkUserName.CssClass = "PostUserLink"; if (!String.IsNullOrEmpty(fpi.PostUserMail) && (fi.ForumDisplayEmails)) { lnkUserName.NavigateUrl = "mailto:" + HTMLHelper.HTMLEncode(fpi.PostUserMail) + "?subject=" + HTMLHelper.HTMLEncode(fpi.PostSubject); lnkUserName.CssClass = "PostUser"; } } // Display action panel only if reply to link or subscription link are visible plcActions.Visible = ((lnkReply.Visible || lnkSubscribe.Visible || lnkQuote.Visible) & !DisplayOnly); if ((lnkReply.Visible) && (lnkQuote.Visible || lnkSubscribe.Visible)) { lblActionSeparator.Visible = true; } if ((lnkQuote.Visible) && (lnkSubscribe.Visible)) { lblActionSeparator2.Visible = true; } }
/// <summary> /// Loads the forums dropdownlist for topic move. /// </summary> private void LoadMoveTopicDropdown() { if (drpMoveToForum.Items.Count > 0) { return; } int currentForumId = 0; ForumPostInfo fpi = ForumContext.CurrentThread; if ((fpi == null) && (CurrentThread > 0)) { fpi = ForumPostInfoProvider.GetForumPostInfo(CurrentThread); } if (fpi != null) { bool isOk = AdminMode ? true : ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID == fpi.PostForumID)); if (isOk) { currentForumId = fpi.PostForumID; ForumInfo fi = ForumInfoProvider.GetForumInfo(currentForumId); if (fi != null) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { string where = null; DataSet dsGroups = null; if (fgi.GroupGroupID > 0) { where = "GroupName NOT LIKE 'AdHoc%' AND GroupSiteID = " + SiteID + " AND GroupGroupID = " + fgi.GroupGroupID; } else { where = "GroupName NOT LIKE 'AdHoc%' AND GroupSiteID = " + SiteID + " AND GroupGroupID IS NULL"; } dsGroups = ForumGroupInfoProvider.GetGroups(where, "GroupDisplayName", 0, "GroupID, GroupDisplayName"); if (!DataHelper.DataSourceIsEmpty(dsGroups)) { Hashtable forums = new Hashtable(); // Get all forums for selected groups string groupWhere = "AND ForumGroupID IN (SELECT GroupID FROM Forums_ForumGroup WHERE " + where + ") "; DataSet dsForums = ForumInfoProvider.GetForums(" ForumOpen = 1 " + " AND NOT ForumID = " + currentForumId + groupWhere, "ForumDisplayName", 0, "ForumID, ForumDisplayName, ForumGroupID"); if (!DataHelper.DataSourceIsEmpty(dsForums)) { // Load forums into hash table foreach (DataRow drForum in dsForums.Tables[0].Rows) { int groupId = Convert.ToInt32(drForum["ForumGroupID"]); List <string[]> forumNames = forums[groupId] as List <string[]>; if (forumNames == null) { forumNames = new List <string[]>(); } forumNames.Add(new string[] { Convert.ToString(drForum["ForumDisplayName"]), Convert.ToString(drForum["ForumID"]) }); forums[groupId] = forumNames; } } foreach (DataRow dr in dsGroups.Tables[0].Rows) { int groupId = Convert.ToInt32(dr["GroupId"]); List <string[]> forumNames = forums[groupId] as List <string[]>; if (forumNames != null) { // Add forum group item if some forum ListItem li = new ListItem(Convert.ToString(dr["GroupDisplayName"]), "0"); li.Attributes.Add("disabled", "disabled"); drpMoveToForum.Items.Add(li); // Add forum items foreach (string[] forum in forumNames) { // Add forum to DDL drpMoveToForum.Items.Add(new ListItem(" \xA0\xA0\xA0\xA0 " + forum[0], forum[1])); } } } // Display message if no forum exists if (drpMoveToForum.Items.Count == 0) { plcMoveInner.Visible = false; ShowInformation(GetString("Forums.NoForumToMoveIn")); } } } } } } }
/// <summary> /// Reloads the form data. /// </summary> public override void ReloadData() { fi = ForumInfoProvider.GetForumInfo(this.ForumID); replyPi = ForumPostInfoProvider.GetForumPostInfo(this.ReplyToPostID); editPi = ForumPostInfoProvider.GetForumPostInfo(this.EditPostID); CurrentUserInfo cui = CMSContext.CurrentUser; // Edit post if (editPi != null) { ForumPost1.PostID = editPi.PostId; ForumPost1.DisplayOnly = true; if (DisableCancelButton) { btnCancel.Enabled = false; } ucBBEditor.Text = editPi.PostText; htmlTemplateBody.ResolvedValue = editPi.PostText; txtSubject.Text = editPi.PostSubject; txtSignature.Text = editPi.PostUserSignature; txtEmail.Text = editPi.PostUserMail; txtUserName.Text = editPi.PostUserName; plcIsAnswer.Visible = true; plcIsNotAnswer.Visible = true; txtPostIsAnswer.Text = editPi.PostIsAnswer.ToString(); txtPostIsNotAnswer.Text = editPi.PostIsNotAnswer.ToString(); if ((fi != null) && (fi.ForumType == 0) && (editPi.PostLevel == 0)) { if (editPi.PostType == 0) { radTypeDiscussion.Checked = true; } else { radTypeQuestion.Checked = true; } } else { plcThreadType.Visible = false; } } else { // Reply to post if (replyPi != null) { pnlReplyPost.Visible = true; ForumPost1.PostID = replyPi.PostId; ForumPost1.DisplayOnly = true; plcThreadType.Visible = false; txtSignature.Text = cui.UserSignature; txtEmail.Text = cui.Email; if (!String.IsNullOrEmpty(cui.UserNickName)) { txtUserName.Text = cui.UserNickName.Trim(); } else { txtUserName.Text = Functions.GetFormattedUserName(cui.UserName, this.IsLiveSite); } if (!replyPi.PostSubject.StartsWith(GetString("Forums.ReplyPrefix"))) { txtSubject.Text = GetString("Forums.ReplyPrefix") + replyPi.PostSubject; txtSubject.Text = TextHelper.LimitLength(txtSubject.Text, POST_SUBJECT_LENGTH, ""); } else { txtSubject.Text = replyPi.PostSubject; } btnCancel.Enabled = true; } // Create new thread else { btnCancel.Enabled = false; txtSignature.Text = cui.UserSignature; txtEmail.Text = cui.Email; if (!String.IsNullOrEmpty(cui.UserNickName)) { txtUserName.Text = cui.UserNickName.Trim(); } else { txtUserName.Text = Functions.GetFormattedUserName(cui.UserName, this.IsLiveSite); } } } }
protected void Page_Load(object sender, EventArgs e) { process = true; if (!Visible || StopProcessing) { EnableViewState = false; process = false; } chkChangeName.CheckedChanged += new EventHandler(chkChangeName_CheckedChanged); if (ForumID > 0) { // Get information on current forum forum = ForumInfoProvider.GetForumInfo(ForumID); // Check whether the forum still exists EditedObject = forum; } // Get forum resource resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); if ((resForums != null) && (forum != null)) { QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ID", resForums.ResourceId); parameters.Add("@ForumID", forum.ForumID); parameters.Add("@SiteID", CMSContext.CurrentSiteID); string where = ""; int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Build where condition if (groupId > 0) { where = "RoleGroupID=" + groupId.ToString() + " AND PermissionDisplayInMatrix = 0"; } else { where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0"; } // Setup matrix control gridMatrix.IsLiveSite = IsLiveSite; gridMatrix.QueryParameters = parameters; gridMatrix.WhereCondition = where; gridMatrix.ContentBefore = "<table class=\"PermissionMatrix\" cellspacing=\"0\" cellpadding=\"0\" rules=\"rows\" border=\"1\" style=\"border-collapse:collapse;\">"; gridMatrix.ContentAfter = "</table>"; gridMatrix.OnItemChanged += new UniMatrix.ItemChangedEventHandler(gridMatrix_OnItemChanged); // Disable permission matrix if user has no MANAGE rights if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { Enable = false; gridMatrix.Enabled = false; ShowError(String.Format(GetString("CMSSiteManager.AccessDeniedOnPermissionName"), "Manage")); } } }