tags:

views:

189

answers:

3

I'd like SharePoint to behave as is, but prior to returning documents to users, I'd like the option to intercept the document and make user-specific additions/changes.

So basically: 1) Can you even tweak the code responsible for "opening" files in SharePoint? 2. If so, can you do it on a user specific basis (e.g. use the default code for everyone except a given class of users) 3) Assuming 1 and 2, can you intercept whatever file was about to be returned and make changes to it (perhaps even replacing it with a different file altogether)?

(I'd prefer not to do this at the IIS level)

Thanks, Rhett

A: 

What do you mean by "opening file"? Viewing a list item or opening the document itself?

Either way, you can edit list forms with SharePoint Designer. Or you can create your code-behind for that list and do whatever with OnLoad event or some javascript stuff with downloading attachment links.

Or, in your case if you want to watermark your document, you could create code-behind (practical example here), override OnLoad event (when opening form), access those documents and set your parameters.

And OnUnload you could then again modify document to revert back changes.

What if multiple users want to access the same document? Well, then, You could actually hide original document with javascript and display a copy which is prepared for that user and on OnUnload discard it.

However it will work only if you access documents from web, not outlook.

Janis Veinbergs
If you look at the UI, there's two ways to open a document. Either click on the link for the document (e.g. http://sharepoint/directory/document.doc) or click on the "Edit in..." menu item. Under the hood, what happens when you click on the link (like the one above) or the "Edit in..." menu item?
Rhett
Ahh, i deleted my wrong comment. Checked out function call tree what happens when you click on list item title. See screenshot: http://img268.imageshack.us/img268/7448/ss20090821091459.pngIf you press "Edit in..." it calls "STSNavigateWithCheckoutAlert" from core.js
Janis Veinbergs
+1  A: 

Hi there.

I think what you need to do here is create a HttpHandler for the documents (eg. Word files - doc/docx). Here's a link that might help. Also, this link gives details on how to create HttpHandlers. You probably need to add the following to the web.config file for your site:

I'm not too sure how to hook your handler to deal with your documents, since I don't know what the file extensions are, but you get the idea.

Cheers. Jas.

Jason Evans
This was my first thought, but I'd like to do it at the SharePoint level with application aware code--I don't want to hop out to IIS.
Rhett
A: 

Create a feature that adds a SPItemEventReceiver to the library and override ItemUploded . Or use this tool to add events to the lybrary.

Andrei
The document needs to be changed on open and different per user. So don't think this can work.
Alex Angas