public static ContentWorkflow CreateDraftVersion( Guid siteGuid, string contentText, string customData, int customReferenceNumber, Guid customReferenceGuid, Guid moduleGuid, Guid userGuid) { ContentWorkflow draftVersion = new ContentWorkflow(); draftVersion.moduleGuid = moduleGuid; draftVersion.contentText = contentText; draftVersion.customData = customData; draftVersion.customReferenceNumber = customReferenceNumber; draftVersion.customReferenceGuid = customReferenceGuid; draftVersion.siteGuid = siteGuid; draftVersion.userGuid = userGuid; draftVersion.lastModUserGuid = userGuid; draftVersion.createdDateUtc = DateTime.UtcNow; draftVersion.status = ContentWorkflowStatus.Draft; draftVersion.Save(); return(draftVersion); }
/// <summary> /// Approves a draft and sets it's status as AwaitingPublishing /// </summary> /// <param name="siteGuid"></param> /// <param name="approvalUserGuid"></param> public void ApproveContentForPublishing(Guid siteGuid, Guid approvalUserGuid) { // get latest workflow record waiting for approval ContentWorkflow submittedContent = ContentWorkflow.GetWorkInProgress(this.moduleGuid, ContentWorkflowStatus.AwaitingApproval.ToString()); if (submittedContent == null) { return; } //update content workflow to show record is now AwaitingPublishing submittedContent.Status = ContentWorkflowStatus.AwaitingPublishing; submittedContent.LastModUserGuid = approvalUserGuid; submittedContent.LastModUtc = DateTime.UtcNow; submittedContent.Save(); }
public static ContentWorkflow GetWorkInProgress(Guid moduleGuid, string status) { using (IDataReader reader = DBContentWorkflow.GetWorkInProgress(moduleGuid, status)) { ContentWorkflow wip = new ContentWorkflow(); if (wip.PopulateFromReader(reader)) { return(wip); } else { return(null); } } }
public void PublishDraft(Guid siteGuid, Guid approvalUserGuid) { // get latest workflow record waiting for approval ContentWorkflow submittedContent = ContentWorkflow.GetWorkInProgress(this.moduleGuid, ContentWorkflowStatus.Draft.ToString()); if (submittedContent == null) { return; } // create a new content history record of the existing live content ContentHistory history = new ContentHistory(); history.ContentGuid = ModuleGuid; history.ContentText = Body; history.SiteGuid = siteGuid; history.UserGuid = LastModUserGuid; history.CreatedUtc = LastModUtc; history.Save(); //update the html with the approved content this.body = submittedContent.ContentText; // Joe D - this line looks like it would be wrong if not using 3 level approval // so I commented it out. I also added the if not Guid.Empty but then decided it was still wrong // a draft could be pubklished directly by an editor without ever submitting for approval // Joe A 2013-04-24 integration comment //Guid submitterGuid = ContentWorkflow.GetDraftSubmitter(submittedContent.Guid); //if (submitterGuid != Guid.Empty) //{ // this.lastModUserGuid = submitterGuid; //} //else //{ this.lastModUserGuid = submittedContent.LastModUserGuid; //} this.lastModUtc = DateTime.UtcNow; this.Save(); //update content workflow to show record is now approved submittedContent.Status = ContentWorkflowStatus.Approved; submittedContent.LastModUserGuid = approvalUserGuid; submittedContent.LastModUtc = DateTime.UtcNow; submittedContent.Save(); }
/// <summary> /// Publishes an approved content draft. /// </summary> /// <param name="siteGuid"></param> /// <param name="publishingUserGuid"></param> public void PublishApprovedContent(Guid siteGuid, Guid publishingUserGuid) { ContentWorkflow approvedContent = ContentWorkflow.GetWorkInProgress(this.moduleGuid, ContentWorkflowStatus.AwaitingPublishing.ToString()); if (approvedContent == null) { return; } // create a new content history record of the existing live content ContentHistory history = new ContentHistory(); history.ContentGuid = ModuleGuid; history.ContentText = Body; history.SiteGuid = siteGuid; history.UserGuid = LastModUserGuid; history.CreatedUtc = LastModUtc; history.Save(); //update the html with the approved content this.body = approvedContent.ContentText; Guid submitterGuid = ContentWorkflow.GetDraftSubmitter(approvedContent.Guid); if (submitterGuid != Guid.Empty) { this.lastModUserGuid = submitterGuid; } this.lastModUtc = DateTime.UtcNow; this.Save(); //update content workflow to show record is now approved approvedContent.Status = ContentWorkflowStatus.Approved; approvedContent.LastModUserGuid = publishingUserGuid; approvedContent.LastModUtc = DateTime.UtcNow; approvedContent.Save(); }
public void ApproveContent(Guid siteGuid, Guid approvalUserGuid, bool allowUnsubmitted) { // get latest workflow record waiting for approval ContentWorkflow submittedContent = ContentWorkflow.GetWorkInProgress(this.moduleGuid, ContentWorkflowStatus.AwaitingApproval.ToString()); if ((submittedContent == null) && (allowUnsubmitted)) { submittedContent = ContentWorkflow.GetWorkInProgress(this.moduleGuid, ContentWorkflowStatus.Draft.ToString()); } if (submittedContent == null) { return; } // create a new content history record of the existing live content ContentHistory history = new ContentHistory(); history.ContentGuid = ModuleGuid; history.ContentText = Body; history.SiteGuid = siteGuid; history.UserGuid = LastModUserGuid; history.CreatedUtc = LastModUtc; history.Save(); //update the html with the approved content this.body = submittedContent.ContentText; this.lastModUserGuid = submittedContent.LastModUserGuid; this.lastModUtc = DateTime.UtcNow; this.Save(); //update content workflow to show record is now approved submittedContent.Status = ContentWorkflowStatus.Approved; submittedContent.LastModUserGuid = approvalUserGuid; submittedContent.LastModUtc = DateTime.UtcNow; submittedContent.Save(); }
private void LoadSettings() { pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); //if (Request.Form.Count > 0) //{ // submittedContent = Server.UrlDecode(Request.Form.ToString()); // this gets the full content of the post //} if (Request.Form["html"] != null) { submittedContent = Request.Form["html"]; //log.Info("html does = " + Request.Form["html"]); } //using (Stream s = Request.InputStream) //{ // using (StreamReader sr = new StreamReader(s)) // { // string requestBody = sr.ReadToEnd(); // requestBody = Server.UrlDecode(requestBody); // log.Info("requestBody was " + requestBody); // JObject jObj = JObject.Parse(requestBody); // submittedContent = (string)jObj["html"]; // } //} module = GetHtmlModule(); if (module == null) { return; } currentUser = SiteUtils.GetCurrentSiteUser(); repository = new HtmlRepository(); moduleSettings = ModuleSettings.GetModuleSettings(module.ModuleId); config = new HtmlConfiguration(moduleSettings); enableContentVersioning = config.EnableContentVersioning; if ((CurrentSite.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } userCanOnlyEditAsDraft = UserCanOnlyEditModuleAsDraft(module.ModuleId, HtmlContent.FeatureGuid); if ((WebConfigSettings.EnableContentWorkflow) && (CurrentSite.EnableContentWorkflow)) { workInProgress = ContentWorkflow.GetWorkInProgress(module.ModuleGuid); } if (workInProgress != null) { switch (workInProgress.Status) { case ContentWorkflowStatus.Draft: //there is a draft version currently available, therefore dont allow the non draft version to be edited: if (ViewMode == PageViewMode.WorkInProgress) { editDraft = true; } break; case ContentWorkflowStatus.ApprovalRejected: //rejected content - allow update as draft only if (ViewMode == PageViewMode.WorkInProgress) { editDraft = true; } break; case ContentWorkflowStatus.AwaitingApproval: //pending approval - dont allow any edited: // 2010-01-18 let editors update the draft if they want to before approving it. editDraft = !userCanOnlyEditAsDraft; break; } } //for (int i = 0; i < Request.QueryString.Count; i++) //{ // log.Info(Request.QueryString.GetKey(i) + " query param = " + Request.QueryString.Get(i)); //} //if (Request.Form["c"] != null) //{ // submittedContent = Request.Form["c"]; // log.Info("c does = " + Request.Form["c"]); //} // this shows that a large html content post appears as multiple params //for (int i = 0; i < Request.Form.Count; i++) //{ // log.Info(Request.Form.GetKey(i) + " form param " + i.ToInvariantString() + " = " + Request.Form.Get(i)); //} }
//joe davis protected SiteUser GetDraftSubmitter(ContentWorkflow workflow) { // hey joe d, note this will still return a user object even if the draft submitter guid comes back empty? return new SiteUser(siteSettings, ContentWorkflow.GetDraftSubmitter(workflow.Guid)); }
public static ContentWorkflow GetWorkInProgress(Guid moduleGuid, string status) { using (IDataReader reader = DBContentWorkflow.GetWorkInProgress(moduleGuid, status)) { ContentWorkflow wip = new ContentWorkflow(); if (wip.PopulateFromReader(reader)) return wip; else return null; } }
private void ShowModified(HtmlContent html, ContentWorkflow workInProgress) { if ((html == null) && (workInProgress == null)) { return; } string modifiedByUserDateFormat = Resource.ModifiedByUserDateFormat; if (displaySettings.OverrideModifiedByUserDateFormat.Length > 0) { modifiedByUserDateFormat = displaySettings.OverrideModifiedByUserDateFormat; } string modifiedDateFormat = Resource.ModifiedDateFormat; if (displaySettings.OverrideModifiedDateFormat.Length > 0) { modifiedDateFormat = displaySettings.OverrideModifiedDateFormat; } string modifiedByUserFormat = Resource.ModifiedByUserFormat; if (displaySettings.OverrideModifiedByUserFormat.Length > 0) { modifiedByUserFormat = displaySettings.OverrideModifiedByUserFormat; } if (config.ShowModifiedBy && config.ShowModifiedDate) { if (workInProgress != null) { litModifiedBy.Text = string.Format(CultureInfo.InvariantCulture, modifiedByUserDateFormat, workInProgress.CreatedDateUtc.ToLocalTime(timeZone).ToString(displaySettings.DateFormat), GetModifiedByName(workInProgress) ); } else if (html != null) { litModifiedBy.Text = string.Format(CultureInfo.InvariantCulture, modifiedByUserDateFormat, html.LastModUtc.ToLocalTime(timeZone).ToString(displaySettings.DateFormat), GetModifiedByName(html) ); } } else if (config.ShowModifiedDate) { if (workInProgress != null) { litModifiedBy.Text = string.Format(CultureInfo.InvariantCulture, modifiedDateFormat, workInProgress.LastModUtc.ToLocalTime(timeZone).ToString(displaySettings.DateFormat) ); } else if (html != null) { litModifiedBy.Text = string.Format(CultureInfo.InvariantCulture, modifiedDateFormat, html.LastModUtc.ToLocalTime(timeZone).ToString(displaySettings.DateFormat) ); } } else if (config.ShowModifiedBy) { if (workInProgress != null) { litModifiedBy.Text = string.Format(CultureInfo.InvariantCulture, modifiedByUserFormat, GetModifiedByName(workInProgress) ); } else if (html != null) { litModifiedBy.Text = string.Format(CultureInfo.InvariantCulture, modifiedByUserFormat, GetModifiedByName(html) ); } } pnlModifiedBy.Visible = true; }
public static void SendApprovalRequestNotification( SmtpSettings smtpSettings, SiteSettings siteSettings, SiteUser submittingUser, ContentWorkflow draftWorkflow, string approvalRoles, string contentUrl ) { if (string.IsNullOrEmpty(approvalRoles)) { approvalRoles = "Admins;Content Administrators;Content Publishers;"; } List<string> emailAddresses = SiteUser.GetEmailAddresses(siteSettings.SiteId, approvalRoles); //int queuedMessageCount = 0; CultureInfo defaultCulture = SiteUtils.GetDefaultUICulture(); string messageTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestNotification.config"); string messageSubject = ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName); foreach (string email in emailAddresses) { if (WebConfigSettings.EmailAddressesToExcludeFromAdminNotifications.IndexOf(email, StringComparison.InvariantCultureIgnoreCase) > -1) { continue; } if (!Email.IsValidEmailAddressSyntax(email)) { continue; } StringBuilder message = new StringBuilder(); message.Append(messageTemplate); message.Replace("{ModuleTitle}", draftWorkflow.ModuleTitle); message.Replace("{ApprovalRequestedDate}", draftWorkflow.RecentActionOn.ToShortDateString()); message.Replace("{SubmittedBy}", submittingUser.Name); message.Replace("{ContentUrl}", contentUrl); if (!Email.IsValidEmailAddressSyntax(draftWorkflow.RecentActionByUserEmail)) { //invalid address log it log.Error("Failed to send workflow rejection message, invalid recipient email " + draftWorkflow.RecentActionByUserEmail + " message was " + message.ToString()); return; } //EmailMessageTask messageTask = new EmailMessageTask(smtpSettings); //messageTask.SiteGuid = siteSettings.SiteGuid; //messageTask.EmailFrom = siteSettings.DefaultEmailFromAddress; //messageTask.EmailReplyTo = submittingUser.Email; //messageTask.EmailTo = email; //messageTask.Subject = messageSubject; //messageTask.TextBody = message.ToString(); //messageTask.QueueTask(); //queuedMessageCount += 1; Email.Send( smtpSettings, siteSettings.DefaultEmailFromAddress, siteSettings.DefaultFromEmailAlias, submittingUser.Email, email, string.Empty, string.Empty, messageSubject, message.ToString(), false, Email.PriorityNormal); } //if (queuedMessageCount > 0) { WebTaskManager.StartOrResumeTasks(); } }
public static void SendRejectionNotification( SmtpSettings smtpSettings, SiteSettings siteSettings, SiteUser rejectingUser, ContentWorkflow rejectedWorkflow, string rejectionReason ) { //EmailMessageTask messageTask = new EmailMessageTask(smtpSettings); //messageTask.SiteGuid = siteSettings.SiteGuid; //messageTask.EmailFrom = siteSettings.DefaultEmailFromAddress; //messageTask.EmailFromAlias = siteSettings.DefaultFromEmailAlias; //messageTask.EmailReplyTo = rejectingUser.Email; //messageTask.EmailTo = rejectedWorkflow.RecentActionByUserEmail; CultureInfo defaultCulture = SiteUtils.GetDefaultUICulture(); //messageTask.Subject = ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestRejectionNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName); StringBuilder message = new StringBuilder(); message.Append(ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestRejectionNotification.config")); message.Replace("{ModuleTitle}", rejectedWorkflow.ModuleTitle); message.Replace("{ApprovalRequestedDate}", rejectedWorkflow.RecentActionOn.ToShortDateString()); message.Replace("{RejectionReason}", rejectionReason); message.Replace("{RejectedBy}", rejectingUser.Name); if (!Email.IsValidEmailAddressSyntax(rejectedWorkflow.RecentActionByUserEmail)) { //invalid address log it log.Error("Failed to send workflow rejection message, invalid recipient email " + rejectedWorkflow.RecentActionByUserEmail + " message was " + message.ToString()); return; } //messageTask.TextBody = message.ToString(); //messageTask.QueueTask(); //WebTaskManager.StartOrResumeTasks(); Email.Send( smtpSettings, siteSettings.DefaultEmailFromAddress, siteSettings.DefaultFromEmailAlias, rejectingUser.Email, rejectedWorkflow.RecentActionByUserEmail, string.Empty, string.Empty, ResourceHelper.GetMessageTemplate(defaultCulture, "ApprovalRequestRejectionNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName), message.ToString(), false, Email.PriorityNormal); }
public static void SendPublishRequestNotification( SmtpSettings smtpSettings, SiteSettings siteSettings, SiteUser submittingUser, SiteUser approvingUser, ContentWorkflow draftWorkflow, string publisherRoles, string contentUrl ) { if (string.IsNullOrEmpty(publisherRoles)) { publisherRoles = "Admins;Content Administrators;Content Publishers;"; } Module module = new Module(draftWorkflow.ModuleGuid); if (module == null) { return; } List<string> emailAddresses = SiteUser.GetEmailAddresses(siteSettings.SiteId, publisherRoles); //int queuedMessageCount = 0; CultureInfo defaultCulture = SiteUtils.GetDefaultUICulture(); string messageTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "PublishRequestNotification.config"); string messageSubject = ResourceHelper.GetMessageTemplate(defaultCulture, "PublishRequestNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName); foreach (string email in emailAddresses) { if (WebConfigSettings.EmailAddressesToExcludeFromAdminNotifications.IndexOf(email, StringComparison.InvariantCultureIgnoreCase) > -1) { continue; } if (!Email.IsValidEmailAddressSyntax(email)) { continue; } StringBuilder message = new StringBuilder(); message.Append(messageTemplate); message.Replace("{ModuleTitle}", draftWorkflow.ModuleTitle); message.Replace("{PublishRequestedDate}", draftWorkflow.RecentActionOn.ToShortDateString()); message.Replace("{SubmittedBy}", submittingUser.Name); message.Replace("{ApprovedBy}", approvingUser.Name); message.Replace("{ContentUrl}", contentUrl); Email.Send( smtpSettings, siteSettings.DefaultEmailFromAddress, siteSettings.DefaultFromEmailAlias, submittingUser.Email, email, string.Empty, string.Empty, messageSubject, message.ToString(), false, Email.PriorityNormal); } }
public static void SendPublishRejectionNotification( SmtpSettings smtpSettings, SiteSettings siteSettings, SiteUser rejectingUser, SiteUser draftSubmissionUser, ContentWorkflow rejectedWorkflow, string rejectionReason ) { CultureInfo defaultCulture = SiteUtils.GetDefaultUICulture(); string messageTemplate = String.Empty; string messageSubject = String.Empty; List<string> messageRecipients = new List<string>(); if (Email.IsValidEmailAddressSyntax(rejectedWorkflow.RecentActionByUserEmail)) { messageRecipients.Add(rejectedWorkflow.RecentActionByUserEmail); } messageTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "PublishRequestRejectionNotification.config"); messageSubject = ResourceHelper.GetMessageTemplate(defaultCulture, "PublishRequestRejectionNotificationSubject.config").Replace("{SiteName}", siteSettings.SiteName); if (Email.IsValidEmailAddressSyntax(draftSubmissionUser.LoweredEmail)) { messageRecipients.Add(draftSubmissionUser.LoweredEmail); } StringBuilder message = new StringBuilder(); message.Append(messageTemplate); message.Replace("{ModuleTitle}", rejectedWorkflow.ModuleTitle); message.Replace("{PublishRequestedDate}", rejectedWorkflow.RecentActionOn.ToShortDateString()); message.Replace("{RejectionReason}", rejectionReason); message.Replace("{RejectedBy}", rejectingUser.Name); if (messageRecipients.Count < 1) { //no valid addresses -- log it log.Error("Failed to send workflow publish rejection message, no valid recipient email " + rejectedWorkflow.RecentActionByUserEmail + ", " + draftSubmissionUser.LoweredEmail + " message was " + message.ToString()); return; } foreach (string recipient in messageRecipients) { Email.Send( smtpSettings, siteSettings.DefaultEmailFromAddress, siteSettings.DefaultFromEmailAlias, rejectingUser.Email, recipient, string.Empty, string.Empty, messageSubject, message.ToString(), false, Email.PriorityNormal); } }
public bool ContainsModuleInProgress() { int count = ContentWorkflow.GetWorkInProgressCountByPage(this.PageGuid); return(count > 0); }
private string GetModifiedByName(ContentWorkflow workInProgress) { if (displaySettings.UseAuthorFirstAndLastName) { if ((workInProgress.LastModByUserFirstName.Length > 0) && (workInProgress.LastModByUserLastName.Length > 0)) { return workInProgress.LastModByUserFirstName + " " + workInProgress.LastModByUserLastName; } } return workInProgress.LastModByUserName; }
public static ContentWorkflow CreateDraftVersion( Guid siteGuid, string contentText, string customData, int customReferenceNumber, Guid customReferenceGuid, Guid moduleGuid, Guid userGuid) { ContentWorkflow draftVersion = new ContentWorkflow(); draftVersion.moduleGuid = moduleGuid; draftVersion.contentText = contentText; draftVersion.customData = customData; draftVersion.customReferenceNumber = customReferenceNumber; draftVersion.customReferenceGuid = customReferenceGuid; draftVersion.siteGuid = siteGuid; draftVersion.userGuid = userGuid; draftVersion.lastModUserGuid = userGuid; draftVersion.createdDateUtc = DateTime.UtcNow; draftVersion.status = ContentWorkflowStatus.Draft; draftVersion.Save(); return draftVersion; }
private void LoadSettings() { Title1.EditUrl = SiteRoot + "/HtmlEdit.aspx"; Title1.EditText = Resource.EditImageAltText; Title1.ToolTip = Resource.EditImageAltText; Title1.Visible = !this.RenderInWebPartMode; timeZone = SiteUtils.GetUserTimeZone(); if ((WebUser.IsAdminOrContentAdmin) || (SiteUtils.UserIsSiteEditor())) { isAdmin = true; Title1.IsAdminEditor = isAdmin; } if (IsEditable) { TitleUrl = SiteRoot + "/HtmlEdit.aspx" + "?mid=" + ModuleId.ToInvariantString() + "&pageid=" + currentPage.PageId.ToInvariantString(); } config = new HtmlConfiguration(Settings); if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if ((config.IncludeSwfObject)&&(Page is mojoBasePage)) { mojoBasePage p = Page as mojoBasePage; if (p != null) { p.ScriptConfig.IncludeSwfObject = true; } } if (this.ModuleConfiguration != null) { this.Title = this.ModuleConfiguration.ModuleTitle; this.Description = this.ModuleConfiguration.FeatureName; } if (config.EnableContentRatingSetting && !displaySettings.DisableContentRating) { if (displaySettings.UseBottomContentRating) { RatingBottom.Enabled = config.EnableContentRatingSetting; RatingBottom.AllowFeedback = config.EnableRatingCommentsSetting; RatingBottom.ContentGuid = ModuleGuid; } else { Rating.Enabled = config.EnableContentRatingSetting; Rating.AllowFeedback = config.EnableRatingCommentsSetting; Rating.ContentGuid = ModuleGuid; } } //pnlContainer.ModuleId = this.ModuleId; if (config.EnableSlideShow) { divContent.EnableSlideShow = true; divContent.EnableSlideClick = config.EnableSlideClick; divContent.Random = config.RandomizeSlides; divContent.CleartypeNoBg = !config.UseSlideClearTypeCorrections; divContent.SlideContainerClass = config.SlideContainerClass; divContent.PauseOnHover = config.PauseSlideOnHover; divContent.TransitionEffect = config.SlideTransitions; divContent.TransitionInterval = config.SlideDuration; divContent.Speed = config.TransitionSpeed; if (config.SlideContainerHeight > 0) { divContent.ContainerHeight = config.SlideContainerHeight.ToInvariantString() + "px"; } if (config.EnableSlideShowPager) { divContent.Pager = "cyclenav"; if (config.SlideShowPagerBefore) { divContent.PagerBefore = true; } } } if (displaySettings.UseHtml5Elements) { if (displaySettings.UseOuterBodyForHtml5Article) { pnlOuterBody.Element = "article"; } else { pnlInnerWrap.Element = "article"; } //if (!IsPostBack) //{ // Title1.LiteralExtraTopContent += "<header>"; // Title1.LiteralExtraBottomContent += "</header>"; // this was a bug just use the theme value //} } if (EnableWorkflow) { //use mojo base page to see if user has toggled draft content: CmsPage cmsPage = this.Page as CmsPage; if (cmsPage != null) { if (cmsPage.ViewMode == PageViewMode.WorkInProgress) { //try to get draft content: workInProgress = ContentWorkflow.GetWorkInProgress(this.ModuleGuid); } } } if ((IsEditable) && (WebConfigSettings.EnableInlineEditing)) { if((WebConfigSettings.TinyMceUseV4)&&(siteSettings.EditorProviderName == "TinyMCEProvider")) { SetupTinyMceInline(); } else { SetupCKEditorInline(); } } }
private static List<ContentWorkflow> LoadListFromReader(IDataReader reader) { List<ContentWorkflow> contentWorkflowList = new List<ContentWorkflow>(); try { while (reader.Read()) { ContentWorkflow contentWorkflow = new ContentWorkflow(); contentWorkflow.guid = new Guid(reader["Guid"].ToString()); contentWorkflow.siteGuid = new Guid(reader["SiteGuid"].ToString()); contentWorkflow.userGuid = new Guid(reader["UserGuid"].ToString()); contentWorkflow.moduleGuid = new Guid(reader["ModuleGuid"].ToString()); contentWorkflow.contentText = reader["ContentText"].ToString(); contentWorkflow.customData = reader["CustomData"].ToString(); object val = reader["CustomReferenceNumber"]; contentWorkflow.customReferenceNumber = val == DBNull.Value ? -1 : Convert.ToInt32(val); val = reader["CustomReferenceGuid"]; contentWorkflow.customReferenceGuid = val == DBNull.Value ? Guid.Empty : new Guid(val.ToString()); contentWorkflow.createdDateUtc = Convert.ToDateTime(reader["CreatedDateUtc"]); //val = reader["LastModUserGuid"]; //contentWorkflow.lastModUserGuid = val == DBNull.Value ? null : (Guid?)new Guid(val.ToString()); contentWorkflow.lastModUserGuid = new Guid(reader["LastModUserGuid"].ToString()); //val = reader["LastModUtc"]; //contentWorkflow.lastModUtc = val == DBNull.Value ? null : (DateTime?)DateTime.Parse(val.ToString()); contentWorkflow.lastModUtc = Convert.ToDateTime(reader["LastModUtc"]); contentWorkflow.createdByUserLogin = reader["CreatedByUserLogin"].ToString(); contentWorkflow.createdByUserName = reader["CreatedByUserName"].ToString(); contentWorkflow.recentActionByUserLogin = reader["RecentActionByUserLogin"].ToString(); contentWorkflow.recentActionByUserName = reader["RecentActionByUserName"].ToString(); contentWorkflow.recentActionByUserEmail = reader["RecentActionByUserEmail"].ToString(); string statusVal = reader["Status"].ToString(); contentWorkflow.status = String.IsNullOrEmpty(statusVal) ? ContentWorkflowStatus.None : (ContentWorkflowStatus)Enum.Parse(typeof(ContentWorkflowStatus), statusVal); contentWorkflow.originalStatus = contentWorkflow.status; contentWorkflow.notes = reader["Notes"].ToString(); //val = reader["RecentActionOn"]; //contentWorkflow.recentActionOn = val == null ? null : (DateTime?)DateTime.Parse(val.ToString()); if (reader["RecentActionOn"] != DBNull.Value) { contentWorkflow.recentActionOn = Convert.ToDateTime(reader["RecentActionOn"]); } contentWorkflow.moduleTitle = reader["ModuleTitle"].ToString(); contentWorkflow.moduleId = Convert.ToInt32(reader["ModuleID"]); contentWorkflow.createdByUserFirstName = reader["CreatedByFirstName"].ToString(); contentWorkflow.createdByUserLastName = reader["CreatedByLastName"].ToString(); contentWorkflow.authorEmail = reader["CreatedByUserEmail"].ToString(); contentWorkflow.authorAvatar = reader["CreatedByAvatar"].ToString(); contentWorkflow.authorBio = reader["CreatedByAuthorBio"].ToString(); contentWorkflow.authorUserId = Convert.ToInt32(reader["CreatedByUserID"]); contentWorkflow.lastModByUserLastName = reader["ModifiedByUserName"].ToString(); contentWorkflow.lastModByUserFirstName = reader["ModifiedByFirstName"].ToString(); contentWorkflow.lastModByUserLastName = reader["ModifiedByLastName"].ToString(); contentWorkflowList.Add(contentWorkflow); } } finally { reader.Close(); } return contentWorkflowList; }
private void LoadSettings() { ScriptConfig.IncludeColorBox = true; repository = new HtmlRepository(); try { // this keeps the action from changing during ajax postback in folder based sites SiteUtils.SetFormAction(Page, Request.RawUrl); } catch (MissingMethodException) { //this method was introduced in .NET 3.5 SP1 } virtualRoot = WebUtils.GetApplicationRoot(); currentUser = SiteUtils.GetCurrentSiteUser(); timeOffset = SiteUtils.GetUserTimeOffset(); lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl(); module = GetHtmlModule(); if (module == null) { SiteUtils.RedirectToAccessDeniedPage(this); return; } if (module.ModuleTitle.Length == 0) { //this is not persisted just used for display if there is no title module.ModuleTitle = Resource.EditHtmlSettingsLabel; } heading.Text = Server.HtmlEncode(module.ModuleTitle); userCanEdit = UserCanEdit(moduleId); userCanEditAsDraft = UserCanOnlyEditModuleAsDraft(moduleId, HtmlContent.FeatureGuid); divExcludeFromRecentContent.Visible = userCanEdit; pageSize = config.VersionPageSize; enableContentVersioning = config.EnableContentVersioning; if ((siteSettings.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } if ((WebUser.IsAdminOrContentAdmin) || (SiteUtils.UserIsSiteEditor())) { isAdmin = true; } edContent.WebEditor.ToolBar = ToolBar.FullWithTemplates; if (moduleSettings.Contains("HtmlEditorHeightSetting")) { edContent.WebEditor.Height = Unit.Parse(moduleSettings["HtmlEditorHeightSetting"].ToString()); } divHistoryDelete.Visible = (enableContentVersioning && isAdmin); pnlHistory.Visible = enableContentVersioning; SetupScript(); html = repository.Fetch(moduleId); if (html == null) { html = new HtmlContent(); html.ModuleId = moduleId; html.ModuleGuid = module.ModuleGuid; } if ((!userCanEdit) && (userCanEditAsDraft)) { btnUpdate.Visible = false; btnUpdateDraft.Visible = true; } btnUpdateDraft.Text = Resource.EditHtmlUpdateDraftButton; if ((WebConfigSettings.EnableContentWorkflow) && (siteSettings.EnableContentWorkflow)) { workInProgress = ContentWorkflow.GetWorkInProgress(this.module.ModuleGuid); //bool draftOnlyAccess = UserCanOnlyEditModuleAsDraft(moduleId); if (workInProgress != null) { // let editors toggle between draft and live view in the editor if (userCanEdit) { SetupWorkflowControls(true); } switch (workInProgress.Status) { case ContentWorkflowStatus.Draft: //there is a draft version currently available, therefore dont allow the non draft version to be edited: btnUpdateDraft.Visible = true; btnUpdate.Visible = false; if (ViewMode == PageViewMode.WorkInProgress) { //litModuleTitle.Text += " - " + Resource.ApprovalProcessStatusDraft; heading.Text = string.Format(CultureInfo.InvariantCulture, Resource.DraftFormat, module.ModuleTitle); lblContentStatusLabel.SetOrAppendCss("wf-draft"); //JOE DAVIS if (userCanEdit) { btnPublishDraft.Visible = true; } } break; case ContentWorkflowStatus.ApprovalRejected: //rejected content - allow update as draft only btnUpdateDraft.Visible = true; btnUpdate.Visible = false; if (ViewMode == PageViewMode.WorkInProgress) { //litModuleTitle.Text += " - " + Resource.ApprovalProcessStatusRejected; heading.Text = string.Format(CultureInfo.InvariantCulture, Resource.ContentRejectedFormat, module.ModuleTitle); lblContentStatusLabel.SetOrAppendCss("wf-rejected"); //JOE DAVIS } break; case ContentWorkflowStatus.AwaitingApproval: //pending approval - dont allow any edited: // 2010-01-18 let editors update the draft if they want to before approving it. btnUpdateDraft.Visible = userCanEdit; btnUpdate.Visible = false; if (ViewMode == PageViewMode.WorkInProgress) { //litModuleTitle.Text += " - " + Resource.ApprovalProcessStatusAwaitingApproval; heading.Text = string.Format(CultureInfo.InvariantCulture, Resource.ContentAwaitingApprovalFormat, module.ModuleTitle); lblContentStatusLabel.SetOrAppendCss("wf-awaitingapproval"); //JOE DAVIS } break; //JOE DAVIS case ContentWorkflowStatus.AwaitingPublishing: //pending publishing - allow editors, publishers, admin to update before publishing btnUpdateDraft.Visible = userCanEdit; btnUpdate.Visible = false; if (ViewMode == PageViewMode.WorkInProgress) { heading.Text = string.Format(CultureInfo.InvariantCulture, Resource.ContentAwaitingPublishingFormat, module.ModuleTitle); lblContentStatusLabel.SetOrAppendCss("wf-awaitingpublishing"); } break; } } else { //workInProgress is null there is no draft if (userCanEdit) { btnUpdateDraft.Text = Resource.CreateDraftButton; btnUpdateDraft.Visible = true; } } if ((userCanEdit) && (ViewMode == PageViewMode.Live)) { btnUpdateDraft.Visible = false; btnUpdate.Visible = true; } } AddClassToBody("htmledit"); }
private void LoadSettings() { module = new Module(moduleId); workInProgress = ContentWorkflow.GetWorkInProgress(module.ModuleGuid); AddClassToBody("administration"); AddClassToBody("wfadmin"); }
//public bool IsValid //{ // get { return (GetRuleViolations().Count() == 0); } //} #endregion private static List <ContentWorkflow> LoadListFromReader(IDataReader reader) { List <ContentWorkflow> contentWorkflowList = new List <ContentWorkflow>(); try { while (reader.Read()) { ContentWorkflow contentWorkflow = new ContentWorkflow(); contentWorkflow.guid = new Guid(reader["Guid"].ToString()); contentWorkflow.siteGuid = new Guid(reader["SiteGuid"].ToString()); contentWorkflow.userGuid = new Guid(reader["UserGuid"].ToString()); contentWorkflow.moduleGuid = new Guid(reader["ModuleGuid"].ToString()); contentWorkflow.contentText = reader["ContentText"].ToString(); contentWorkflow.customData = reader["CustomData"].ToString(); object val = reader["CustomReferenceNumber"]; contentWorkflow.customReferenceNumber = val == DBNull.Value ? -1 : Convert.ToInt32(val); val = reader["CustomReferenceGuid"]; contentWorkflow.customReferenceGuid = val == DBNull.Value ? Guid.Empty : new Guid(val.ToString()); contentWorkflow.createdDateUtc = Convert.ToDateTime(reader["CreatedDateUtc"]); //val = reader["LastModUserGuid"]; //contentWorkflow.lastModUserGuid = val == DBNull.Value ? null : (Guid?)new Guid(val.ToString()); contentWorkflow.lastModUserGuid = new Guid(reader["LastModUserGuid"].ToString()); //val = reader["LastModUtc"]; //contentWorkflow.lastModUtc = val == DBNull.Value ? null : (DateTime?)DateTime.Parse(val.ToString()); contentWorkflow.lastModUtc = Convert.ToDateTime(reader["LastModUtc"]); contentWorkflow.createdByUserLogin = reader["CreatedByUserLogin"].ToString(); contentWorkflow.createdByUserName = reader["CreatedByUserName"].ToString(); contentWorkflow.recentActionByUserLogin = reader["RecentActionByUserLogin"].ToString(); contentWorkflow.recentActionByUserName = reader["RecentActionByUserName"].ToString(); contentWorkflow.recentActionByUserEmail = reader["RecentActionByUserEmail"].ToString(); string statusVal = reader["Status"].ToString(); contentWorkflow.status = String.IsNullOrEmpty(statusVal) ? ContentWorkflowStatus.None : (ContentWorkflowStatus)Enum.Parse(typeof(ContentWorkflowStatus), statusVal); contentWorkflow.originalStatus = contentWorkflow.status; contentWorkflow.notes = reader["Notes"].ToString(); //val = reader["RecentActionOn"]; //contentWorkflow.recentActionOn = val == null ? null : (DateTime?)DateTime.Parse(val.ToString()); if (reader["RecentActionOn"] != DBNull.Value) { contentWorkflow.recentActionOn = Convert.ToDateTime(reader["RecentActionOn"]); } contentWorkflow.moduleTitle = reader["ModuleTitle"].ToString(); contentWorkflow.moduleId = Convert.ToInt32(reader["ModuleID"]); contentWorkflow.createdByUserFirstName = reader["CreatedByFirstName"].ToString(); contentWorkflow.createdByUserLastName = reader["CreatedByLastName"].ToString(); contentWorkflow.authorEmail = reader["CreatedByUserEmail"].ToString(); contentWorkflow.authorAvatar = reader["CreatedByAvatar"].ToString(); contentWorkflow.authorBio = reader["CreatedByAuthorBio"].ToString(); contentWorkflow.authorUserId = Convert.ToInt32(reader["CreatedByUserID"]); contentWorkflow.lastModByUserLastName = reader["ModifiedByUserName"].ToString(); contentWorkflow.lastModByUserFirstName = reader["ModifiedByFirstName"].ToString(); contentWorkflow.lastModByUserLastName = reader["ModifiedByLastName"].ToString(); contentWorkflowList.Add(contentWorkflow); } } finally { reader.Close(); } return(contentWorkflowList); }