From f42480dfd2babaf78ca743ec88766832bf37d1ad Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 26 Apr 2021 12:32:13 +0300 Subject: [PATCH] csharp: add favorite and permissions at user list --- .../csharp/DocEditor.aspx.cs | 12 ++++-------- web/documentserver-example/csharp/Users.cs | 14 +++++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 87d66b45..31a5f08b 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -155,11 +155,7 @@ namespace OnlineEditorsExample var jss = new JavaScriptSerializer(); // favorite icon state - object favorite = null; - if (!user.id.Equals("uid-0") && !user.id.Equals("uid-1")) - { - favorite = user.id.Equals("uid-2"); - } + bool? favorite = user.favorite; var actionLink = Request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link @@ -189,10 +185,10 @@ namespace OnlineEditorsExample "permissions", new Dictionary { { "comment", editorsMode != "view" && editorsMode != "fillForms" && editorsMode != "embedded" && editorsMode != "blockcontent"}, - { "copy", user.id.Equals("uid-3") ? false : true }, - { "download", user.id.Equals("uid-3") ? false : true }, + { "copy", !user.deniedPermissions.Contains("copy") }, + { "download", !user.deniedPermissions.Contains("download") }, { "edit", canEdit && (editorsMode == "edit" || editorsMode =="view" || editorsMode == "filter" || editorsMode == "blockcontent") }, - { "print", user.id.Equals("uid-3") ? false : true }, + { "print", !user.deniedPermissions.Contains("print") }, { "fillForms", editorsMode != "view" && editorsMode != "comment" && editorsMode != "embedded" && editorsMode != "blockcontent" }, { "modifyFilter", editorsMode != "filter" }, { "modifyContentControl", editorsMode != "blockcontent" }, diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index c67eff37..15c92775 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -23,10 +23,10 @@ namespace OnlineEditorsExample public class Users { private static List users = new List() { - new User("uid-1", "John Smith", "smith@mail.ru", null, null), - new User("uid-2", "Mark Pottato", "pottato@mail.ru", "group-2", new List() { "group-2", "" }), - new User("uid-3", "Hamish Mitchell", "mitchell@mail.ru", "group-3", new List() { "group-2" }), - new User("uid-0", null, null, null, null) + new User("uid-1", "John Smith", "smith@mail.ru", null, null, null, new List()), + new User("uid-2", "Mark Pottato", "pottato@mail.ru", "group-2", new List() { "group-2", "" }, true, new List()), + new User("uid-3", "Hamish Mitchell", "mitchell@mail.ru", "group-3", new List() { "group-2" }, false, new List() { "copy", "download", "print" }), + new User("uid-0", null, null, null, null, null, new List()) }; public static User getUser(string id) @@ -51,14 +51,18 @@ namespace OnlineEditorsExample public string email; public string group; public List reviewGroups; + public bool? favorite; + public List deniedPermissions; - public User(string id, string name, string email, string group, List reviewGroups) + public User(string id, string name, string email, string group, List reviewGroups, bool? favorite, List deniedPermissions) { this.id = id; this.name = name; this.email = email; this.group = group; this.reviewGroups = reviewGroups; + this.favorite = favorite; + this.deniedPermissions = deniedPermissions; } }