Beispiel #1
0
        public void DeleteSiteDomain(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.SiteDomainService SiteDomainService = new Rock.CMS.SiteDomainService();
                Rock.CMS.SiteDomain        SiteDomain        = SiteDomainService.Get(int.Parse(id));
                if (SiteDomain.Authorized("Edit", currentUser))
                {
                    SiteDomainService.Delete(SiteDomain, currentUser.PersonId);
                    SiteDomainService.Save(SiteDomain, currentUser.PersonId);
                }
                else
                {
                    throw new WebFaultException <string>("Not Authorized to Edit this SiteDomain", System.Net.HttpStatusCode.Forbidden);
                }
            }
        }
Beispiel #2
0
        public void ApiDeleteSiteDomain(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.SiteDomainService SiteDomainService = new Rock.CMS.SiteDomainService();
                    Rock.CMS.SiteDomain        SiteDomain        = SiteDomainService.Get(int.Parse(id));
                    if (SiteDomain.Authorized("Edit", user))
                    {
                        SiteDomainService.Delete(SiteDomain, user.PersonId);
                        SiteDomainService.Save(SiteDomain, user.PersonId);
                    }
                    else
                    {
                        throw new WebFaultException <string>("Not Authorized to Edit this SiteDomain", System.Net.HttpStatusCode.Forbidden);
                    }
                }
                else
                {
                    throw new WebFaultException <string>("Invalid API Key", System.Net.HttpStatusCode.Forbidden);
                }
            }
        }
Beispiel #3
0
        protected void btnSave_Click( object sender, EventArgs e )
        {
            Rock.CMS.Site site;
            Rock.CMS.SiteDomain sd;
            bool newSite = false;

            using ( new Rock.Data.UnitOfWorkScope() )
            {
                siteService = new Rock.CMS.SiteService();
                siteDomainService = new Rock.CMS.SiteDomainService();

                int siteId = 0;
                if ( !Int32.TryParse( hfSiteId.Value, out siteId ) )
                    siteId = 0;

                if ( siteId == 0 )
                {
                    newSite = true;
                    site = new Rock.CMS.Site();
                    siteService.Add( site, CurrentPersonId );
                }
                else
                {
                    site = siteService.Get( siteId );
                    foreach ( var domain in site.SiteDomains.ToList() )
                        siteDomainService.Delete( domain, CurrentPersonId );
                    site.SiteDomains.Clear();
                }

                site.Name = tbSiteName.Text;
                site.Description = tbDescription.Text;
                site.Theme = ddlTheme.Text;
                site.DefaultPageId = Convert.ToInt32( ddlDefaultPage.SelectedValue );

                foreach ( string domain in tbSiteDomains.Text.SplitDelimitedValues() )
                {
                    sd = new Rock.CMS.SiteDomain();
                    sd.Domain = domain;
                    sd.Guid = Guid.NewGuid();
                    site.SiteDomains.Add( sd );
                }

                site.FaviconUrl = tbFaviconUrl.Text;
                site.AppleTouchIconUrl = tbAppleTouchIconUrl.Text;
                site.FacebookAppId = tbFacebookAppId.Text;
                site.FacebookAppSecret = tbFacebookAppSecret.Text;

                siteService.Save( site, CurrentPersonId );

                if ( newSite )
                    Rock.Security.Authorization.CopyAuthorization( PageInstance.Site, site, CurrentPersonId );

                Rock.Web.Cache.Site.Flush( site.Id );

                BindGrid();

                pnlDetails.Visible = false;
                pnlList.Visible = true;
            }
        }
Beispiel #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Rock.CMS.Site       site;
            Rock.CMS.SiteDomain sd;
            bool newSite = false;

            using (new Rock.Data.UnitOfWorkScope())
            {
                siteService       = new Rock.CMS.SiteService();
                siteDomainService = new Rock.CMS.SiteDomainService();

                int siteId = 0;
                if (!Int32.TryParse(hfSiteId.Value, out siteId))
                {
                    siteId = 0;
                }

                if (siteId == 0)
                {
                    newSite = true;
                    site    = new Rock.CMS.Site();
                    siteService.Add(site, CurrentPersonId);
                }
                else
                {
                    site = siteService.Get(siteId);
                    foreach (var domain in site.SiteDomains.ToList())
                    {
                        siteDomainService.Delete(domain, CurrentPersonId);
                    }
                    site.SiteDomains.Clear();
                }

                site.Name          = tbSiteName.Text;
                site.Description   = tbDescription.Text;
                site.Theme         = ddlTheme.Text;
                site.DefaultPageId = Convert.ToInt32(ddlDefaultPage.SelectedValue);

                foreach (string domain in tbSiteDomains.Text.SplitDelimitedValues())
                {
                    sd        = new Rock.CMS.SiteDomain();
                    sd.Domain = domain;
                    sd.Guid   = Guid.NewGuid();
                    site.SiteDomains.Add(sd);
                }

                site.FaviconUrl        = tbFaviconUrl.Text;
                site.AppleTouchIconUrl = tbAppleTouchIconUrl.Text;
                site.FacebookAppId     = tbFacebookAppId.Text;
                site.FacebookAppSecret = tbFacebookAppSecret.Text;

                siteService.Save(site, CurrentPersonId);

                if (newSite)
                {
                    Rock.Security.Authorization.CopyAuthorization(PageInstance.Site, site, CurrentPersonId);
                }

                Rock.Web.Cache.Site.Flush(site.Id);

                BindGrid();

                pnlDetails.Visible = false;
                pnlList.Visible    = true;
            }
        }