예제 #1
0
        /// <summary>
        ///   Displays the content but hide the editor if editing is locked from the current user
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        /// <param name = "lastPublishedContent">Last content of the published.</param>
        private void DisplayLockedContent(HtmlTextInfo htmlContent, HtmlTextInfo lastPublishedContent)
        {
            txtContent.Visible = false;
            cmdSave.Visible    = false;
            //cmdPreview.Visible = false;
            divPublish.Visible = false;

            divSubmittedContent.Visible = true;

            lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
            lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);

            litCurrentContentPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings);
            lblCurrentVersion.Text        = htmlContent.Version.ToString();
            DisplayVersions();

            if ((lastPublishedContent != null))
            {
                DisplayPreview(lastPublishedContent);
                //DisplayHistory(lastPublishedContent);
            }
            else
            {
                dnnSitePanelEditHTMLHistory.Visible = false;
                fsEditHtmlHistory.Visible           = false;
                DisplayPreview(htmlContent.Content);
            }
        }
예제 #2
0
        /// -----------------------------------------------------------------------------
        /// <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);
        }
예제 #3
0
        /// <summary>
        ///   Displays the content but hide the editor if editing is locked from the current user.
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        /// <param name = "lastPublishedContent">Last content of the published.</param>
        private void DisplayLockedContent(HtmlTextInfo htmlContent, HtmlTextInfo lastPublishedContent)
        {
            this.txtContent.Visible = false;
            this.cmdSave.Visible    = false;

            // cmdPreview.Enabled = false;
            this.divPublish.Visible = false;

            this.divSubmittedContent.Visible = true;

            this.lblCurrentWorkflowInUse.Text = this.GetLocalizedString(htmlContent.WorkflowName);
            this.lblCurrentWorkflowState.Text = this.GetLocalizedString(htmlContent.StateName);

            this.litCurrentContentPreview.Text = HtmlTextController.FormatHtmlText(this.ModuleId, htmlContent.Content, this.Settings, this.PortalSettings, this.Page);
            this.lblCurrentVersion.Text        = htmlContent.Version.ToString();
            this.DisplayVersions();

            if (lastPublishedContent != null)
            {
                this.DisplayPreview(lastPublishedContent);

                // DisplayHistory(lastPublishedContent);
            }
            else
            {
                this.dnnSitePanelEditHTMLHistory.Visible = false;
                this.fsEditHtmlHistory.Visible           = false;
                this.DisplayPreview(htmlContent.Content);
            }
        }
예제 #4
0
        /// -----------------------------------------------------------------------------
        /// <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));
        }
예제 #5
0
        /// -----------------------------------------------------------------------------
        /// <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);
            }
        }
예제 #6
0
 /// <summary>
 ///   Displays the content preview in the preview section
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayPreview(HtmlTextInfo htmlContent)
 {
     lblPreviewVersion.Text       = htmlContent.Version.ToString();
     lblPreviewWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
     lblPreviewWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
     litPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings);
     DisplayHistory(htmlContent);
 }
예제 #7
0
        /// <summary>
        ///   Displays the html content in the preview section.
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        private void DisplayContent(HtmlTextInfo htmlContent)
        {
            lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
            lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
            lblCurrentVersion.Text       = htmlContent.Version.ToString();
            txtContent.Text = FormatContent(htmlContent.Content);

            DisplayMasterLanguageContent();
        }
예제 #8
0
        /// <summary>
        ///   Gets the latest html content of the module.
        /// </summary>
        /// <returns></returns>
        private HtmlTextInfo GetLatestHTMLContent()
        {
            var htmlContent = this._htmlTextController.GetTopHtmlText(this.ModuleId, false, this.WorkflowID);

            if (htmlContent == null)
            {
                htmlContent            = new HtmlTextInfo();
                htmlContent.ItemID     = -1;
                htmlContent.StateID    = this._workflowStateController.GetFirstWorkflowStateID(this.WorkflowID);
                htmlContent.WorkflowID = this.WorkflowID;
                htmlContent.ModuleID   = this.ModuleId;
            }

            return(htmlContent);
        }
