locked
Restricting access to context menu items RRS feed

  • Question

  • Hi,
    I´m trying to restrict the access to the SP context menu items. The restriction should depend on which groups the user belongs to. For example, if a user belongs to the "JustViewProperties" group, he can just see the "View Properties" entry on the list context menu.
    I´m a newbie sharepoint developer and my question is:
    should I change something inside the SP javascript files (core.js) or should I create a new feature, as they suggest in this forum  ?

    Thanks in advance for any suggestions or links
    • Moved by Mike Walsh FIN Friday, May 1, 2009 6:22 AM code (From:SharePoint - General Question and Answers and Discussion)
    Monday, March 10, 2008 7:44 AM

Answers

All replies

  • Hi,

     

    Instead of modifying js file you can try the following.

    http://shailajakumar.blogspot.com/2008/01/create-custom-context-menu-in.html

     

    Monday, March 10, 2008 8:30 AM
  • You can create a ascx control and in the control's Page_Load event create a Javascrip code snippet conditionally.
    I hope you know how to add custom Context menu. All you you need to have a javascript function Custom_AddListMenuItems. The following function add two menu item to context menu.

        function Custom_AddListMenuItems(m, ctx)
        {
    //Add a menu View Properties
        var strText1 = "View Properties";
        var strAction1 = "_ViewProperties(itemID)";
        var strSelectionImage = '';
        CAMOpt(m, strText1, strAction1, strSelectionImage);

    //Add a menu Edit Properties
        var strText2 = "Edit Properties";
        var strAction2 = "_EditProperties(ItemId)";
        var strImagePath = "";
        CAMOpt(m, strText2, strAction2, strImagePath);


        // add a separator to the menu
        CAMSep(m);
        // false means that the standard menu items should also rendered
        return true;
        }

    If you want to add this menu item programatically then Create an ascx control and in the page load event add the function in page programatically:

    protected void Page_Load()
    {
    IF(User is Admin)
    {
    Add the code snippet above to the page
    //If you add the above menu then the edit menu will ne show as well as View
    }
    else
    {
    Remove the blue part of the above code snippet.
    //IF you remove the blue section then edit menu will not appear to the user.
    }
    }

    Finally add the control to the SharePoint page with visible set to false.

    Hope this will help you

    Thanks
    Sohel Rana
    Tuesday, March 11, 2008 1:25 PM
  •  

    "_ViewProperties(itemID)"; in the var strAction1  under function for Custom_AddListMenuItems(m, ctx)  is not redirecting the item to View Properties page.

     

    I tried your code but it's not working.

     

    Please advise.

     

    ~Maulee

    Monday, June 16, 2008 6:27 PM
  • Hi,

    Can anyone give me a javascript which I can use in a content editor webpart to Hide "Edit in Microsoft Office InfoPath" and "Edit Properties" menu items?

    Please dont refer me to some other blog.

    Thanks :)

    I already have one function like below:

    function CAMOpt(p,wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc)
    {
    var mo=CMOpt(wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc);
    if(!mo)
    return null;

    if(wzText != "Edit in Microsoft Office InfoPath" && wzText != "View Properties")
    if(wzText != "Edit Properties")
    AChld(p,mo);
    return true;

    }

    BUT this is working only when I am in ".....?PageView=Shared" view of the page.

    NOT in AllItems.aspx page.

     


    rajdeep
    Thursday, April 16, 2009 8:17 PM
  • There is also a third party prodict from BeWise

  • SPListDisplaySetting (Powered by Laurent Cotton Aka Suchii ...

    And using the C:\Program Files\Bewise\SPListDisplaySetting\Bewise.SharePoint.SPListDisplaySetting.wsp solution files I installed the solution on to the farm ...
    www.codeplex.com/SPListDisplaySetting/Thread/View.aspx?ThreadId=23927 - 154k - Cached - Similar pages
  • SPViewPermissionSetting (Powered by Laurent Cotton Aka Suchii ...

    Error=Object reference not set to an instance of an object at Bewise.SharePoint.SPViewPermissionSetting.ViewPermissionSelectorMenu.OnLoad(EventArgs e) ...
    www.codeplex.com/SPViewPermission/WorkItem/View.aspx?WorkItemId=105 - 80k -


    Cheers,

     

    Ivan Sanders

    http://dimension-si.com/blog

    http://linkedin.com/in/iasanders

    http://twitter.com/iasanders

    http://delicious.com/iasanders


  • Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
Monday, April 20, 2009 8:46 PM

  • There used to be a third party feature on codeplex by BeWise, its part of their toolbox, I have the feature but I am hesitant to Share due to licensing etc... Basically it removes the context menu from all menus a where a yser isnt in the correct role to have taccess to the menu. I think its still up on the French Site so alittle translation you should be able to find it. Bewise has two new parts on CodePlex...

    http://sharepoint.over-blog.fr/categorie-10037247.html

    http://www.codeplex.com/site/search?ProjectSearchText=bewise


    Cheers,

     

    Ivan Sanders

    http://dimension-si.com/blog

    http://linkedin.com/in/iasanders

    http://twitter.com/iasanders

    http://delicious.com/iasanders



    Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
    Monday, April 20, 2009 9:02 PM
  • Were you able to find the Feature I can deploy it to codeplex if I can receive permissions...




    Ivan Sanders

    SharePoint Architect

    Dimension Solutions, Inc.

    http://dimension-si.com/blog

    http://linkedin.com/in/iasanders

    http://twitter.com/iasanders

    http://delicious.com/iasanders


    Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
    Thursday, April 30, 2009 6:28 AM
  • Moving to Programming.

    Please post your "sharepoint developer" questions there and not to General !
    WSS FAQ sites: WSS 2.0: http://wssv2faq.mindsharp.com WSS 3.0 and MOSS 2007: http://wssv3faq.mindsharp.com
    Total list of WSS 3.0 and MOSS 2007 Books (including foreign language titles) http://wssv3faq.mindsharp.com/Lists/v3%20WSS%20FAQ/V%20Books.aspx
    Friday, May 1, 2009 6:22 AM
  • hi you can do this without editing in CORE.JS

    see  this with the help of this you can hide Edit Document Menu

    ctx.isWebEditorPreview = 1;


    like this way you can hide and show the context menu items
    Friday, May 1, 2009 8:51 AM