This could be accomplished on client side.
Below is provided full solution description.
Script for highlighting discussion list replies:
ExecuteOrDelayUntilScriptLoaded(highlightDiscussion, "sp.js");
function highlightDiscussion()
{
var discussionGroupId = 3;
var clientContext = new SP.ClientContext.get_current;
var groups = clientContext.get_web().get_siteGroups();
var group = groups.getById(discussionGroupId); //
this.groupUsers = group.get_users();
clientContext.load(groupUsers);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function resolveUserForReply(replyItem)
{
var userEntry = {};
var replyRow = replyItem.closest('tr');
var userUrl = replyRow.find('a').attr('href');
userEntry.ID = userUrl.match(/ID=([^&]+)/)[1];
return userEntry;
}
function highlightReply(replyItem)
{
replyItem.css({'background-color': '#00ffcc'});
}
function highlightReplyForUser(userId)
{
$('div[class^="ExternalClass"]').each(function(index) {
var user = resolveUserForReply($(this));
if(userId == user.ID)
highlightReply($(this));
});
}
function onQuerySucceeded() {
var ie = groupUsers.getEnumerator();
while (ie.moveNext()) {
var user = ie.get_current();
highlightReplyForUser(user.get_id());
}
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
How to make it work:
- Save this script as a file DiscussionsHighlight.js and place it to LAYOUTS folder
- Embed specified file and jquery files into discussion list, for example add it to Flat.aspx like shown below:
Results
On picture below is displayed discussion list with highlighted replies for users who belongs to specific group (see parameter discussionGroupId
in script )