예제 #9
0
 /// <summary>
 ///   Displays the html content in the preview section.
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayContent(HtmlTextInfo htmlContent)
 {
     lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
     lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
     lblCurrentVersion.Text       = htmlContent.Version.ToString();
     txtContent.Text    = FormatContent(htmlContent.Content);
     phEdit.Visible     = true;
     phPreview.Visible  = false;
     phHistory.Visible  = false;
     cmdEdit.Enabled    = false;
     cmdPreview.Enabled = true;
     cmdHistory.Enabled = true;
     //DisplayMasterLanguageContent();
     DisplayMasterContentButton();
     ddlRender.Visible = true;
 }
예제 #10
0
 /// <summary>
 ///   Displays the content preview in the preview section.
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayPreview(HtmlTextInfo htmlContent)
 {
     this.lblPreviewVersion.Text       = htmlContent.Version.ToString();
     this.lblPreviewWorkflowInUse.Text = this.GetLocalizedString(htmlContent.WorkflowName);
     this.lblPreviewWorkflowState.Text = this.GetLocalizedString(htmlContent.StateName);
     this.litPreview.Text    = HtmlTextController.FormatHtmlText(this.ModuleId, htmlContent.Content, this.Settings, this.PortalSettings, this.Page);
     this.phEdit.Visible     = false;
     this.phPreview.Visible  = true;
     this.phHistory.Visible  = false;
     this.cmdEdit.Enabled    = true;
     this.cmdPreview.Enabled = false;
     this.cmdHistory.Enabled = true;
     this.DisplayHistory(htmlContent);
     this.cmdMasterContent.Visible = false;
     this.ddlRender.Visible        = false;
 }
예제 #11
0
        /// <summary>
        ///   Displays the history of an html content item in a grid in the preview section.
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        private void DisplayHistory(HtmlTextInfo htmlContent)
        {
            dnnSitePanelEditHTMLHistory.Visible = CurrentWorkflowType != WorkflowType.DirectPublish;
            fsEditHtmlHistory.Visible           = CurrentWorkflowType != WorkflowType.DirectPublish;

            if (((CurrentWorkflowType == WorkflowType.DirectPublish)))
            {
                return;
            }
            var htmlLogging = _htmlTextLogController.GetHtmlTextLog(htmlContent.ItemID);

            dgHistory.DataSource = htmlLogging;
            dgHistory.DataBind();

            dnnSitePanelEditHTMLHistory.Visible = htmlLogging.Count != 0;
            fsEditHtmlHistory.Visible           = htmlLogging.Count != 0;
        }
예제 #12
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "moduleId">The Id of the module to be exported</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public string ExportModule(int moduleId)
        {
            string xml = "";

            ModuleInfo module     = ModuleController.Instance.GetModule(moduleId, Null.NullInteger, true);
            int        workflowID = GetWorkflow(moduleId, module.TabID, module.PortalID).Value;

            HtmlTextInfo content = GetTopHtmlText(moduleId, true, workflowID);

            if ((content != null))
            {
                xml += "<htmltext>";
                xml += "<content>" + XmlUtils.XMLEncode(TokeniseLinks(content.Content, module.PortalID)) + "</content>";
                xml += "</htmltext>";
            }

            return(xml);
        }
예제 #13
0
        /// <summary>
        ///   Displays the html content in the preview section.
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        private void DisplayContent(HtmlTextInfo htmlContent)
        {
            lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
            lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
            lblCurrentVersion.Text       = htmlContent.Version.ToString();
            txtContent.Text    = FormatContent(htmlContent.Content);
            phEdit.Visible     = true;
            phPreview.Visible  = false;
            phHistory.Visible  = false;
            cmdEdit.Visible    = false;
            cmdPreview.Visible = true;
            cmdHistory.Visible = true;
            //DisplayMasterLanguageContent();
            var objModule = ModuleController.Instance.GetModule(ModuleId, TabId, false);

            if (objModule.DefaultLanguageModule != null)
            {
                cmdMasterContent.Visible = true;
                cmdMasterContent.Text    = Localization.GetString("cmdShowMasterContent", LocalResourceFile);
            }
        }
