Как скрыть шаблоны сайтов по умолчанию от пользовательских групп в SharePoint 2010 с помощью C#

Мне необходимо hide все default site templates from a custom user group except Blog and custom site templates используя программирование в C#.

я имею Level - 2 SharePoint Coordinator group который должен позволять пользователям создавать сайты из моих пользовательских шаблонов сайтов и блога, все остальные шаблоны сайтов должны быть скрыты.

я имею Level - 3 SharePoint Coordinator group он имеет уровень разрешений "Полный доступ", поэтому пользователям этой группы должны быть доступны все шаблоны сайтов.

Мой код:

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWeb web = properties.Feature.Parent as SPWeb;
        SPWebTemplateCollection templates = web.GetAvailableWebTemplates(1033, true);
        foreach (SPWebTemplate template in templates)
        {
            if (template.Name != "Blog" && template.DisplayCategory =="CUSTOM")
            {
                //how to attach the user group to a site template or any other suggestions
            }
        }
    }

У меня такой вопрос: как прикрепить группу пользователей к шаблону сайта или как отобразить пользовательский шаблон сайта для уровня 2 и все шаблоны сайтов для группы уровня 3?

Часть Ответ.

Спасибо SigarDave. Мне удалось скрыть шаблоны сайтов по умолчанию, кроме блога и шаблонов пользовательских сайтов. Ниже приведен код.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        try
        {
            SPWeb web = properties.Feature.Parent as SPWeb;
            SPWebTemplateCollection templates = web.GetAvailableWebTemplates((uint)1033);
            Collection<SPWebTemplate> collection = new Collection<SPWebTemplate>();
            foreach (SPWebTemplate template in templates)
            {
                if(template.Name == "BLOG#0" || template.DisplayCategory == "Custom")
                collection.Add(template);
            }
            web.SetAvailableWebTemplates(collection, (uint)1033);
            web.Update();
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.ToString());
        }
    }

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        try
        {
            SPWeb web = properties.Feature.Parent as SPWeb;
            // Show all available web templates
            web.AllowAllWebTemplates();
            web.Update();
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.ToString());
        }
    }

Этот код скрывает шаблон для всех пользователей, включая Администратора семейства сайтов. Как включить или показать все шаблоны сайта для администратора SC? Благодарю.

0 ответов

Другие вопросы по тегам