The Approve/Reject menu item:
The way to remove this item from the ECB was to override the method in Core.js by creating a custom javascript file containing the method that needs to be customised (don't customise the core.js as this is not supported by Microsoft, Core.js could be changed/overwritten by subsequent service packs for example).
In 12\TEMPLATE\LAYOUTS\1033\ A new javascript file (Custom_Core.js) was created alongside Core.js to contain the methods that will override those in the Sharepoint Core.js . All the methods were removed apart from the one that required the custom code, AddDocLibMenuItems the only remaining method (best way to do this is copy Core.js and remove all methods that aren't going to be changed).
The Document Library Template was specified in a feature, and had been given the List Type 101001. The AddDocLibMenuItems was tweaked to not show the Approve/Reject item with a simple if-condition checking that the list was based on this 101001 type.

To add the javascript to all views based on the default view, in the schema file of the Document Library Template (for Library type 101001).
Locate view with BaseViewID="1"
In this view locate the ViewFooter
Before the closing ViewFooter tag add the reference to the over-riding javascript file:
<HTML><![CDATA[<script type="text/javascript" language="javascript" src="/_layouts/1033/custom_core.js" defer></script>]]></HTML>
Perform an IISReset

NOTE:
This solution works because the Document Library was defined as a Custom Document Library feature, so to attach the custom_core.js to an out of the box Document Library based on the standard Document Library, do not change the schema code, another, supported method should be used, such as customising the Default.master in SharePoint Designer.

2 comments:
It is great.
Besides, I want to apply this to generic lists. Is it possible?
The javascript would work, you'd have to take out the condition referring to the custom list type (101001). And you'd have to place the reference to the .js file in a more general place either using SharePoint Designer or customised Master Page for example, I have only put it in the view in the schema because I wanted to lock it down to one list type only.
Post a Comment