本文讲述如何在SharePoint 2013 中显示用户Lync的状态(是否在线等)。
一共五种显示模式:
显示模式 | Lync的状态 | 用户名 | 用户照片 |
DefaultRender | Yes | Yes | No |
WithPicture | Yes | Yes | Yes |
WithPictureDetails | Yes | Yes | Yes |
PictureOnly | Yes | No | Yes |
PresenceOnly | Yes | No | No |
代码实现方式如下(注意替换邮件地址和userpictureUrl,按邮件地址确定用户):
1. DefaultRender 模式
<span>
<span class='ms-imnSpan'>
<a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink ms-spimn-presenceLink' >
<span class='ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10'>
<img name='imnmark' title='' ShowOfflinePawn='1' class='ms-spimn-img ms-spimn-presence-disconnected-10x10x32' src= '/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_1,ty pe=sip' />
</span>
</a>
</span>
<span>
<a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink' tabIndex='-1'>
<img name='imnmark' title='' ShowOfflinePawn='1' class=' ms-hide' src='/_layouts/15/images/spimn.png?rev=23' alt='Us er Presence' sip='test@hotmail.com' id='imn_2,type=sip' /></a>Raghavendra Shanbhag
</span>
</span>
2. WithPicture 模式
<div>
<div>
<span>
<a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink' tabIndex='-1'><img name='imnmark' title='' ShowOfflinePawn='1' class=' ms-hide' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' s ip='test@hotmail.com' id='imn_1,type=sip' /></a>
<span>
<img style="width:62px; height:62px; border:none" src="yourpictureUrl" alt=" Ram" />
</span>
</span></span>
</div>
<div class="ms-floatLeft ms-descriptiontext"><span class="ms-verticalAlignTop ms-noWrap ms-displayInlineBlock">
<span class='ms-imnSpan'><a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink ms-spimn-presenceLink' ><span class='ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10'><img name='imnmark' title='' ShowOfflinePawn='1' class='ms-spimn-img ms-spimn-presence-disconnected-10x10x32' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_2,type=sip' /></span></a></span><span class="ms-noWrap ms-imnSpan"><a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink' tabIndex='-1'><img name='imnmark' title='' ShowOfflinePawn='1' class=' ms-hide' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_3,type=sip' /></a>Ram</span>
</span>
</div>
</div>
3. WithPictureDetails 模式
<div>
<div class="ms-tableRow">
<div>
<span class='ms-imnSpan'>
<a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink ms-spimn-presenceLink' >
<span class='ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10'><img name='imnmark' title='' ShowOfflinePaw n='1' class='ms-spimn-img ms-spimn-presence-disconnected-10x10x32' src='/_layouts/15/images/spimn.png?rev=23' alt=' User Presence' sip='test@hotmail.com' id='imn_661,type=sip' /></span>
</a>
</span></span>
</div>
<div class="ms-tableCell ms-verticalAlignTop">
<div class="ms-peopleux-userImgDiv"><span class="ms-imnSpan"><a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink' tabIndex='-1'><img name='imnmark' title='' ShowOfflinePawn='1' class=' ms-hide' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_3452,type=sip' /></a><span><img style="width:62px; height:62px; border:none" src="userpictureUrl" alt=" Ram" /></span></span></span></div></div><div class="ms-tableCell ms-peopleux-userdetails ms-noList"><ul style="max-width:150px"><li><div class="ms-noWrap"><span><a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink' tabIndex='-1'><img name='imnmark' title='' ShowOfflinePawn='1' class=' ms-hide' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_34523,type=sip' /></a>Raghavendra Shanbhag</span></div></li></ul></div>
</div>
</div>
4. PictureOnly 模式
<div>
<div>
<div class="ms-tableCell">
<span class='ms-imnSpan'><a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink ms-spimn-prese nceLink' ><span class='ms-spimn-presenceWrapper ms-spimn-imgSize-8x72'><img name='imnmark' title='' ShowOfflinePawn= '1' class='ms-spimn-img ms-spimn-presence-disconnected-8x72x32' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_1,type=sip' /></span></a></span></span></div>
<div class="ms-tableCell ms-verticalAlignTop">
<div class="ms-peopleux-userImgDiv"><span class="ms-imnSpan"><a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink' tabIndex='-1'><img name='imnmark' title='' ShowOfflinePawn='1' class=' ms-hide' src='/_layouts/15/images/spimn.png?rev=23' alt='User Presence' sip='test@hotmail.com' id='imn_2,type=sip' /></a><span class="ms-peopleux-imgUserLink"><span class="ms-peopleux-userImgWrapper" style="width:72px; height:72px"><img style="min-width:72px; min-height:72px; clip:rect(0px, 72px, 72px, 0px); max-width:72px" src="userpictureurl" alt=" Ram" /></span></span></span></div>
</div>
</div>
</div>
5. PresenceOnly 模式:
<span class='ms-imnSpan'>
<a href='#' οnclick='IMNImageOnClick(event);return false;' class='ms-imnlink ms-spimn-presenceLink' >
<span class='ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10'><img name='imnmark' title='' ShowOfflinePa wn='1' class='ms-spimn-img ms-spimn-presence-disconnected-10x10x32' src='/_layouts/15/images/spimn.png?rev=23' alt ='User Presence' sip='test@hotmail.com' id='imn_1,type=sip' />
</span>
</a>
</span>
原文来自:
http://www.sharepointcolumn.com/lync-presence-indicators-code-snippets-in-sharepoint-2013/
http://www.sharepointcolumn.com/lync-presence-indicators-in-sharepoint-2013/