/// ----------------------------------------------------------------------------- /// <summary> /// GetWorkFlow retrieves the currently active Workflow for the Portal /// </summary> /// <remarks> /// </remarks> /// <param name = "ModuleId">The ID of the Module</param> /// <param name="TabId">The Tab ID</param> /// <param name = "PortalId">The ID of the Portal</param> public KeyValuePair <string, int> GetWorkflow(int ModuleId, int TabId, int PortalId) { int workFlowId = Null.NullInteger; string workFlowType = Null.NullString; // get module settings HtmlModuleSettings settings; if (ModuleId > -1) { var module = ModuleController.Instance.GetModule(ModuleId, TabId, false); var repo = new HtmlModuleSettingsRepository(); settings = repo.GetSettings(module); } else { settings = new HtmlModuleSettings(); } if (settings.WorkFlowID != Null.NullInteger) { workFlowId = settings.WorkFlowID; workFlowType = "Module"; } if (workFlowId == Null.NullInteger) { // if undefined at module level, get from tab settings var tabSettings = TabController.Instance.GetTabSettings(TabId); if (tabSettings["WorkflowID"] != null) { workFlowId = Convert.ToInt32(tabSettings["WorkflowID"]); workFlowType = "Page"; } } if (workFlowId == Null.NullInteger) { // if undefined at tab level, get from portal settings workFlowId = int.Parse(PortalController.GetPortalSetting("WorkflowID", PortalId, "-1")); workFlowType = "Site"; } // if undefined at portal level, set portal default if (workFlowId == Null.NullInteger) { var objWorkflow = new WorkflowStateController(); ArrayList arrWorkflows = objWorkflow.GetWorkflows(PortalId); foreach (WorkflowStateInfo objState in arrWorkflows) { // use direct publish as default if (Null.IsNull(objState.PortalID) && objState.WorkflowName == "Direct Publish") { workFlowId = objState.WorkflowID; workFlowType = "Module"; } } } return(new KeyValuePair <string, int>(workFlowType, workFlowId)); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State /// </summary> /// <remarks> /// </remarks> /// <param name = "moduleId">The ID of the Module</param> /// <param name = "isPublished">Whether the content has been published or not</param> /// <param name="workflowId">The Workflow ID</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public HtmlTextInfo GetTopHtmlText(int moduleId, bool isPublished, int workflowId) { var htmlText = CBO.FillObject <HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, isPublished)); if (htmlText != null) { // check if workflow has changed if (isPublished == false && htmlText.WorkflowID != workflowId) { // get proper state for workflow htmlText.WorkflowID = workflowId; htmlText.WorkflowName = "[REPAIR_WORKFLOW]"; var workflowStateController = new WorkflowStateController(); htmlText.StateID = htmlText.IsPublished ? workflowStateController.GetLastWorkflowStateID(workflowId) : workflowStateController.GetFirstWorkflowStateID(workflowId); // update object UpdateHtmlText(htmlText, GetMaximumVersionHistory(htmlText.PortalID)); // get object again htmlText = CBO.FillObject <HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, false)); } } return(htmlText); }
/// ----------------------------------------------------------------------------- /// <summary> /// ImportModule implements the IPortable ImportModule Interface /// </summary> /// <remarks> /// </remarks> /// <param name = "ModuleID">The ID of the Module being imported</param> /// <param name = "Content">The Content being imported</param> /// <param name = "Version">The Version of the Module Content being imported</param> /// <param name = "UserId">The UserID of the User importing the Content</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public void ImportModule(int ModuleID, string Content, string Version, int UserId) { ModuleInfo module = ModuleController.Instance.GetModule(ModuleID, Null.NullInteger, true); var workflowStateController = new WorkflowStateController(); int workflowID = GetWorkflow(ModuleID, module.TabID, module.PortalID).Value; XmlNode xml = Globals.GetContent(Content, "htmltext"); var htmlContent = new HtmlTextInfo(); htmlContent.ModuleID = ModuleID; // convert Version to System.Version var objVersion = new Version(Version); if (objVersion >= new Version(5, 1, 0)) { // current module content htmlContent.Content = DeTokeniseLinks(xml.SelectSingleNode("content").InnerText, module.PortalID); } else { // legacy module content htmlContent.Content = DeTokeniseLinks(xml.SelectSingleNode("desktophtml").InnerText, module.PortalID); } htmlContent.WorkflowID = workflowID; htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowID); // import UpdateHtmlText(htmlContent, GetMaximumVersionHistory(module.PortalID)); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name = "ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { var objWorkflow = new WorkflowStateController(); int WorkflowID = GetWorkflow(ModInfo.ModuleID, ModInfo.TabID, ModInfo.PortalID).Value; var SearchItemCollection = new SearchItemInfoCollection(); HtmlTextInfo objContent = GetTopHtmlText(ModInfo.ModuleID, true, WorkflowID); if (objContent != null) { //content is encoded in the Database so Decode before Indexing string strContent = HttpUtility.HtmlDecode(objContent.Content); //Get the description string string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strContent, false), MAX_DESCRIPTION_LENGTH, "..."); var SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, strDescription, objContent.LastModifiedByUserID, objContent.LastModifiedOnDate, ModInfo.ModuleID, "", strContent, "", Null.NullInteger); SearchItemCollection.Add(SearchItem); } return(SearchItemCollection); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State /// </summary> /// <remarks> /// </remarks> /// <param name = "ModuleID">The ID of the Module</param> /// <param name = "IsPublished">Whether the content has been published or not</param> /// <param name="WorkflowID">The Workflow ID</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public HtmlTextInfo GetTopHtmlText(int ModuleID, bool IsPublished, int WorkflowID) { var objHtmlText = (HtmlTextInfo)(CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof(HtmlTextInfo))); if (objHtmlText != null) { // check if workflow has changed if (IsPublished == false && objHtmlText.WorkflowID != WorkflowID) { // get proper state for workflow var objWorkflow = new WorkflowStateController(); objHtmlText.WorkflowID = WorkflowID; objHtmlText.WorkflowName = "[REPAIR_WORKFLOW]"; if (objHtmlText.IsPublished) { objHtmlText.StateID = objWorkflow.GetLastWorkflowStateID(WorkflowID); } else { objHtmlText.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID); } // update object UpdateHtmlText(objHtmlText, GetMaximumVersionHistory(objHtmlText.PortalID)); // get object again objHtmlText = (HtmlTextInfo)(CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof(HtmlTextInfo))); } } return(objHtmlText); }
/// ----------------------------------------------------------------------------- /// <summary> /// ModuleAction_Click handles all ModuleAction events raised from the action menu /// </summary> /// <remarks> /// </remarks> /// ----------------------------------------------------------------------------- private void ModuleAction_Click(object sender, ActionEventArgs e) { try { if (e.Action.CommandArgument == "publish") { // verify security if (IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); var objWorkflow = new WorkflowStateController(); if (objContent.StateID == objWorkflow.GetFirstWorkflowStateID(WorkflowID)) { // publish content objContent.StateID = objWorkflow.GetNextWorkflowStateID(objContent.WorkflowID, objContent.StateID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); // refresh page Response.Redirect(Globals.NavigateURL(), true); } } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } //get decoration setting, set to true as default. cbDecorate.Checked = !ModuleSettings.ContainsKey("HtmlText_UseDecorate") || ModuleSettings["HtmlText_UseDecorate"].ToString() == "1"; // get workflow/version settings var workflows = new ArrayList(); foreach (WorkflowStateInfo state in workflowStateController.GetWorkflows(PortalId)) { if (!state.IsDeleted) { workflows.Add(state); } } cboWorkflow.DataSource = workflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.FindItemByValue(workflow.Value.ToString()) != null)) { cboWorkflow.FindItemByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } txtSearchDescLength.Text = ModuleSettings.ContainsKey("HtmlText_SearchDescLength") && !string.IsNullOrEmpty(ModuleSettings["HtmlText_SearchDescLength"].ToString()) ? ModuleSettings["HtmlText_SearchDescLength"].ToString() : HtmlTextController.MAX_DESCRIPTION_LENGTH.ToString(); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// UpdateSettings saves the modified settings to the Database /// </summary> public override void UpdateSettings() { try { var htmlTextController = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); // update replace token setting var objModules = new ModuleController(); objModules.UpdateModuleSetting(ModuleId, "HtmlText_ReplaceTokens", chkReplaceTokens.Checked.ToString()); objModules.UpdateModuleSetting(ModuleId, "HtmlText_UseDecorate", cbDecorate.Checked ? "1" : "0"); objModules.UpdateModuleSetting(ModuleId, "HtmlText_SearchDescLength", txtSearchDescLength.Text); // disable module caching if token replace is enabled if (chkReplaceTokens.Checked) { ModuleInfo objModule = objModules.GetModule(ModuleId, TabId, false); if (objModule.CacheTime > 0) { objModule.CacheTime = 0; objModules.UpdateModule(objModule); } } // update workflow/version settings switch (rblApplyTo.SelectedValue) { case "Module": htmlTextController.UpdateWorkflow(ModuleId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Page": htmlTextController.UpdateWorkflow(TabId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Site": htmlTextController.UpdateWorkflow(PortalId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them. /// </summary> /// <remarks> /// </remarks> public override void LoadSettings() { try { if (!this.Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); this.chkReplaceTokens.Checked = this.ModuleSettings.ReplaceTokens; this.cbDecorate.Checked = this.ModuleSettings.UseDecorate; // get workflow/version settings var workflows = new ArrayList(); foreach (WorkflowStateInfo state in workflowStateController.GetWorkflows(this.PortalId)) { if (!state.IsDeleted) { workflows.Add(state); } } this.cboWorkflow.DataSource = workflows; this.cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(this.ModuleId, this.TabId, this.PortalId); if (this.cboWorkflow.FindItemByValue(workflow.Value.ToString()) != null) { this.cboWorkflow.FindItemByValue(workflow.Value.ToString()).Selected = true; } this.DisplayWorkflowDetails(); if (this.rblApplyTo.Items.FindByValue(workflow.Key) != null) { this.rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } this.txtSearchDescLength.Text = this.ModuleSettings.SearchDescLength.ToString(); } // Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } // get workflow/version settings var arrWorkflows = new ArrayList(); foreach (WorkflowStateInfo objState in workflowStateController.GetWorkflows(PortalId)) { if (!objState.IsDeleted) { arrWorkflows.Add(objState); } } cboWorkflow.DataSource = arrWorkflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.Items.FindByValue(workflow.Value.ToString()) != null)) { cboWorkflow.Items.FindByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void DisplayWorkflowDetails() { if ((cboWorkflow.SelectedValue != null)) { var objWorkflow = new WorkflowStateController(); var strDescription = ""; var arrStates = objWorkflow.GetWorkflowStates(int.Parse(cboWorkflow.SelectedValue)); if (arrStates.Count > 0) { foreach (WorkflowStateInfo objState in arrStates) { strDescription = strDescription + " >> " + "<strong>" + objState.StateName + "</strong>"; } strDescription = strDescription + "<br />" + ((WorkflowStateInfo) arrStates[0]).Description; } lblDescription.Text = strDescription; } }
private void DisplayWorkflowDetails() { if ((cboWorkflow.SelectedValue != null)) { var objWorkflow = new WorkflowStateController(); var strDescription = ""; var arrStates = objWorkflow.GetWorkflowStates(int.Parse(cboWorkflow.SelectedValue)); if (arrStates.Count > 0) { foreach (WorkflowStateInfo objState in arrStates) { strDescription = strDescription + " >> " + "<strong>" + objState.StateName + "</strong>"; } strDescription = strDescription + "<br />" + ((WorkflowStateInfo)arrStates[0]).Description; } lblDescription.Text = strDescription; } }
/// ----------------------------------------------------------------------------- /// <summary> /// lblContent_UpdateLabel allows for inline editing of content /// </summary> /// <remarks> /// </remarks> /// ----------------------------------------------------------------------------- private void lblContent_UpdateLabel(object source, DNNLabelEditEventArgs e) { try { // verify security if ((!PortalSecurity.Instance.InputFilter(e.Text, PortalSecurity.FilterFlag.NoScripting).Equals(e.Text))) { throw new SecurityException(); } else if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); if (objContent == null) { objContent = new HtmlTextInfo(); objContent.ItemID = -1; } // set content attributes objContent.ModuleID = ModuleId; objContent.Content = Server.HtmlEncode(e.Text); objContent.WorkflowID = WorkflowID; objContent.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); } else { throw new SecurityException(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// UpdateHtmlText creates a new HtmlTextInfo object or updates an existing HtmlTextInfo object /// </summary> /// <remarks> /// </remarks> /// <param name = "htmlContent">An HtmlTextInfo object</param> /// <param name = "MaximumVersionHistory">The maximum number of versions to retain</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public void UpdateHtmlText(HtmlTextInfo htmlContent, int MaximumVersionHistory) { var _workflowStateController = new WorkflowStateController(); bool blnCreateNewVersion = false; // determine if we are creating a new version of content or updating an existing version if (htmlContent.ItemID != -1) { if (htmlContent.WorkflowName != "[REPAIR_WORKFLOW]") { HtmlTextInfo objContent = GetTopHtmlText(htmlContent.ModuleID, false, htmlContent.WorkflowID); if (objContent != null) { if (objContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID)) { blnCreateNewVersion = true; } } } } else { blnCreateNewVersion = true; } // determine if content is published if (htmlContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID)) { htmlContent.IsPublished = true; } else { htmlContent.IsPublished = false; } if (blnCreateNewVersion) { // add content htmlContent.ItemID = DataProvider.Instance().AddHtmlText(htmlContent.ModuleID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.GetCurrentUserInfo().UserID, MaximumVersionHistory); } else { // update content DataProvider.Instance().UpdateHtmlText(htmlContent.ItemID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.GetCurrentUserInfo().UserID); } // add log history var logInfo = new HtmlTextLogInfo(); logInfo.ItemID = htmlContent.ItemID; logInfo.StateID = htmlContent.StateID; logInfo.Approved = htmlContent.Approved; logInfo.Comment = htmlContent.Comment; var objLogs = new HtmlTextLogController(); objLogs.AddHtmlTextLog(logInfo); // create user notifications CreateUserNotifications(htmlContent); // refresh output cache ModuleController.SynchronizeModule(htmlContent.ModuleID); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State /// </summary> /// <remarks> /// </remarks> /// <param name = "ModuleID">The ID of the Module</param> /// <param name = "IsPublished">Whether the content has been published or not</param> /// <param name="WorkflowID">The Workflow ID</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public HtmlTextInfo GetTopHtmlText(int ModuleID, bool IsPublished, int WorkflowID) { var objHtmlText = (HtmlTextInfo) (CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof (HtmlTextInfo))); if (objHtmlText != null) { // check if workflow has changed if (IsPublished == false && objHtmlText.WorkflowID != WorkflowID) { // get proper state for workflow var objWorkflow = new WorkflowStateController(); objHtmlText.WorkflowID = WorkflowID; objHtmlText.WorkflowName = "[REPAIR_WORKFLOW]"; if (objHtmlText.IsPublished) { objHtmlText.StateID = objWorkflow.GetLastWorkflowStateID(WorkflowID); } else { objHtmlText.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID); } // update object UpdateHtmlText(objHtmlText, GetMaximumVersionHistory(objHtmlText.PortalID)); // get object again objHtmlText = (HtmlTextInfo) (CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof (HtmlTextInfo))); } } return objHtmlText; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetWorkFlow retrieves the currently active Workflow for the Portal /// </summary> /// <remarks> /// </remarks> /// <param name = "ModuleId">The ID of the Module</param> /// <param name="TabId">The Tab ID</param> /// <param name = "PortalId">The ID of the Portal</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public KeyValuePair<string, int> GetWorkflow(int ModuleId, int TabId, int PortalId) { int workFlowId = Null.NullInteger; string workFlowType = Null.NullString; // get from module settings var moduleController = new ModuleController(); Hashtable settings = moduleController.GetModuleSettings(ModuleId); if (settings["WorkflowID"] != null) { workFlowId = Convert.ToInt32(settings["WorkflowID"]); workFlowType = "Module"; } if (workFlowId == Null.NullInteger) { // if undefined at module level, get from tab settings settings = new TabController().GetTabSettings(TabId); if (settings["WorkflowID"] != null) { workFlowId = Convert.ToInt32(settings["WorkflowID"]); workFlowType = "Page"; } } if (workFlowId == Null.NullInteger) { // if undefined at tab level, get from portal settings workFlowId = int.Parse(PortalController.GetPortalSetting("WorkflowID", PortalId, "-1")); workFlowType = "Site"; } // if undefined at portal level, set portal default if (workFlowId == Null.NullInteger) { var objWorkflow = new WorkflowStateController(); ArrayList arrWorkflows = objWorkflow.GetWorkflows(PortalId); foreach (WorkflowStateInfo objState in arrWorkflows) { // use direct publish as default if (Null.IsNull(objState.PortalID) && objState.WorkflowName == "Direct Publish") { workFlowId = objState.WorkflowID; workFlowType = "Module"; } } } return new KeyValuePair<string, int>(workFlowType, workFlowId); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State /// </summary> /// <remarks> /// </remarks> /// <param name = "moduleId">The ID of the Module</param> /// <param name = "isPublished">Whether the content has been published or not</param> /// <param name="workflowId">The Workflow ID</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public HtmlTextInfo GetTopHtmlText(int moduleId, bool isPublished, int workflowId) { var htmlText = CBO.FillObject<HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, isPublished)); if (htmlText != null) { // check if workflow has changed if (isPublished == false && htmlText.WorkflowID != workflowId) { // get proper state for workflow htmlText.WorkflowID = workflowId; htmlText.WorkflowName = "[REPAIR_WORKFLOW]"; var workflowStateController = new WorkflowStateController(); htmlText.StateID = htmlText.IsPublished ? workflowStateController.GetLastWorkflowStateID(workflowId) : workflowStateController.GetFirstWorkflowStateID(workflowId); // update object UpdateHtmlText(htmlText, GetMaximumVersionHistory(htmlText.PortalID)); // get object again htmlText = CBO.FillObject<HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, false)); } } return htmlText; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name = "ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { var objWorkflow = new WorkflowStateController(); int WorkflowID = GetWorkflow(ModInfo.ModuleID, ModInfo.TabID, ModInfo.PortalID).Value; var SearchItemCollection = new SearchItemInfoCollection(); HtmlTextInfo objContent = GetTopHtmlText(ModInfo.ModuleID, true, WorkflowID); if (objContent != null) { //content is encoded in the Database so Decode before Indexing string strContent = HttpUtility.HtmlDecode(objContent.Content); //Get the description string string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strContent, false), MAX_DESCRIPTION_LENGTH, "..."); var SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, strDescription, objContent.LastModifiedByUserID, objContent.LastModifiedOnDate, ModInfo.ModuleID, "", strContent, "", Null.NullInteger); SearchItemCollection.Add(SearchItem); } return SearchItemCollection; }
/// ----------------------------------------------------------------------------- /// <summary> /// lblContent_UpdateLabel allows for inline editing of content /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- private void lblContent_UpdateLabel(object source, DNNLabelEditEventArgs e) { try { // verify security if ((!new PortalSecurity().InputFilter(e.Text, PortalSecurity.FilterFlag.NoScripting).Equals(e.Text))) { throw new SecurityException(); } else if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); if (objContent == null) { objContent = new HtmlTextInfo(); objContent.ItemID = -1; } // set content attributes objContent.ModuleID = ModuleId; objContent.Content = Server.HtmlEncode(e.Text); objContent.WorkflowID = WorkflowID; objContent.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); } else { throw new SecurityException(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// ModuleAction_Click handles all ModuleAction events raised from the action menu /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- private void ModuleAction_Click(object sender, ActionEventArgs e) { try { if (e.Action.CommandArgument == "publish") { // verify security if (IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit) { // get content var objHTML = new HtmlTextController(); HtmlTextInfo objContent = objHTML.GetTopHtmlText(ModuleId, false, WorkflowID); var objWorkflow = new WorkflowStateController(); if (objContent.StateID == objWorkflow.GetFirstWorkflowStateID(WorkflowID)) { // publish content objContent.StateID = objWorkflow.GetNextWorkflowStateID(objContent.WorkflowID, objContent.StateID); // save the content objHTML.UpdateHtmlText(objContent, objHTML.GetMaximumVersionHistory(PortalId)); // refresh page Response.Redirect(Globals.NavigateURL(), true); } } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// UpdateSettings saves the modified settings to the Database /// </summary> public override void UpdateSettings() { try { var htmlTextController = new HtmlTextController(); var objWorkflow = new WorkflowStateController(); // update replace token setting var objModules = new ModuleController(); objModules.UpdateModuleSetting(ModuleId, "HtmlText_ReplaceTokens", chkReplaceTokens.Checked.ToString()); objModules.UpdateModuleSetting(ModuleId, "HtmlText_UseDecorate", cbDecorate.Checked ? "1" : "0"); objModules.UpdateModuleSetting(ModuleId, "HtmlText_SearchDescLength", txtSearchDescLength.Text); // disable module caching if token replace is enabled if (chkReplaceTokens.Checked) { ModuleInfo objModule = objModules.GetModule(ModuleId, TabId, false); if (objModule.CacheTime > 0) { objModule.CacheTime = 0; objModules.UpdateModule(objModule); } } // update workflow/version settings switch (rblApplyTo.SelectedValue) { case "Module": htmlTextController.UpdateWorkflow(ModuleId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Page": htmlTextController.UpdateWorkflow(TabId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; case "Site": htmlTextController.UpdateWorkflow(PortalId, rblApplyTo.SelectedValue, Int32.Parse(cboWorkflow.SelectedValue), chkReplace.Checked); break; } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// UpdateHtmlText creates a new HtmlTextInfo object or updates an existing HtmlTextInfo object /// </summary> /// <remarks> /// </remarks> /// <param name = "htmlContent">An HtmlTextInfo object</param> /// <param name = "MaximumVersionHistory">The maximum number of versions to retain</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public void UpdateHtmlText(HtmlTextInfo htmlContent, int MaximumVersionHistory) { var _workflowStateController = new WorkflowStateController(); bool blnCreateNewVersion = false; // determine if we are creating a new version of content or updating an existing version if (htmlContent.ItemID != -1) { if (htmlContent.WorkflowName != "[REPAIR_WORKFLOW]") { HtmlTextInfo objContent = GetTopHtmlText(htmlContent.ModuleID, false, htmlContent.WorkflowID); if (objContent != null) { if (objContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID)) { blnCreateNewVersion = true; } } } } else { blnCreateNewVersion = true; } // determine if content is published if (htmlContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID)) { htmlContent.IsPublished = true; } else { htmlContent.IsPublished = false; } if (blnCreateNewVersion) { // add content htmlContent.ItemID = DataProvider.Instance().AddHtmlText(htmlContent.ModuleID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.Instance.GetCurrentUserInfo().UserID, MaximumVersionHistory); } else { // update content DataProvider.Instance().UpdateHtmlText(htmlContent.ItemID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.Instance.GetCurrentUserInfo().UserID); } // add log history var logInfo = new HtmlTextLogInfo(); logInfo.ItemID = htmlContent.ItemID; logInfo.StateID = htmlContent.StateID; logInfo.Approved = htmlContent.Approved; logInfo.Comment = htmlContent.Comment; var objLogs = new HtmlTextLogController(); objLogs.AddHtmlTextLog(logInfo); // create user notifications CreateUserNotifications(htmlContent); // refresh output cache ModuleController.SynchronizeModule(htmlContent.ModuleID); }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } //get decoration setting, set to true as default. cbDecorate.Checked = !ModuleSettings.ContainsKey("HtmlText_UseDecorate") || ModuleSettings["HtmlText_UseDecorate"].ToString() == "1"; // get workflow/version settings var arrWorkflows = new ArrayList(); foreach (WorkflowStateInfo objState in workflowStateController.GetWorkflows(PortalId)) { if (!objState.IsDeleted) { arrWorkflows.Add(objState); } } cboWorkflow.DataSource = arrWorkflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.FindItemByValue(workflow.Value.ToString()) != null)) { cboWorkflow.FindItemByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } txtSearchDescLength.Text = ModuleSettings.ContainsKey("HtmlText_SearchDescLength") && !string.IsNullOrEmpty(ModuleSettings["HtmlText_SearchDescLength"].ToString()) ? ModuleSettings["HtmlText_SearchDescLength"].ToString() : HtmlTextController.MAX_DESCRIPTION_LENGTH.ToString(); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// CreateUserNotifications creates HtmlTextUser records and optionally sends email notifications to participants in a Workflow /// </summary> /// <remarks> /// </remarks> /// <param name="objHtmlText">An HtmlTextInfo object</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- private void CreateUserNotifications(HtmlTextInfo objHtmlText) { var _htmlTextUserController = new HtmlTextUserController(); HtmlTextUserInfo _htmlTextUser = null; UserInfo _user = null; // clean up old user notification records _htmlTextUserController.DeleteHtmlTextUsers(); // ensure we have latest htmltext object loaded objHtmlText = GetHtmlText(objHtmlText.ModuleID, objHtmlText.ItemID); // build collection of users to notify var objWorkflow = new WorkflowStateController(); var arrUsers = new ArrayList(); // if not published if (objHtmlText.IsPublished == false) { arrUsers.Add(objHtmlText.CreatedByUserID); // include content owner } // if not draft and not published if (objHtmlText.StateID != objWorkflow.GetFirstWorkflowStateID(objHtmlText.WorkflowID) && objHtmlText.IsPublished == false) { // get users from permissions for state foreach (WorkflowStatePermissionInfo permission in WorkflowStatePermissionController.GetWorkflowStatePermissions(objHtmlText.StateID)) { if (permission.AllowAccess) { if (Null.IsNull(permission.UserID)) { int roleId = permission.RoleID; RoleInfo objRole = RoleController.Instance.GetRole(objHtmlText.PortalID, r => r.RoleID == roleId); if ((objRole != null)) { foreach (UserRoleInfo objUserRole in RoleController.Instance.GetUserRoles(objHtmlText.PortalID, null, objRole.RoleName)) { if (!arrUsers.Contains(objUserRole.UserID)) { arrUsers.Add(objUserRole.UserID); } } } } else { if (!arrUsers.Contains(permission.UserID)) { arrUsers.Add(permission.UserID); } } } } } // process notifications if (arrUsers.Count > 0 || (objHtmlText.IsPublished && objHtmlText.Notify)) { // get tabid from module ModuleInfo objModule = ModuleController.Instance.GetModule(objHtmlText.ModuleID, Null.NullInteger, true); PortalSettings objPortalSettings = PortalController.Instance.GetCurrentPortalSettings(); if (objPortalSettings != null) { string strResourceFile = string.Format("{0}/DesktopModules/{1}/{2}/{3}", Globals.ApplicationPath, objModule.DesktopModule.FolderName, Localization.LocalResourceDirectory, Localization.LocalSharedResourceFile); string strSubject = Localization.GetString("NotificationSubject", strResourceFile); string strBody = Localization.GetString("NotificationBody", strResourceFile); strBody = strBody.Replace("[URL]", Globals.NavigateURL(objModule.TabID)); strBody = strBody.Replace("[STATE]", objHtmlText.StateName); // process user notification collection foreach (int intUserID in arrUsers) { // create user notification record _htmlTextUser = new HtmlTextUserInfo(); _htmlTextUser.ItemID = objHtmlText.ItemID; _htmlTextUser.StateID = objHtmlText.StateID; _htmlTextUser.ModuleID = objHtmlText.ModuleID; _htmlTextUser.TabID = objModule.TabID; _htmlTextUser.UserID = intUserID; _htmlTextUserController.AddHtmlTextUser(_htmlTextUser); // send an email notification to a user if the state indicates to do so if (objHtmlText.Notify) { _user = UserController.GetUserById(objHtmlText.PortalID, intUserID); if (_user != null) { AddHtmlNotification(strSubject, strBody, _user); } } } // if published and the published state specifies to notify members of the workflow if (objHtmlText.IsPublished && objHtmlText.Notify) { // send email notification to the author _user = UserController.GetUserById(objHtmlText.PortalID, objHtmlText.CreatedByUserID); if (_user != null) { try { Services.Mail.Mail.SendEmail(objPortalSettings.Email, objPortalSettings.Email, strSubject, strBody); } catch (Exception exc) { Exceptions.LogException(exc); } } } } } }
/// ----------------------------------------------------------------------------- /// <summary> /// ImportModule implements the IPortable ImportModule Interface /// </summary> /// <remarks> /// </remarks> /// <param name = "ModuleID">The ID of the Module being imported</param> /// <param name = "Content">The Content being imported</param> /// <param name = "Version">The Version of the Module Content being imported</param> /// <param name = "UserId">The UserID of the User importing the Content</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public void ImportModule(int ModuleID, string Content, string Version, int UserId) { var moduleController = new ModuleController(); ModuleInfo module = moduleController.GetModule(ModuleID); var workflowStateController = new WorkflowStateController(); int workflowID = GetWorkflow(ModuleID, module.TabID, module.PortalID).Value; XmlNode xml = Globals.GetContent(Content, "htmltext"); var htmlContent = new HtmlTextInfo(); htmlContent.ModuleID = ModuleID; // convert Version to System.Version var objVersion = new Version(Version); if (objVersion >= new Version(5, 1, 0)) { // current module content htmlContent.Content = DeTokeniseLinks(xml.SelectSingleNode("content").InnerText, module.PortalID); } else { // legacy module content htmlContent.Content = DeTokeniseLinks(xml.SelectSingleNode("desktophtml").InnerText, module.PortalID); } htmlContent.WorkflowID = workflowID; htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowID); // import UpdateHtmlText(htmlContent, GetMaximumVersionHistory(module.PortalID)); }
/// ----------------------------------------------------------------------------- /// <summary> /// CreateUserNotifications creates HtmlTextUser records and optionally sends email notifications to participants in a Workflow /// </summary> /// <remarks> /// </remarks> /// <param name="objHtmlText">An HtmlTextInfo object</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- private void CreateUserNotifications(HtmlTextInfo objHtmlText) { var _htmlTextUserController = new HtmlTextUserController(); HtmlTextUserInfo _htmlTextUser = null; UserInfo _user = null; // clean up old user notification records _htmlTextUserController.DeleteHtmlTextUsers(); // ensure we have latest htmltext object loaded objHtmlText = GetHtmlText(objHtmlText.ModuleID, objHtmlText.ItemID); // build collection of users to notify var objWorkflow = new WorkflowStateController(); var arrUsers = new ArrayList(); // if not published if (objHtmlText.IsPublished == false) { arrUsers.Add(objHtmlText.CreatedByUserID); // include content owner } // if not draft and not published if (objHtmlText.StateID != objWorkflow.GetFirstWorkflowStateID(objHtmlText.WorkflowID) && objHtmlText.IsPublished == false) { // get users from permissions for state var objRoles = new RoleController(); foreach (WorkflowStatePermissionInfo permission in WorkflowStatePermissionController.GetWorkflowStatePermissions(objHtmlText.StateID)) { if (permission.AllowAccess) { if (Null.IsNull(permission.UserID)) { int roleId = permission.RoleID; RoleInfo objRole = TestableRoleController.Instance.GetRole(objHtmlText.PortalID, r => r.RoleID == roleId); if ((objRole != null)) { foreach (UserRoleInfo objUserRole in objRoles.GetUserRoles(objHtmlText.PortalID, null, objRole.RoleName)) { if (!arrUsers.Contains(objUserRole.UserID)) { arrUsers.Add(objUserRole.UserID); } } } } else { if (!arrUsers.Contains(permission.UserID)) { arrUsers.Add(permission.UserID); } } } } } // process notifications if (arrUsers.Count > 0 || (objHtmlText.IsPublished && objHtmlText.Notify)) { // get tabid from module var objModules = new ModuleController(); ModuleInfo objModule = objModules.GetModule(objHtmlText.ModuleID); PortalSettings objPortalSettings = PortalController.GetCurrentPortalSettings(); if (objPortalSettings != null) { string strResourceFile = string.Format("{0}/DesktopModules/{1}/{2}/{3}", Globals.ApplicationPath, objModule.DesktopModule.FolderName, Localization.LocalResourceDirectory, Localization.LocalSharedResourceFile); string strSubject = Localization.GetString("NotificationSubject", strResourceFile); string strBody = Localization.GetString("NotificationBody", strResourceFile); strBody = strBody.Replace("[URL]", Globals.NavigateURL(objModule.TabID)); strBody = strBody.Replace("[STATE]", objHtmlText.StateName); // process user notification collection foreach (int intUserID in arrUsers) { // create user notification record _htmlTextUser = new HtmlTextUserInfo(); _htmlTextUser.ItemID = objHtmlText.ItemID; _htmlTextUser.StateID = objHtmlText.StateID; _htmlTextUser.ModuleID = objHtmlText.ModuleID; _htmlTextUser.TabID = objModule.TabID; _htmlTextUser.UserID = intUserID; _htmlTextUserController.AddHtmlTextUser(_htmlTextUser); // send an email notification to a user if the state indicates to do so if (objHtmlText.Notify) { _user = UserController.GetUserById(objHtmlText.PortalID, intUserID); if (_user != null) { AddHtmlNotification(strSubject, strBody, _user); } } } // if published and the published state specifies to notify members of the workflow if (objHtmlText.IsPublished && objHtmlText.Notify) { // send email notification to the author _user = UserController.GetUserById(objHtmlText.PortalID, objHtmlText.CreatedByUserID); if (_user != null) { try { Services.Mail.Mail.SendEmail(objPortalSettings.Email, objPortalSettings.Email, strSubject, strBody); } catch (Exception exc) { Exceptions.LogException(exc); } } } } } }
/// <summary> /// LoadSettings loads the settings from the Database and displays them /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> public override void LoadSettings() { try { if (!Page.IsPostBack) { var htmlTextController = new HtmlTextController(); var workflowStateController = new WorkflowStateController(); // get replace token settings if (ModuleSettings["HtmlText_ReplaceTokens"] != null) { chkReplaceTokens.Checked = Convert.ToBoolean(ModuleSettings["HtmlText_ReplaceTokens"]); } // get workflow/version settings var arrWorkflows = new ArrayList(); foreach (WorkflowStateInfo objState in workflowStateController.GetWorkflows(PortalId)) { if (!objState.IsDeleted) { arrWorkflows.Add(objState); } } cboWorkflow.DataSource = arrWorkflows; cboWorkflow.DataBind(); var workflow = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId); if ((cboWorkflow.Items.FindByValue(workflow.Value.ToString()) != null)) { cboWorkflow.Items.FindByValue(workflow.Value.ToString()).Selected = true; } DisplayWorkflowDetails(); if (rblApplyTo.Items.FindByValue(workflow.Key) != null) { rblApplyTo.Items.FindByValue(workflow.Key).Selected = true; } } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }