2019-06-07 08:59:07 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System Limited 2010-2018
|
|
|
|
*
|
|
|
|
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
|
|
|
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
|
|
|
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
|
|
|
*
|
|
|
|
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
|
|
|
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
|
|
|
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
|
|
|
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
|
|
|
* in every copy of the program you distribute.
|
|
|
|
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
2019-08-08 09:26:58 +00:00
|
|
|
using ASC.Core.Tenants;
|
2019-06-07 08:59:07 +00:00
|
|
|
using ASC.Web.Core.Users;
|
|
|
|
using ASC.Web.Studio.Utility;
|
|
|
|
|
|
|
|
namespace ASC.Core.Users
|
|
|
|
{
|
|
|
|
public static class UserInfoExtension
|
|
|
|
{
|
|
|
|
public static string DisplayUserName(this UserInfo userInfo)
|
|
|
|
{
|
|
|
|
return DisplayUserName(userInfo, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string DisplayUserName(this UserInfo userInfo, bool withHtmlEncode)
|
|
|
|
{
|
|
|
|
return DisplayUserSettings.GetFullUserName(userInfo, withHtmlEncode);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-08-08 09:26:58 +00:00
|
|
|
public static bool HasAvatar(this UserInfo userInfo, Tenant tenant)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.UserHasAvatar(tenant, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static Size GetPhotoSize(this UserInfo userInfo, Tenant tenant)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetPhotoSize(tenant, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string GetPhotoURL(this UserInfo userInfo, Tenant tenant)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetPhotoAbsoluteWebPath(tenant, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string GetRetinaPhotoURL(this UserInfo userInfo, int tenantId)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetRetinaPhotoURL(tenantId, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string GetMaxPhotoURL(this UserInfo userInfo, int tenantId)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetMaxPhotoURL(tenantId, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string GetBigPhotoURL(this UserInfo userInfo, int tenantId)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetBigPhotoURL(tenantId, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string GetMediumPhotoURL(this UserInfo userInfo, int tenantId)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetMediumPhotoURL(tenantId, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string GetSmallPhotoURL(this UserInfo userInfo, int tenantId)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return UserPhotoManager.GetSmallPhotoURL(tenantId, userInfo.ID);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string RenderProfileLinkBase(this UserInfo userInfo, Tenant tenant)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
//check for removed users
|
2019-08-30 12:40:57 +00:00
|
|
|
if (userInfo == null || !CoreContext.UserManager.UserExists(userInfo))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
sb.Append("<span class='userLink text-medium-describe' style='white-space:nowrap;'>profile removed</span>");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var popupID = Guid.NewGuid();
|
|
|
|
sb.AppendFormat("<span class=\"userLink\" style='white-space:nowrap;' id='{0}' data-uid='{1}'>", popupID, userInfo.ID);
|
2019-08-30 12:40:57 +00:00
|
|
|
sb.AppendFormat("<a class='linkDescribe' href=\"{0}\">{1}</a>", userInfo.GetUserProfilePageURLGeneral(), userInfo.DisplayUserName());
|
2019-06-07 08:59:07 +00:00
|
|
|
sb.Append("</span>");
|
|
|
|
|
|
|
|
sb.AppendFormat("<script language='javascript'> StudioUserProfileInfo.RegistryElement('{0}','\"{1}\"); </script>", popupID, userInfo.ID);
|
|
|
|
}
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// return absolute profile link
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="userInfo"></param>
|
|
|
|
/// <returns></returns>
|
2019-08-30 12:40:57 +00:00
|
|
|
private static string GetUserProfilePageURLGeneral(this UserInfo userInfo)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-30 12:40:57 +00:00
|
|
|
return CommonLinkUtility.GetUserProfile(userInfo);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|