예제 #14
0
        /// -----------------------------------------------------------------------------
        /// <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);
            }
        }
예제 #15
0
        /// -----------------------------------------------------------------------------
        /// <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);
                            }
                        }
                    }
                }
            }
        }
예제 #16
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                var objHTML = new HtmlTextController();

                // edit in place
                if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit)
                {
                    EditorEnabled = true;
                }
                else
                {
                    EditorEnabled = false;
                }

                // get content
                HtmlTextInfo htmlTextInfo  = null;
                string       contentString = "";

                htmlTextInfo = objHTML.GetTopHtmlText(ModuleId, !IsEditable, WorkflowID);

                if ((htmlTextInfo != null))
                {
                    //don't decode yet (this is done in FormatHtmlText)
                    contentString = htmlTextInfo.Content;
                }
                else
                {
                    // get default content from resource file
                    if (!IsPostBack)
                    {
                        if (PortalSettings.UserMode == PortalSettings.Mode.Edit)
                        {
                            if (EditorEnabled)
                            {
                                contentString = Localization.GetString("AddContentFromToolBar.Text", LocalResourceFile);
                            }
                            else
                            {
                                contentString = Localization.GetString("AddContentFromActionMenu.Text", LocalResourceFile);
                            }
                        }
                        else
                        {
                            // hide the module if no content and in view mode
                            ContainerControl.Visible = false;
                        }
                    }
                }

                // token replace
                if (EditorEnabled && Settings["HtmlText_ReplaceTokens"] != null)
                {
                    EditorEnabled = !Convert.ToBoolean(Settings["HtmlText_ReplaceTokens"]);
                }

                // localize toolbar
                if (!IsPostBack)
                {
                    if (EditorEnabled)
                    {
                        foreach (DNNToolBarButton button in editorDnnToobar.Buttons)
                        {
                            button.ToolTip = Localization.GetString(button.ToolTip + ".ToolTip", LocalResourceFile);
                        }
                    }
                    else
                    {
                        editorDnnToobar.Visible = false;
                    }
                }

                lblContent.EditEnabled = EditorEnabled;

                // add content to module
                lblContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(ModuleId, contentString, Settings)));

                //set normalCheckBox on the content wrapper to prevent form decoration if its disabled.
                if (Settings.ContainsKey("HtmlText_UseDecorate") && Settings["HtmlText_UseDecorate"].ToString() == "0")
                {
                    lblContent.CssClass = string.Format("{0} normalCheckBox", lblContent.CssClass);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
예제 #17
0
        /// -----------------------------------------------------------------------------
        /// <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);
            }
        }
예제 #18
0
        /// <summary>
        ///   Displays the content but hide the editor if editing is locked from the current user
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        /// <param name = "lastPublishedContent">Last content of the published.</param>
        private void DisplayLockedContent(HtmlTextInfo htmlContent, HtmlTextInfo lastPublishedContent)
        {
            txtContent.Visible = false;
            cmdSave.Visible = false;
            //cmdPreview.Enabled = false;
            divPublish.Visible = false;

            divSubmittedContent.Visible = true;

            lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
            lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);

            litCurrentContentPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings);
            lblCurrentVersion.Text = htmlContent.Version.ToString();
            DisplayVersions();

            if ((lastPublishedContent != null))
            {
                DisplayPreview(lastPublishedContent);
                //DisplayHistory(lastPublishedContent);
            }
            else
            {
                dnnSitePanelEditHTMLHistory.Visible = false;
                fsEditHtmlHistory.Visible = false;
                DisplayPreview(htmlContent.Content);
            }
        }
예제 #19
0
 /// <summary>
 ///   Displays the content preview in the preview section
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayPreview(HtmlTextInfo htmlContent)
 {
     lblPreviewVersion.Text = htmlContent.Version.ToString();
     lblPreviewWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
     lblPreviewWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
     litPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings);
     phEdit.Visible = false;
     phPreview.Visible = true;
     phHistory.Visible = false;
     cmdEdit.Enabled = true;
     cmdPreview.Enabled = false;
     cmdHistory.Enabled = true;
     DisplayHistory(htmlContent);
     cmdMasterContent.Visible = false;
     ddlRender.Visible = false;
 }
