2019-06-07 08:59:07 +00:00
|
|
|
namespace ASC.Core.Users
|
|
|
|
{
|
|
|
|
public static class UserInfoExtension
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
public static string DisplayUserName(this UserInfo userInfo, DisplayUserSettingsHelper displayUserSettingsHelper)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
return DisplayUserName(userInfo, true, displayUserSettingsHelper);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-11-08 12:21:51 +00:00
|
|
|
public static string DisplayUserName(this UserInfo userInfo, bool withHtmlEncode, DisplayUserSettingsHelper displayUserSettingsHelper)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
return displayUserSettingsHelper.GetFullUserName(userInfo, withHtmlEncode);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static List<UserInfo> SortByUserName(this IEnumerable<UserInfo> userInfoCollection)
|
|
|
|
{
|
|
|
|
if (userInfoCollection == null) return new List<UserInfo>();
|
|
|
|
|
|
|
|
var users = new List<UserInfo>(userInfoCollection);
|
|
|
|
users.Sort(UserInfoComparer.Default);
|
|
|
|
return users;
|
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static bool HasAvatar(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.UserHasAvatar(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static Size GetPhotoSize(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetPhotoSize(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static string GetPhotoURL(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetPhotoAbsoluteWebPath(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static string GetRetinaPhotoURL(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetRetinaPhotoURL(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static string GetMaxPhotoURL(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetMaxPhotoURL(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static string GetBigPhotoURL(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetBigPhotoURL(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static string GetMediumPhotoURL(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetMediumPhotoURL(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public static string GetSmallPhotoURL(this UserInfo userInfo, UserPhotoManager UserPhotoManager)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-02-15 10:30:05 +00:00
|
|
|
return UserPhotoManager.GetSmallPhotoURL(userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 13:59:49 +00:00
|
|
|
public static string RenderProfileLinkBase(this UserInfo userInfo, CommonLinkUtility commonLinkUtility, DisplayUserSettingsHelper displayUserSettingsHelper)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
//check for removed users
|
2022-02-15 10:30:05 +00:00
|
|
|
if (userInfo.Id == Constants.LostUser.Id)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2022-01-14 13:12:37 +00:00
|
|
|
sb.Append($"<span class='userLink text-medium-describe' style='white-space:nowrap;'>{userInfo.DisplayUserName(displayUserSettingsHelper)}</span>");
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var popupID = Guid.NewGuid();
|
2022-02-15 10:30:05 +00:00
|
|
|
sb.Append($"<span class=\"userLink\" style='white-space:nowrap;' id='{popupID}' data-uid='{userInfo.Id}'>");
|
2022-01-14 13:12:37 +00:00
|
|
|
sb.Append($"<a class='linkDescribe' href=\"{userInfo.GetUserProfilePageURLGeneral(commonLinkUtility)}\">{userInfo.DisplayUserName(displayUserSettingsHelper)}</a>");
|
2019-06-07 08:59:07 +00:00
|
|
|
sb.Append("</span>");
|
|
|
|
|
2022-02-15 10:30:05 +00:00
|
|
|
sb.AppendFormat("<script language='javascript'> StudioUserProfileInfo.RegistryElement('{0}','\"{1}\"); </script>", popupID, userInfo.Id);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// return absolute profile link
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="userInfo"></param>
|
|
|
|
/// <returns></returns>
|
2019-09-19 15:55:44 +00:00
|
|
|
private static string GetUserProfilePageURLGeneral(this UserInfo userInfo, CommonLinkUtility commonLinkUtility)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-09-19 15:55:44 +00:00
|
|
|
return commonLinkUtility.GetUserProfile(userInfo);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|