Example #1
0
        private Guid FindUser(Guid userId)
        {
            MembershipUser usr = SecurityData.GetUserByGuid(userId);

            if (usr == null)
            {
                return(SecurityData.CurrentUserGuid);
            }
            else
            {
                return(userId);
            }
        }
        protected string GetUserName(Guid userId)
        {
            MembershipUser usr = SecurityData.GetUserByGuid(userId);

            if (usr != null)
            {
                return(usr.UserName);
            }
            else
            {
                return(" ");
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ActivateTab(AdminBaseMasterPage.SectionID.BlogContentAdd);

            RedirectIfNoSite();

            lblUpdated.Text    = SiteData.CurrentSite.Now.ToString();
            lblCreateDate.Text = SiteData.CurrentSite.Now.ToString();

            guidContentID        = GetGuidIDFromQuery();
            guidVersionContentID = GetGuidParameterFromQuery("versionid");
            guidImportContentID  = GetGuidParameterFromQuery("importid");

            sPageMode = GetStringParameterFromQuery("mode");
            if (sPageMode.ToLower() == "raw")
            {
                reBody.CssClass      = "rawEditor";
                reLeftBody.CssClass  = "rawEditor";
                reRightBody.CssClass = "rawEditor";
                divCenter.Visible    = false;
                divRight.Visible     = false;
                divLeft.Visible      = false;
            }

            if (!IsPostBack)
            {
                DateTime dtSite = CalcNearestFiveMinTime(SiteData.CurrentSite.Now);
                txtReleaseDate.Text = dtSite.ToShortDateString();
                txtReleaseTime.Text = dtSite.ToShortTimeString();
                txtRetireDate.Text  = dtSite.AddYears(200).ToShortDateString();
                txtRetireTime.Text  = dtSite.AddYears(200).ToShortTimeString();

                hdnRootID.Value = Guid.Empty.ToString();

                GeneralUtilities.BindList(listCats, SiteData.CurrentSite.GetCategoryList().OrderBy(x => x.CategoryText));
                GeneralUtilities.BindList(listTags, SiteData.CurrentSite.GetTagList().OrderBy(x => x.TagText));

                ContentPage pageContents = null;
                if (guidVersionContentID != Guid.Empty)
                {
                    pageContents = pageHelper.GetVersion(SiteID, guidVersionContentID);
                }
                if (guidContentID != Guid.Empty && pageContents == null)
                {
                    pageContents = pageHelper.FindContentByID(SiteID, guidContentID);
                }

                if (guidImportContentID != Guid.Empty)
                {
                    ContentPageExport cpe = ContentImportExportUtils.GetSerializedContentPageExport(guidImportContentID);

                    if (cpe != null)
                    {
                        pageContents                  = cpe.ThePage;
                        pageContents.EditDate         = SiteData.CurrentSite.Now;
                        pageContents.Parent_ContentID = null;
                    }

                    var rp = pageHelper.GetLatestContentByURL(SiteID, false, pageContents.FileName);
                    if (rp != null)
                    {
                        pageContents.Root_ContentID = rp.Root_ContentID;
                        pageContents.ContentID      = rp.ContentID;
                    }
                    else
                    {
                        pageContents.Root_ContentID = Guid.Empty;
                        pageContents.ContentID      = Guid.Empty;
                    }
                    pageContents.Parent_ContentID = null;
                    pageContents.NavOrder         = SiteData.BlogSortOrderNumber;
                }

                //if (pageContents == null) {
                //    pageContents = new ContentPage(SiteData.CurrentSiteID, ContentPageType.PageType.BlogEntry);
                //}

                List <ContentPage> lstContent = pageHelper.GetAllLatestContentList(SiteID);

                GeneralUtilities.BindList(ddlTemplate, cmsHelper.Templates);

                chkDraft.Visible   = false;
                divEditing.Visible = false;

                Dictionary <string, float> dictTemplates = pageHelper.GetPopularTemplateList(SiteID, ContentPageType.PageType.BlogEntry);
                if (dictTemplates.Any())
                {
                    try {
                        GeneralUtilities.SelectListValue(ddlTemplate, dictTemplates.First().Key);
                    } catch { }
                }

                if (pageContents == null)
                {
                    btnDeleteButton.Visible = false;
                }

                if (pageContents != null)
                {
                    bool bRet = pageHelper.RecordPageLock(pageContents.Root_ContentID, SiteData.CurrentSite.SiteID, SecurityData.CurrentUserGuid);

                    if (pageContents.ContentType != ContentPageType.PageType.BlogEntry)
                    {
                        Response.Redirect(SiteFilename.PageAddEditURL + "?id=" + Request.QueryString.ToString());
                    }

                    cmsHelper.OverrideKey(pageContents.Root_ContentID);
                    cmsHelper.cmsAdminContent = pageContents;
                    cmsHelper.cmsAdminWidget  = pageContents.GetWidgetList();

                    BindTextDataGrid();

                    guidRootContentID = pageContents.Root_ContentID;
                    hdnRootID.Value   = guidRootContentID.ToString();

                    txtOldFile.Text = pageContents.FileName;

                    if (guidImportContentID != Guid.Empty)
                    {
                        txtOldFile.Text = "";
                    }

                    Dictionary <string, string> dataVersions = (from v in pageHelper.GetVersionHistory(SiteID, pageContents.Root_ContentID)
                                                                join u in ExtendedUserData.GetUserList() on v.EditUserId equals u.UserId
                                                                orderby v.EditDate descending
                                                                select new KeyValuePair <string, string>(v.ContentID.ToString(), string.Format("{0} ({1}) {2}", v.EditDate, u.UserName, (v.IsLatestVersion ? " [**] " : " ")))
                                                                ).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

                    GeneralUtilities.BindListDefaultText(ddlVersions, dataVersions, null, "Page Versions", "00000");

                    bLocked = pageHelper.IsPageLocked(pageContents);

                    pnlHB.Visible      = !bLocked;
                    pnlButtons.Visible = !bLocked;
                    divEditing.Visible = bLocked;
                    chkDraft.Visible   = !bLocked;
                    pnlHBEmpty.Visible = bLocked;

                    if (bLocked && pageContents.Heartbeat_UserId != null)
                    {
                        MembershipUser usr = SecurityData.GetUserByGuid(pageContents.Heartbeat_UserId.Value);
                        litUser.Text = "Read only mode. User '" + usr.UserName + "' is currently editing the page.";
                    }

                    txtTitle.Text    = pageContents.TitleBar;
                    txtNav.Text      = pageContents.NavMenuText;
                    txtHead.Text     = pageContents.PageHead;
                    txtPageSlug.Text = pageContents.PageSlug;
                    txtThumb.Text    = pageContents.Thumbnail;

                    txtDescription.Text = pageContents.MetaDescription;
                    txtKey.Text         = pageContents.MetaKeyword;

                    lblUpdated.Text    = pageContents.EditDate.ToString();
                    lblCreateDate.Text = pageContents.CreateDate.ToString();

                    reBody.Text      = pageContents.PageText;
                    reLeftBody.Text  = pageContents.LeftPageText;
                    reRightBody.Text = pageContents.RightPageText;

                    chkActive.Checked = pageContents.PageActive;
                    chkHide.Checked   = pageContents.BlockIndex;

                    GeneralUtilities.BindDataBoundControl(gvTracks, pageContents.GetTrackbacks());

                    txtReleaseDate.Text = pageContents.GoLiveDate.ToShortDateString();
                    txtReleaseTime.Text = pageContents.GoLiveDate.ToShortTimeString();
                    txtRetireDate.Text  = pageContents.RetireDate.ToShortDateString();
                    txtRetireTime.Text  = pageContents.RetireDate.ToShortTimeString();

                    if (pageContents.CreditUserId.HasValue)
                    {
                        var usr = new ExtendedUserData(pageContents.CreditUserId.Value);
                        hdnCreditUserID.Value = usr.UserName;
                        txtSearchUser.Text    = string.Format("{0} ({1})", usr.UserName, usr.EmailAddress);
                    }

                    pageContents.Parent_ContentID = null;

                    GeneralUtilities.SelectListValue(ddlTemplate, pageContents.TemplateFile.ToLower());

                    GeneralUtilities.SelectListValues(listTags, pageContents.ContentTags.Cast <IContentMetaInfo>().Select(x => x.ContentMetaInfoID.ToString()).ToList());
                    GeneralUtilities.SelectListValues(listCats, pageContents.ContentCategories.Cast <IContentMetaInfo>().Select(x => x.ContentMetaInfoID.ToString()).ToList());
                }
            }

            SetBlankText(reBody);
            SetBlankText(reLeftBody);
            SetBlankText(reRightBody);

            if (ddlVersions.Items.Count < 1)
            {
                pnlReview.Visible = false;
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ActivateTab(AdminBaseMasterPage.SectionID.ContentSnippet);

            guidRootItemID    = GetGuidIDFromQuery();
            guidVersionItemID = GetGuidParameterFromQuery("versionid");

            guidItemID = guidRootItemID;

            if (guidItemID == Guid.Empty)
            {
                guidItemID = guidVersionItemID;
            }

            if (!IsPostBack)
            {
                DateTime dtSite = CMSConfigHelper.CalcNearestFiveMinTime(SiteData.CurrentSite.Now);
                ucReleaseDate.SetDate(dtSite);
                ucRetireDate.SetDate(dtSite.AddYears(200));

                ContentSnippet item = null;

                if (guidRootItemID != Guid.Empty)
                {
                    item = ContentSnippet.Get(guidRootItemID);
                }
                else
                {
                    item = ContentSnippet.GetVersion(guidVersionItemID);
                }

                if (item != null)
                {
                    bool bRet = item.RecordSnippetLock(SecurityData.CurrentUserGuid);
                    bLocked = item.IsSnippetLocked();

                    if (bLocked && item.Heartbeat_UserId != null)
                    {
                        MembershipUser usr = SecurityData.GetUserByGuid(item.Heartbeat_UserId.Value);
                        litUser.Text = "Read only mode. User '" + usr.UserName + "' is currently editing the snippet.";
                    }

                    txtSlug.Text   = item.ContentSnippetSlug;
                    txtLabel.Text  = item.ContentSnippetName;
                    reBody.Text    = item.ContentBody;
                    guidRootItemID = item.Root_ContentSnippetID;

                    ucReleaseDate.SetDate(item.GoLiveDate);
                    ucRetireDate.SetDate(item.RetireDate);

                    chkPublic.Checked       = item.ContentSnippetActive;
                    btnDeleteButton.Visible = true;
                    pnlReview.Visible       = true;

                    Dictionary <string, string> dataVersions = (from v in ContentSnippet.GetHistory(guidRootItemID)
                                                                join u in ExtendedUserData.GetUserList() on v.EditUserId equals u.UserId
                                                                orderby v.EditDate descending
                                                                select new KeyValuePair <string, string>(v.ContentSnippetID.ToString(), string.Format("{0} ({1}) {2}", v.EditDate, u.UserName, (v.IsLatestVersion ? " [**] " : " ")))
                                                                ).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

                    GeneralUtilities.BindListDefaultText(ddlVersions, dataVersions, null, "Versions", "00000");
                }
                else
                {
                    btnDeleteButton.Visible = false;
                    pnlReview.Visible       = false;
                }
            }

            sPageMode = GetStringParameterFromQuery("mode");
            if (sPageMode.ToLowerInvariant() == "raw")
            {
                reBody.CssClass   = "rawEditor";
                divCenter.Visible = false;
            }

            pnlHB.Visible      = !bLocked;
            pnlHBEmpty.Visible = bLocked;
            pnlButtons.Visible = !bLocked;
            divEditing.Visible = bLocked;
        }
Example #5
0
        //protected void Page_Load(object sender, EventArgs e) {
        protected void Page_Init(object sender, EventArgs e)
        {
            guidContentID = GetGuidIDFromQuery();

            EditorPrefs = UserEditState.cmsUserEditState;
            if (EditorPrefs == null)
            {
                EditorPrefs = new UserEditState();
                EditorPrefs.Init();
            }

            string sCurrentPage = SiteData.CurrentScriptName;
            string sScrubbedURL = SiteData.AlternateCurrentScriptName;

            if (sScrubbedURL.ToLowerInvariant() != sCurrentPage.ToLowerInvariant())
            {
                sCurrentPage = sScrubbedURL;
            }

            ContentPage pageContents = new ContentPage();

            if (guidContentID == Guid.Empty)
            {
                pageContents = pageHelper.FindByFilename(SiteData.CurrentSiteID, sCurrentPage);
            }
            else
            {
                pageContents = pageHelper.FindContentByID(SiteData.CurrentSiteID, guidContentID);
            }

            PageType           = pageContents.ContentType;
            EditedPageFileName = pageContents.FileName;

            btnEditCoreInfo.Attributes["onclick"] = "cmsShowEditPageInfo();";

            if (pageContents.ContentType == ContentPageType.PageType.BlogEntry)
            {
                btnEditCoreInfo.Attributes["onclick"] = "cmsShowEditPostInfo();";
                btnSortChildPages.Visible             = false;
            }

            if (cmsHelper.cmsAdminContent != null)
            {
                EditedPageFileName = cmsHelper.cmsAdminContent.FileName;
            }

            if (cmsHelper.ToolboxPlugins.Any())
            {
                GeneralUtilities.BindRepeater(rpTools, cmsHelper.ToolboxPlugins);
            }
            else
            {
                rpTools.Visible = false;
            }

            bLocked = pageHelper.IsPageLocked(pageContents.Root_ContentID, SiteData.CurrentSiteID, SecurityData.CurrentUserGuid);

            GeneralUtilities.BindList(ddlTemplate, cmsHelper.Templates);
            try { GeneralUtilities.SelectListValue(ddlTemplate, cmsHelper.cmsAdminContent.TemplateFile.ToLowerInvariant()); } catch { }

            if (!bLocked)
            {
                foreach (Control c in plcIncludes.Controls)
                {
                    this.Page.Header.Controls.Add(c);
                }

                //jquerybasic jquerybasic2 = new jquerybasic();
                //jquerybasic2.SelectedSkin = jquerybasic.jQueryTheme.NotUsed;
                //Page.Header.Controls.AddAt(0, jquerybasic2);

                //BasicControlUtils.InsertjQuery(this.Page);

                BasicControlUtils.InsertjQueryMain(this.Page);
                BasicControlUtils.InsertjQueryUI(this.Page);

                guidContentID = pageContents.Root_ContentID;

                if (cmsHelper.cmsAdminContent == null)
                {
                    pageContents.LoadAttributes();
                    cmsHelper.cmsAdminContent = pageContents;
                }
                else
                {
                    pageContents = cmsHelper.cmsAdminContent;
                }

                bool bRet = pageHelper.RecordPageLock(pageContents.Root_ContentID, SiteData.CurrentSite.SiteID, SecurityData.CurrentUserGuid);

                cmsDivEditing.Visible = false;

                BasicControlUtils.MakeXUACompatibleFirst(this.Page);
            }
            else
            {
                pnlCMSEditZone.Visible  = false;
                rpTools.Visible         = false;
                btnToolboxSave1.Visible = false;
                btnToolboxSave2.Visible = false;
                btnToolboxSave3.Visible = false;
                btnTemplate.Visible     = false;
                btnEditCoreInfo.Visible = false;
                cmsDivEditing.Visible   = true;

                if (bLocked && pageContents.Heartbeat_UserId != null)
                {
                    MembershipUser usr = SecurityData.GetUserByGuid(pageContents.Heartbeat_UserId.Value);
                    EditUserName = usr.UserName;
                    litUser.Text = "Read only mode. User '" + usr.UserName + "' is currently editing the page.<br />" +
                                   " Click <b><a href=\"" + pageContents.FileName + "\">here</a></b> to return to the browse view.<br />";
                }
            }
        }