예제 #20
0
 /// <summary>
 ///   Returns whether or not the user has review permissions to this module
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 /// <returns></returns>
 private bool UserCanReview(HtmlTextInfo htmlContent)
 {
     return (htmlContent != null) && WorkflowStatePermissionController.HasWorkflowStatePermission(WorkflowStatePermissionController.GetWorkflowStatePermissions(htmlContent.StateID), "REVIEW");
 }
예제 #21
0
        /// <summary>
        ///   Gets the latest html content of the module
        /// </summary>
        /// <returns></returns>
        private HtmlTextInfo GetLatestHTMLContent()
        {
            var htmlContent = _htmlTextController.GetTopHtmlText(ModuleId, false, WorkflowID);
            if (htmlContent == null)
            {
                htmlContent = new HtmlTextInfo();
                htmlContent.ItemID = -1;
                htmlContent.StateID = _workflowStateController.GetFirstWorkflowStateID(WorkflowID);
                htmlContent.WorkflowID = WorkflowID;
                htmlContent.ModuleID = ModuleId;
            }

            return htmlContent;
        }
예제 #22
0
 /// <summary>
 ///   Displays the html content in the preview section.
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayContent(HtmlTextInfo htmlContent)
 {
     lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
     lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
     lblCurrentVersion.Text = htmlContent.Version.ToString();
     txtContent.Text = FormatContent(htmlContent.Content);
     phEdit.Visible = true;
     phPreview.Visible = false;
     phHistory.Visible = false;
     cmdEdit.Enabled = false;
     cmdPreview.Enabled = true;
     cmdHistory.Enabled = true;
     //DisplayMasterLanguageContent();
     DisplayMasterContentButton();
     ddlRender.Visible = true;
 }
예제 #23
0
 /// <summary>
 ///   Displays the html content in the preview section.
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayContent(HtmlTextInfo htmlContent)
 {
     lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
     lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
     lblCurrentVersion.Text = htmlContent.Version.ToString();
     txtContent.Text = FormatContent(htmlContent.Content);
     phEdit.Visible = true;
     phPreview.Visible = false;
     phHistory.Visible = false;
     cmdEdit.Visible = false;
     cmdPreview.Visible = true;
     cmdHistory.Visible = true;
     //DisplayMasterLanguageContent();
     var objModule = ModuleController.Instance.GetModule(ModuleId, TabId, false);
     if (objModule.DefaultLanguageModule != null)
     {
         cmdMasterContent.Visible = true;
         cmdMasterContent.Text = Localization.GetString("cmdShowMasterContent", LocalResourceFile);
     }
 }
예제 #24
0
 /// <summary>
 ///   Displays the content preview in the preview section
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 private void DisplayPreview(HtmlTextInfo htmlContent)
 {
     lblPreviewVersion.Text = htmlContent.Version.ToString();
     lblPreviewWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
     lblPreviewWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
     litPreview.Text = HtmlTextController.FormatHtmlText(ModuleId, htmlContent.Content, Settings);
     DisplayHistory(htmlContent);
 }
예제 #25
0
        /// -----------------------------------------------------------------------------
        /// <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));
        }
예제 #26
0
 /// <summary>
 ///   Returns whether or not the user has review permissions to this module.
 /// </summary>
 /// <param name = "htmlContent">Content of the HTML.</param>
 /// <returns></returns>
 private bool UserCanReview(HtmlTextInfo htmlContent)
 {
     return((htmlContent != null) && WorkflowStatePermissionController.HasWorkflowStatePermission(WorkflowStatePermissionController.GetWorkflowStatePermissions(htmlContent.StateID), "REVIEW"));
 }
예제 #27
0
        /// -----------------------------------------------------------------------------
        /// <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);
        }
