コード例 #1
0
        public CmsTemplate GetTemplate(string id, int type)
        {
            BaseService.CheckLoginAndLicense();
            CmsTemplate template = CmsTemplate.New();

            //TODO: NewsletterTemplate service. 0 = PageTemplate & 1 = NewsletterTemplate
            if (type == 1)
            {
                //template.Content = template.Content.Replace("[HEAD]", "");
            }
            if (id != null)
            {
                template = BaseObject.GetById <CmsTemplate>(new Guid(id));
                if (template.HasAutorisation)
                {
                    //BitAutorisationService.AutorisationClient client = BitMetaServerServicesHelper.GetClient();
                    //BitplateUserGroup[] usergroups = client.GetUserGroupsByObjectPermission(template.ID);
                    //template.AutorizedBitplateUserGroups = usergroups;

                    //BitplateUser[] users = client.GetUsersByObjectPermission(template.ID);
                    //template.AutorizedBitplateUsers = users;
                    if (!template.IsAutorized(SessionObject.CurrentBitplateUser))
                    {
                        throw new Exception("U heeft geen rechten voor deze template");
                    }
                }
            }
            else
            {
                template.Site = SessionObject.CurrentSite;
            }
            return(template);
        }
コード例 #2
0
        public CmsTemplate GetTemplateIncludeHeader(string id)
        {
            BaseService.CheckLoginAndLicense();
            CmsTemplate template = CmsTemplate.New();

            if (id != null)
            {
                template = BaseObject.GetById <CmsTemplate>(new Guid(id));
                if (template.HasAutorisation)
                {
                    //BitAutorisationService.AutorisationClient client = BitAutorisationServiceHelper.GetClient();
                    //BitplateUserGroup[] usergroups = client.GetUserGroupsByObjectPermission(template.ID);
                    //template.AutorizedBitplateUserGroups = usergroups;

                    //BitplateUser[] users = client.GetUsersByObjectPermission(template.ID);
                    //template.AutorizedBitplateUsers = users;
                    if (!template.IsAutorized(SessionObject.CurrentBitplateUser))
                    {
                        throw new Exception("U heeft geen rechten voor deze template");
                    }
                }
            }
            else
            {
                template.Site = SessionObject.CurrentSite;
            }
            string tmpHead = "";

            foreach (CmsScript script in template.Scripts)
            {
                tmpHead += script.GetTag() + "\n\r";
            }
            template.Content = template.Content.Replace("[HEAD]", tmpHead).Replace("[SCRIPTS]", "");
            return(template);
        }
コード例 #3
0
        public void DeleteTemplate(string id)
        {
            BaseService.CheckLoginAndLicense();
            CmsTemplate template = GetTemplate(id);

            if (template.HasAutorisation)
            {
                if (!template.IsAutorized(SessionObject.CurrentBitplateUser))
                {
                    throw new Exception("U heeft geen rechten voor deze template");
                }
            }
            template.Delete();
        }