Presence in the SharePoint UI is rendered very simply, as an image tag (WSS V2) or anchor tag (WSS V3) tag that calls into JavaScript functions that actually render the presence info SmartTag (ActiveX object) on the page. In each case, the user’s email address is placed as a parameter to a JavaScript call that actually adds the presence info SmartTag to the page’s DOM. The SmartTag invokes the Windows Messenger / MSN Messenger client applications to actually determine the presence of the email address passed as the parameter to the SmartTag through the JavaScript call.
WSS V2:
Here is the code that gives you presence awareness:
<img border=”0″ height=”12″ width=”12″ src=”http://portal.blackbladesystems.com/_layouts/images/blank.gif” onload=”IMNRC(‘erosenfeld@blackbladesystems.com‘)” id=”imn0″ >
Easiest way to override WSS presence info is to override the IMNRC JavaScript function with your own.
WSS V3:
Here is the code that gives you presence awareness:
<a href=”javascript:” onclick=”IMNImageOnClick();return false;” class=”ms-imnlink”><img title=”” alt=”No presence information” name=”imnmark” border=”0″ valign=”middle” height=”12″ width=”12″ src=”/_layouts/images/blank.gif” sip=”administrator@trainsbydave.com” id=”imn0,type=smtp” ></a>
All presence information elements in WSS V3 are tagged with the “imnmark” name.
In WSS V2, the IMNRC method was called directly from the img tags that showed the presence information.
Here’s how things work in WSS V3:
-
_spBodyOnLoadWrapper
- Called from the page’s BODY onload event
- <BODY scroll=”yes” onload=”javascript:if (typeof(_spBodyOnLoadWrapper) != ‘undefined’) _spBodyOnLoadWrapper();”>
-
ProcessDefaultOnLoad(onLoadFunctionNames)
- onLoadFunctionNames: array of function to call in the page onload event
- ProcessImn()
-
ProcessImnMarkers()
-
For each “imnmark” element: IMNRC(name, elem):
- name: SIP address
- elem: the element on the page whose image will be updated
-
Thanks for documenting this–I was having a tough time unraveling how it works. I’d like to somehow add new actions to that context menu universally whereever the presence indicator is shown. I think I can probably override some javascript somewhere (maybe using the CEWP), but that will be harder on a mysite. Can you think of any relatively clean/safe ways to achieve this? I notice there is an “Additional Actions” menu pick but I can’t find any documentation on how to add stuff there. Any help appreciated. Thanks, Clark
Clark, Glad you found the post useful. One of the easiest ways to inject custom JavaScript / HTML / ASP.Net controls into SharePoint pages is by creating a delegate control feature. You can read up on delegate controls here:
http://www.google.com/search?q=sharepoint+delegate+control+feature&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1
Clark, also check out SharePoint custom action features. Custom actions allow you to easily add or hide menu items on SharePoint pages. Read more here:
http://www.google.com/search?q=sharepoint+custom+actions&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1
Thanks, I will take a look at those. However, I found out the way to add to the “Additional Actions” is through Smart Tags. Turns out the whole presence menu runs on the client via ActiveX. Unfortunately, I believe that requires a client-side deployment.
I think you’re right. I misunderstood your comment. My suggestions were for adding menu items to a SharePoint item’s Edit Control Block in the list view or adding global content to SharePoint pages that contains presence information.
Great information. Our users are wanting to know how we can still show the indicator if the user is off line. With WSS V2, you could say ShowOfflinePawn=1, but I don’t see that control over that here. We could do it the old way, but we were hoping not to have to update the View for the list in AllItems.aspx for Colleagues.
This is pretty awesome.
Have you ever tried to add presence information in a list item in WSS 3.0? I tried to add it to a multiple lines of text with the “Edit HTML Source” button, but once I saved it and returned it did not work. When I reopened the item, the link that goes around the image was changed to just “A class=ms-imnlink” (so it took out the href=… section). Do you know of any way around this?
Drew, you’re right. SharePoint does tend to filter out JavaScript. The only way I can think of off the top of my head is to create a custom field type or a custom CAML list view.
Hi Eugene, In one of our web part, we want to display the list of users along with their presence indicator
And we are calling the "ProcessImn" function every mouseover of HREF tag, but it is working for the first User but for others it's not working.
Any help on this
Roopesh, Do you have duplicate IDs on the img tags? That may lead to the behavior you describe.
Eugene, The issue was some thing else, earlier we have the IMG tags in a table, each tag in a row. Now removed the Table and rendered in DIV tags then it is started working. Not sure what is the issue with TABLE.
Thanks for the help
Found a strange thing with presence: I added two contact details webparts to a page. Both of them are presenting a link to a person with the grey presence bubble.
But: only the presence bubble of the first person is reactin when hovering with the mouse on it. The presence bubble of the person showed by the second webpart does not react.
When deleting the first webpart the presence bubble of the former second person now reacts on mouse hovering.
Looks like there is a bug in the contact details webpart 🙂
Do you know this kind of problem?
Regards,
Oliver
Oliver, I haven't seen this behavior, but I have not looked for it specifically either. It sounds like the contact details web part is suffering from the same issue as Roopesh's custom web part.
@Eugene: I'm not quite sure. The problem description looks similar, that's right, but because the contact details webpart comes out of the box with sharepoint I'm not able to solve this. I was hoping you or one of your readers already ran into the same problem and found a kind of workaround.
Regards,
Oliver
Hi Eugene,
Thanks for an excellent post. What would be the easiest way to make all the buttons show in a view (like with the Content Editor Web Part)?
Thanks,
Sara Tenenbaum
Sara, if you control the rendering of the buttons, then explicitly writing out the HTML / script is the easiest way. If you need to modify page elements that something else is writing, the easiest way is probably to use some jQuery to alter the elements to incorporate the presence info script. There will be performance impact for the client browser using the approach though.
SharePoint MVP Jan Tielens has a number of excellent posts on using jQuery with SharePoint.