7/11/2009

SharePoint: Hiding Create options from MySite users

 

SharePoint does not give you and easy way to customize the Site Actions, Create page for selected users or sites. For example, you may not want MySite users to create Wikis or Discussion Boards, but everything else is ok.

The following “hack” is:
  - quick
  - easy
  - requires access to the web servers
  - not a form of security
  - and is not best practice!

        but is a cool hack.

 

Steps:

  • Go to your web server and to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS
  • Open create.aspx in your favoriate text / page editor. (I used Notepad)   BACKUP THIS FILE BEFORE EDITING!
  • Scroll to the end and past the following JavaScript just before the "</asp:Content>" tag.

<script type="text/javascript" language="javascript">
if (document.location.href.match('/personal/')!=null)    //do this just for the mysites
{  

  var x = document.getElementsByTagName("TABLE") // find all of the TABLEs on the page  
  var i=0;
  for (i=0;i<x.length;i++)
  {

    if (x[i].className=="ms-itemstatic") //find the TDs styled for lists
    {

      if (x[i].innerHTML.match('Wiki|Survey|Sites and Workspaces')!=null)  // find the items to hide.
      {
        x[i].style.display='none'
      }
    }
  }
}
</script>

 

How it works:

  • it does its work only for mysites (and only if you have not changed the mysite URL from /personal/)
  • it finds all tables (each choice on the page is in a little table)
  • it finds any table that has the keywords you are looking for in the innerHTML.match line
    Note: this example hides any item with the words/phrases: "Wiki", "Survey" and "Sites and Workspaces"
    pick your phrases carefully and TEST!
  • it hides those that match.

Why not best practice?

  • you are modifying a Microsoft page that may be overwritten in the next service pack
  • if you don't document it in your disaster / rebuild plan, it will be forgotten.

Why not a form of security?

  • the user could go to another site and create the same item and note the URL used. Modify the URL and it works in any site.

.

No comments:

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.