예제 #28
0
        /// <summary>
        ///   Displays the history of an html content item in a grid in the preview section.
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        private void DisplayHistory(HtmlTextInfo htmlContent)
        {
            dnnSitePanelEditHTMLHistory.Visible = CurrentWorkflowType != WorkflowType.DirectPublish;
            fsEditHtmlHistory.Visible = CurrentWorkflowType != WorkflowType.DirectPublish;

            if (((CurrentWorkflowType == WorkflowType.DirectPublish)))
            {
                return;
            }
            var htmlLogging = _htmlTextLogController.GetHtmlTextLog(htmlContent.ItemID);
            dgHistory.DataSource = htmlLogging;
            dgHistory.DataBind();

            dnnSitePanelEditHTMLHistory.Visible = htmlLogging.Count != 0;
            fsEditHtmlHistory.Visible = htmlLogging.Count != 0;
        }
예제 #29
0
        /// -----------------------------------------------------------------------------
        /// <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);
        }
예제 #30
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                var objHTML = new HtmlTextController();

                // edit in place
                if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit)
                {
                    EditorEnabled = true;
                }
                else
                {
                    EditorEnabled = false;
                }

                // get content
                HtmlTextInfo htmlTextInfo  = null;
                string       contentString = "";

                htmlTextInfo = objHTML.GetTopHtmlText(ModuleId, !IsEditable, WorkflowID);

                if ((htmlTextInfo != null))
                {
                    //don't decode yet (this is done in FormatHtmlText)
                    contentString = htmlTextInfo.Content;
                }
                else
                {
                    // get default content from resource file
                    if (PortalSettings.UserMode == PortalSettings.Mode.Edit)
                    {
                        if (EditorEnabled)
                        {
                            contentString = Localization.GetString("AddContentFromToolBar.Text", LocalResourceFile);
                        }
                        else
                        {
                            contentString = Localization.GetString("AddContentFromActionMenu.Text", LocalResourceFile);
                        }
                    }
                    else
                    {
                        // hide the module if no content and in view mode
                        ContainerControl.Visible = false;
                    }
                }

                // token replace
                EditorEnabled = EditorEnabled && !Settings.ReplaceTokens;

                // localize toolbar
                if (EditorEnabled)
                {
                    foreach (DNNToolBarButton button in editorDnnToobar.Buttons)
                    {
                        button.ToolTip = Localization.GetString(button.ToolTip + ".ToolTip", LocalResourceFile);
                    }
                }
                else
                {
                    editorDnnToobar.Visible = false;
                }

                lblContent.EditEnabled = EditorEnabled;

                // add content to module
                lblContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(ModuleId, contentString, Settings, PortalSettings, Page)));

                //set normalCheckBox on the content wrapper to prevent form decoration if its disabled.
                if (!Settings.UseDecorate)
                {
                    lblContent.CssClass = string.Format("{0} normalCheckBox", lblContent.CssClass);
                }

                if (IsPostBack && AJAX.IsEnabled() && AJAX.GetScriptManager(Page).IsInAsyncPostBack)
                {
                    var resetScript = $@"
if(typeof dnn !== 'undefined' && typeof dnn.controls !== 'undefined' && typeof dnn.controls.controls !== 'undefined'){{
    var control = dnn.controls.controls['{lblContent.ClientID}'];
    if(control && control.container !== $get('{lblContent.ClientID}')){{
        dnn.controls.controls['{lblContent.ClientID}'] = null;
    }}
}};";
                    ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), $"ResetHtmlModule{ClientID}", resetScript, true);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
예제 #31
0
        /// -----------------------------------------------------------------------------
        /// <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);
                            }
                        }
                    }
                }
            }
        }
예제 #32
0
        /// <summary>
        ///   Displays the html content in the preview section.
        /// </summary>
        /// <param name = "htmlContent">Content of the HTML.</param>
        private void DisplayContent(HtmlTextInfo htmlContent)
        {
            lblCurrentWorkflowInUse.Text = GetLocalizedString(htmlContent.WorkflowName);
            lblCurrentWorkflowState.Text = GetLocalizedString(htmlContent.StateName);
            lblCurrentVersion.Text = htmlContent.Version.ToString();
            txtContent.Text = FormatContent(htmlContent.Content);

            DisplayMasterLanguageContent();
        }