Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > User selection in forum private messaging View modes: 
User avatar
Member
Member
damon.amanabadi-artisgroup.com - 7/5/2011 8:39:39 PM
   
User selection in forum private messaging
Currently we have the private messaging implemented on our website using the MyMessages.ascx. It has now become a requirement that when creating a message and selecting a user that the popup doesn’t display Full Name of the user, only the User name is to be displayed. This is also the same for when adding users to the contact list and the ignore list. Is this possible?

User avatar
Member
Member
kentico_michal - 7/10/2011 1:02:29 AM
   
RE:User selection in forum private messaging
Hello,

You will need to modify the following control ~\CMSModules\Messaging\Controls\SelectFromContactList.ascx in order to display the FullName in the user selector in Messaging.

As you can see the control uses a standard UniGrid control. For more information about the UniGrid control please visit Controls documentation: UniGrid overview.

To display the FullName in the UniGrid, please add a new column definition to the ~\CMSModules\Messaging\Controls\SelectFromContactList.xml:

<column source="ContactListContactUserID" externalsourcename="contactlistcontactuserid" caption="$general.FullName$" wrap="false" />


Then, please find the gridContactList_OnExternalDataBound method (~\CMSModules\Messaging\Controls\SelectFromContactList.ascx) and add a new case statement for the new column:


case "contactlistcontactuserid":
drv = GetDataRowView((DataControlFieldCell)(sender));
userId = ValidationHelper.GetInteger(drv["ContactListContactUserID"], 0);
if (userId != 0)
{
UserInfo ui = UserInfoProvider.GetUserInfo(userId);
if (ui != null)
{
userName = ValidationHelper.GetString(drv["UserName"], String.Empty);
userName = Functions.GetFormattedUserName(userName, this.IsLiveSite);

return GetItemText(userId, userName, ui);
}
}
return parameter;


The GetItemText method needs to be modified in the following way:


protected string GetItemText(int userId, object username, object usernickname)
{
string usrName = username.ToString();
string nick = HTMLHelper.HTMLEncode(UserInfoProvider.GetFullUserName(usrName, usernickname.ToString()));
if (usernickname is UserInfo)
{
nick = (usernickname as UserInfo).FullName;
}

return "<a href=\"javascript: window.parent.CloseAndRefresh(" + userId + ", " + ScriptHelper.GetString(HTMLHelper.HTMLEncode(usrName)) + ", " +
ScriptHelper.GetString(QueryHelper.GetText("mid", String.Empty)) +
", " + ScriptHelper.GetString(QueryHelper.GetText("hidid", String.Empty)) +
")\">" + nick + "</a>";
}


Best regards,
Michal Legen