diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bbc06..5bbe6450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp: user avatar - csharp-mvc: user avatar - java: user avatar - java-spring: user avatar diff --git a/web/documentserver-example/csharp/App_Themes/images/uid-1.png b/web/documentserver-example/csharp/App_Themes/images/uid-1.png new file mode 100644 index 00000000..91cf9e02 Binary files /dev/null and b/web/documentserver-example/csharp/App_Themes/images/uid-1.png differ diff --git a/web/documentserver-example/csharp/App_Themes/images/uid-2.png b/web/documentserver-example/csharp/App_Themes/images/uid-2.png new file mode 100644 index 00000000..651b40c6 Binary files /dev/null and b/web/documentserver-example/csharp/App_Themes/images/uid-2.png differ diff --git a/web/documentserver-example/csharp/DocEditor.aspx b/web/documentserver-example/csharp/DocEditor.aspx index 4d254058..e4c6cdb6 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -272,9 +272,29 @@ // add mentions for not anonymous users <% if (!string.IsNullOrEmpty(UsersForMentions)) { %> - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= UsersForMentions %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = <%= UsersInfo %>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = <%= UsersForMentions %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; <% } %> diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 334112a9..28a2a67d 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -64,6 +64,7 @@ namespace OnlineEditorsExample protected string DocumentData { get; private set; } protected string DataSpreadsheet { get; private set; } protected string UsersForMentions { get; private set; } + protected string UsersInfo { get; private set; } protected string DocumentType { get { return _Default.DocumentType(FileName); } } // get callback url @@ -256,7 +257,8 @@ namespace OnlineEditorsExample { { "id", !user.id.Equals("uid-0") ? user.id : null }, { "name", user.name }, - { "group", user.group } + { "group", user.group }, + { "image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null } } }, { @@ -317,6 +319,9 @@ namespace OnlineEditorsExample // get users for mentions List> usersData = Users.getUsersForMentions(user.id); UsersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(usersData) : null; + + List> usersInfo = Users.getUsersInfo(user.id); + UsersInfo = jss.Serialize(usersData); } catch { } } diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index 1dea57de..40c250a0 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -30,7 +30,8 @@ namespace OnlineEditorsExample "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Has an avatar" }; static List descr_user_2 = new List() @@ -40,7 +41,8 @@ namespace OnlineEditorsExample "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar" }; static List descr_user_3 = new List() @@ -84,6 +86,7 @@ namespace OnlineEditorsExample null, new List(), descr_user_1, + true, true ), new User( @@ -102,7 +105,8 @@ namespace OnlineEditorsExample true, new List(), descr_user_2, - false + false, + true ), new User( "uid-3", @@ -120,6 +124,7 @@ namespace OnlineEditorsExample false, new List() { "copy", "download", "print" }, descr_user_3, + false, false ), new User( @@ -133,6 +138,7 @@ namespace OnlineEditorsExample null, new List() { "protect" }, descr_user_0, + false, false ) }; @@ -171,6 +177,24 @@ namespace OnlineEditorsExample } return usersData; } + + public static List> getUsersInfo(string id) + { + List> usersData = new List>(); + if(id != "uid-0"){ + foreach (User user in users) + { + usersData.Add(new Dictionary() + { + {"id", user.id}, + {"name", user.name }, + {"email", user.email }, + {"image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null } + }); + } + } + return usersData; + } } public class User @@ -186,8 +210,9 @@ namespace OnlineEditorsExample public List descriptions; public bool templates; public List userInfoGroups; + public bool avatar; - public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates) + public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates, bool avatar) { this.id = id; this.name = name; @@ -200,6 +225,7 @@ namespace OnlineEditorsExample this.descriptions = descriptions; this.templates = templates; this.userInfoGroups = userInfoGroups; + this.avatar = avatar; } } }