Example #1
0
        ///<summary>Creates historical entry of deletion into wikiPageHist, and deletes current non-draft page from WikiPage.
        ///For middle tier purposes we need to have the currently logged in user passed into this method.</summary>
        public static void Archive(string pageTitle, long userNumCur)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), pageTitle, userNumCur);
                return;
            }
            WikiPage wikiPage = GetByTitle(pageTitle);

            if (wikiPage == null)
            {
                return;                //The wiki page could not be found by the page title, nothing to do.
            }
            WikiPageHist wikiPageHist = PageToHist(wikiPage);

            //preserve the existing page with user credentials
            WikiPageHists.Insert(wikiPageHist);
            //make entry to show who deleted the page
            wikiPageHist.IsDeleted     = true;
            wikiPageHist.UserNum       = userNumCur;
            wikiPageHist.DateTimeSaved = MiscData.GetNowDateTime();
            WikiPageHists.Insert(wikiPageHist);
            //Now mark the wikipage as IsDeleted
            wikiPage.IsDeleted     = true;
            wikiPage.DateTimeSaved = MiscData.GetNowDateTime();
            Crud.WikiPageCrud.Update(wikiPage);
            //Remove all associated home pages for all users.
            UserOdPrefs.DeleteForValueString(0, UserOdFkeyType.WikiHomePage, pageTitle);
        }
Example #2
0
        ///<summary>Archives first by moving to WikiPageHist if it already exists.  Then, in either case, it inserts the new page.</summary>
        public static long InsertAndArchive(WikiPage wikiPage)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                wikiPage.WikiPageNum = Meth.GetLong(MethodBase.GetCurrentMethod(), wikiPage);
                return(wikiPage.WikiPageNum);
            }
            WikiPage wpExisting = GetByTitle(wikiPage.PageTitle);

            if (wpExisting != null)
            {
                WikiPageHist wpHist = PageToHist(wpExisting);
                WikiPageHists.Insert(wpHist);
                string command = "DELETE FROM wikipage WHERE PageTitle = '" + POut.String(wikiPage.PageTitle) + "'";
                Db.NonQ(command);
            }
            return(Crud.WikiPageCrud.Insert(wikiPage));
        }
Example #3
0
        ///<summary>Creates historical entry of deletion into wikiPageHist, and deletes current page from WikiPage.</summary>
        public static void Delete(string pageTitle)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), pageTitle);
                return;
            }
            WikiPage     wikiPage     = GetByTitle(pageTitle);
            WikiPageHist wikiPageHist = PageToHist(wikiPage);

            //preserve the existing page with user credentials
            WikiPageHists.Insert(wikiPageHist);
            //make entry to show who deleted the page
            wikiPageHist.IsDeleted = true;
            wikiPageHist.UserNum   = Security.CurUser.UserNum;
            WikiPageHists.Insert(wikiPageHist);
            string command = "DELETE FROM wikipage WHERE PageTitle = '" + POut.String(pageTitle) + "'";

            Db.NonQ(command);
        }
Example #4
0
        ///<summary>Archives first by moving to WikiPageHist if it already exists.  Then, in either case, it inserts the new page.
        ///Does not delete drafts.</summary>
        public static long InsertAndArchive(WikiPage wikiPage)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                wikiPage.WikiPageNum = Meth.GetLong(MethodBase.GetCurrentMethod(), wikiPage);
                return(wikiPage.WikiPageNum);
            }
            wikiPage.PageContentPlainText = MarkupEdit.ConvertToPlainText(wikiPage.PageContent);
            wikiPage.IsDraft = false;
            WikiPage wpExisting = GetByTitle(wikiPage.PageTitle);

            if (wpExisting != null)
            {
                WikiPageHist wpHist = PageToHist(wpExisting);
                WikiPageHists.Insert(wpHist);
                wikiPage.DateTimeSaved = MiscData.GetNowDateTime();
                //Old behavior was to delete the wiki page and then always insert.
                //It was changed to Update here for storing wiki page references by WikiPageNum instead of PageTitle
                //See JobNum 4429 for additional information.
                Crud.WikiPageCrud.Update(wikiPage);
                return(wikiPage.WikiPageNum);
            }
            //Deleted(archived) wp with the same page title should be updated with new page content. No need to create a new wp if the wikipage exist already.
            WikiPage wpDeleted = GetByTitle(wikiPage.PageTitle, isDeleted: true);

            if (wpDeleted != null)
            {
                //No need to add history since we already added the history when we archived it.
                wikiPage.WikiPageNum   = wpDeleted.WikiPageNum;
                wikiPage.DateTimeSaved = wpDeleted.DateTimeSaved;
                Crud.WikiPageCrud.Update(wikiPage);
                return(wikiPage.WikiPageNum);
            }
            //At this point the wp does not exist. Insert new a new wikipage.
            return(Crud.WikiPageCrud.Insert(wikiPage));
        }