Example #1
0
        public void DeletePage(string id)
        {
            var currentUser = Rock.CMS.UserService.GetCurrentUser();

            if (currentUser == null)
            {
                throw new WebFaultException <string>("Must be logged in", System.Net.HttpStatusCode.Forbidden);
            }

            using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope())
            {
                uow.objectContext.Configuration.ProxyCreationEnabled = false;
                Rock.CMS.PageService PageService = new Rock.CMS.PageService();
                Rock.CMS.Page        Page        = PageService.Get(int.Parse(id));
                if (Page.Authorized("Edit", currentUser))
                {
                    PageService.Delete(Page, currentUser.PersonId);
                    PageService.Save(Page, currentUser.PersonId);
                }
                else
                {
                    throw new WebFaultException <string>("Not Authorized to Edit this Page", System.Net.HttpStatusCode.Forbidden);
                }
            }
        }
Example #2
0
        public void ApiDeletePage(string id, string apiKey)
        {
            using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope())
            {
                Rock.CMS.UserService userService = new Rock.CMS.UserService();
                Rock.CMS.User        user        = userService.Queryable().Where(u => u.ApiKey == apiKey).FirstOrDefault();

                if (user != null)
                {
                    uow.objectContext.Configuration.ProxyCreationEnabled = false;
                    Rock.CMS.PageService PageService = new Rock.CMS.PageService();
                    Rock.CMS.Page        Page        = PageService.Get(int.Parse(id));
                    if (Page.Authorized("Edit", user))
                    {
                        PageService.Delete(Page, user.PersonId);
                        PageService.Save(Page, user.PersonId);
                    }
                    else
                    {
                        throw new WebFaultException <string>("Not Authorized to Edit this Page", System.Net.HttpStatusCode.Forbidden);
                    }
                }
                else
                {
                    throw new WebFaultException <string>("Invalid API Key", System.Net.HttpStatusCode.Forbidden);
                }
            }
        }
Example #3
0
        protected void rGrid_Delete(object sender, RowEventArgs e)
        {
            Rock.CMS.Page page = pageService.Get(( int )rGrid.DataKeys[e.RowIndex]["id"]);
            if (page != null)
            {
                Rock.Web.Cache.Page.Flush(page.Id);

                pageService.Delete(page, CurrentPersonId);
                pageService.Save(page, CurrentPersonId);

                if (_page != null)
                {
                    _page.FlushChildPages();
                }
            }

            BindGrid();
        }
Example #4
0
        public void ApiDeletePage( string id, string apiKey )
        {
            using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() )
            {
                Rock.CMS.UserService userService = new Rock.CMS.UserService();
                Rock.CMS.User user = userService.Queryable().Where( u => u.ApiKey == apiKey ).FirstOrDefault();

                if (user != null)
                {
                    uow.objectContext.Configuration.ProxyCreationEnabled = false;
                    Rock.CMS.PageService PageService = new Rock.CMS.PageService();
                    Rock.CMS.Page Page = PageService.Get( int.Parse( id ) );
                    if ( Page.Authorized( "Edit", user ) )
                    {
                        PageService.Delete( Page, user.PersonId );
                        PageService.Save( Page, user.PersonId );
                    }
                    else
                        throw new WebFaultException<string>( "Not Authorized to Edit this Page", System.Net.HttpStatusCode.Forbidden );
                }
                else
                    throw new WebFaultException<string>( "Invalid API Key", System.Net.HttpStatusCode.Forbidden );
            }
        }
Example #5
0
        public void DeletePage( string id )
        {
            var currentUser = Rock.CMS.UserService.GetCurrentUser();
            if ( currentUser == null )
                throw new WebFaultException<string>("Must be logged in", System.Net.HttpStatusCode.Forbidden );

            using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() )
            {
                uow.objectContext.Configuration.ProxyCreationEnabled = false;
                Rock.CMS.PageService PageService = new Rock.CMS.PageService();
                Rock.CMS.Page Page = PageService.Get( int.Parse( id ) );
                if ( Page.Authorized( "Edit", currentUser ) )
                {
                    PageService.Delete( Page, currentUser.PersonId );
                    PageService.Save( Page, currentUser.PersonId );
                }
                else
                    throw new WebFaultException<string>( "Not Authorized to Edit this Page", System.Net.HttpStatusCode.Forbidden );
            }
        }