1

Is there any way of catching when a theme is being changed -- so that I can fire a ThmxTheme.RemoveThemeFromWeb?

The option to change the theme is currently hidden in our farm, but we can't disallow themes in the web application or user policy or it causes certain other issues.

Are there any other advised options to prevent themes from being changed?

3

There are third party tools, like Axceler ControlPoint that give this type of functionality. Their methodology is to use event receivers to detect these types of changes and to block them. Being in an O365 environment, I'm not certain if you'd have the ability to create an event receiver or not (haven't used the cloud version ever).

2
  • We can write all the custom code we need, it just goes through the MSOCAF validation process, etc. However, I have been thinking about utilizing an Event Receiver. Oct 28 '12 at 19:24
  • Would you be so kind as to provide a sample on how to check for this particular event in a event receiver? (Not using Axceler) Oct 31 '12 at 18:57
0

To accommodate the issue, we did the following:

Since we weren't going to disable the privileges, we did the very best next thing - remove the problem.

We removed all the managed themes, via the following code in a site-scoped feature receiver, on feature activation.

if (properties != null)
{
    using (SPSite _SPSite = properties.Feature.Parent as SPSite)
    {
        using (SPWeb web = _SPSite.RootWeb)
        {
            ReadOnlyCollection<ThmxTheme> ManagedThemes = null;
            ManagedThemes = ThmxTheme.GetManagedThemes(web.Site);
            SPFile file = null;
            foreach (ThmxTheme themes in ManagedThemes)
            {                                    
                file = web.GetFile(themes.ServerRelativeUrl);
                file.Delete();                                   
            }
        }
    }
}

and then also disabled the following feature through feature stapling,

'Enhanced Theming' - GUID: 068bc832-4951-11dc-8314-0800200c9a66

Hopefully, this helps someone in the future. I've expanded on permissions/removal of themes at my blog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.