Ejemplo n.º 1
0
        public bool mt_setPostCategories(string postid, string username, string password, MoveableType.Category[] categories)
        {
            VerifyAccess(username, password);

            var entry = dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                var cats = "";
                foreach (var mcat in categories)
                {
                    if (cats.Length > 0)
                    {
                        cats += ";";
                    }
                    cats += mcat.categoryId;
                }
                entry.Categories = cats;
                dataService.SaveEntry(entry);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool mt_setPostCategories(string postid, string username, string password, MoveableType.Category[] categories)
        {
            if (!dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }

            if (!VerifyLogin(username, password))
            {
                throw new SecurityException();
            }

            Entry entry = dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                string cats = "";
                foreach (MoveableType.Category mcat in categories)
                {
                    if (cats.Length > 0)
                    {
                        cats += ";";
                    }
                    cats += mcat.categoryId;
                }
                entry.Categories = cats;
                dataService.SaveEntry(entry);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        bool IBlogger.blogger_editPost(string appKey, string postid, string username, string password, string content, bool publish)
        {
            if (!siteConfig.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = SiteSecurity.Login(username, password);

            if (token == null)
            {
                throw new System.Security.SecurityException();
            }
            Entry entry = dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                FillEntryFromBloggerPost(entry, content, username);
                entry.IsPublic   = publish;
                entry.Syndicated = publish;
                SiteUtilities.SaveEntry(entry, siteConfig, this.logService, this.dataService);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public bool mt_setPostCategories(string postid, string username, string password, MoveableType.Category[] categories)
        {
            if (!_dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = _siteSecurity.Login(username, password);

            if (token == null)
            {
                throw new SecurityException();
            }
            Entry entry = _dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                string cats = "";
                foreach (MoveableType.Category mcat in categories)
                {
                    if (cats.Length > 0)
                    {
                        cats += ";";
                    }
                    cats += mcat.categoryId;
                }
                entry.Categories = cats;
                _dataService.SaveEntry(entry);

                // TODO: give the XSS upstreamer a hint that things have changed
                //  XSSUpstreamer.TriggerUpstreaming();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public void BlogDataService_GetEntryForEditDelete_Successful(IBlogDataService blogdataservice)
        {
            var entry = TestEntry.CreateEntry(String.Format("Test Entry 2"), 5, 2);

            blogdataservice.SaveEntry(entry, null);

            var dt          = DateTime.Now;
            var returnEntry = blogdataservice.GetEntryForEdit(entry.EntryId);

            Assert.NotNull(returnEntry);

            blogdataservice.DeleteEntry(entry.EntryId, null);

            var entryFailRetrieval = blogdataservice.GetEntry(entry.EntryId);

            Assert.Null(entryFailRetrieval);
        }
Ejemplo n.º 6
0
        public static void FixIsPublic(string path)
        {
            ContentPath = path;

            BlogDataServiceFactory.RemoveService(path);
            IBlogDataService dataService = BlogDataServiceFactory.GetService(ContentPath, null);
            EntryCollection  entries     = dataService.GetEntriesForDay(
                DateTime.MaxValue.AddDays(-2),
                TimeZone.CurrentTimeZone,
                String.Empty,
                int.MaxValue,
                int.MaxValue,
                String.Empty);

            foreach (Entry e in entries)
            {
                //if (e.IsPublic == false)
                {
                    try
                    {
                        Entry edit = dataService.GetEntryForEdit(e.EntryId);
                        edit.IsPublic = true;

                        if (edit.Categories == String.Empty)
                        {
                            edit.Categories = "Main";
                        }
                        EntrySaveState saved = dataService.SaveEntry(edit);

                        if (saved == EntrySaveState.Failed)
                        {
                            WriteLine(String.Format("Failed saving {0}", e.Title));
                        }
                        else
                        {
                            WriteLine(String.Format("Saved {0}", e.Title));
                        }
                    }
                    catch (Exception e1)
                    {
                        WriteLine(String.Format("Failed saving {0}, {1}", e.Title, e1.ToString()));
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void BlogDataService_UpdateEntriesDelete_Successful(IBlogDataService blogdataservice)
        {
            var entry = TestEntry.CreateEntry(String.Format("Test Entry 3"), 5, 2);

            entry.Categories = "test";
            blogdataservice.SaveEntry(entry, null);

            var dt          = DateTime.Now;
            var returnEntry = blogdataservice.GetEntryForEdit(entry.EntryId);

            Assert.NotNull(returnEntry);

            returnEntry.Title = "Test Entry 4";
            var state = blogdataservice.SaveEntry(returnEntry, null);

            Assert.True(state == EntrySaveState.Updated);

            var entryAfterUpdate = blogdataservice.GetEntry(entry.EntryId);

            Assert.True(entryAfterUpdate.Title == "Test Entry 4");

            blogdataservice.DeleteEntry(entry.EntryId, null);
        }
Ejemplo n.º 8
0
 public Entry GetEntryForEdit(string postid)
 {
     return(_dataService.GetEntryForEdit(postid));
 }
        public void ProcessRequest(HttpContext context)
        {
            if (!SiteSecurity.IsValidContributor())
            {
                context.Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }

            SiteConfig siteConfig = SiteConfig.GetSiteConfig();

            string entryId     = "";
            string author      = "";
            string title       = "";
            string textToSave  = "";
            string redirectUrl = SiteUtilities.GetStartPageUrl();


            System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(context.Request.InputStream);
            try
            {
                while (!xtr.EOF)
                {
                    xtr.Read();
                    if (xtr.Name == "entryid")
                    {
                        entryId = xtr.ReadInnerXml();
                    }
                    if (xtr.Name == "author")
                    {
                        author = xtr.ReadInnerXml();
                    }
                    if (xtr.Name == "title" && xtr.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        // Ensure this is the start element before moving forward to the CDATA.
                        xtr.Read();                          // Brings us to the CDATA inside "title"
                        title = xtr.Value;
                    }
                    if (xtr.Name == "posttext" && xtr.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        xtr.Read();
                        textToSave = xtr.Value;
                    }
                }
            }
            finally
            {
                xtr.Close();
            }


            // make sure the entry param is there
            if (entryId == null || entryId.Length == 0)
            {
                context.Response.Redirect(SiteUtilities.GetStartPageUrl(siteConfig));
                return;
            }
            else
            {
                ILoggingDataService logService  = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
                IBlogDataService    dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService);

                // First, attempt to get the entry.  If the entry exists, then get it for editing
                // and save.  If not, create a brand new entry and save it instead.
                Entry entry = dataService.GetEntry(entryId);
                if (entry != null)
                {
                    entry = dataService.GetEntryForEdit(entryId);
                    Entry modifiedEntry = entry.Clone();
                    modifiedEntry.Content     = textToSave;
                    modifiedEntry.Title       = title;
                    modifiedEntry.Author      = author;
                    modifiedEntry.Syndicated  = false;
                    modifiedEntry.IsPublic    = false;
                    modifiedEntry.ModifiedUtc = DateTime.Now.ToUniversalTime();
                    modifiedEntry.Categories  = "";
                    dataService.SaveEntry(modifiedEntry, null);

                    //context.Request.Form["textbox1"];

                    logService.AddEvent(
                        new EventDataItem(
                            EventCodes.EntryChanged, entryId,
                            context.Request.RawUrl));
                }
                else
                {
                    // This is a brand new entry.  Create the entry and save it.
                    entry             = new Entry();
                    entry.EntryId     = entryId;
                    entry.CreatedUtc  = DateTime.Now.ToUniversalTime();
                    entry.ModifiedUtc = DateTime.Now.ToUniversalTime();
                    entry.Title       = title;
                    entry.Author      = author;
                    entry.Content     = textToSave;
                    entry.Syndicated  = false;
                    entry.IsPublic    = false;
                    dataService.SaveEntry(entry, null);

                    //context.Request.Form["textbox1"];

                    logService.AddEvent(
                        new EventDataItem(
                            EventCodes.EntryAdded, entryId,
                            context.Request.RawUrl));
                }
            }
        }