From eac78eb879bc19566b1e89e495e8d68dfe293ffd Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Fri, 13 Oct 2023 09:54:44 +0200 Subject: [PATCH 1/8] profile for prod #66 --- BExIS.Modules.Fmt.UI.csproj | 2 ++ .../BexisServer_BE-Website.pubxml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Properties/PublishProfiles/BexisServer_BE-Website.pubxml diff --git a/BExIS.Modules.Fmt.UI.csproj b/BExIS.Modules.Fmt.UI.csproj index 97955c3..c98c229 100644 --- a/BExIS.Modules.Fmt.UI.csproj +++ b/BExIS.Modules.Fmt.UI.csproj @@ -221,6 +221,8 @@ + + diff --git a/Properties/PublishProfiles/BexisServer_BE-Website.pubxml b/Properties/PublishProfiles/BexisServer_BE-Website.pubxml new file mode 100644 index 0000000..bb7d2cb --- /dev/null +++ b/Properties/PublishProfiles/BexisServer_BE-Website.pubxml @@ -0,0 +1,18 @@ + + + + + FileSystem + FileSystem + Release + Any CPU + + True + False + C:\inetpub\wwwroot\BE-Website\Site\Areas\FMT + False + + \ No newline at end of file From 63214afb480cb7f2b6e2643f532c60e4eacfdcff Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Wed, 1 Nov 2023 10:00:58 +0100 Subject: [PATCH 2/8] https://github.com/bexis/Module_ResearchAreaManagement/issues/136 --- Controllers/PlotchartFilesController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/PlotchartFilesController.cs b/Controllers/PlotchartFilesController.cs index 7e8d81c..a348e8b 100644 --- a/Controllers/PlotchartFilesController.cs +++ b/Controllers/PlotchartFilesController.cs @@ -6,7 +6,7 @@ public class PlotchartFilesController : BaseFileManagementController { public ActionResult Index(string node_id = "") { - return RedirectToAction("Show", "PlotchartFiles", new { area = "FMT", viewName = "PlotchartFiles", viewTitle = "Potchart Documents", rootMenu = "PlotchartPackages", node_id = node_id.Replace("\\", "_") }); + return RedirectToAction("Show", "PlotchartFiles", new { area = "FMT", viewName = "PlotchartFiles", viewTitle = "Plotchart Documents", rootMenu = "PlotchartPackages", node_id = node_id.Replace("\\", "_") }); } } } \ No newline at end of file From 2a24da1b323bd30a18d15d9c15e346d62002a257 Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Wed, 19 Jun 2024 18:32:16 +0200 Subject: [PATCH 3/8] https://github.com/bexis/BExIS-intern/issues/629 --- .../TechniciansFilesAdminController.cs | 7 + Controllers/TechniciansFilesController.cs | 16 ++ .../ThematicGroupsFilesAdminController.cs | 7 + Controllers/ThematicGroupsFilesController.cs | 16 ++ .../TechniciansFiles/TechniciansFiles.cshtml | 168 ++++++++++++++++++ Views/TechniciansFilesAdmin/readme.txt | 1 + .../ThematicGroupsFiles.cshtml | 167 +++++++++++++++++ Views/ThematicGroupsFilesAdmin/readme.txt | 1 + 8 files changed, 383 insertions(+) create mode 100644 Controllers/TechniciansFilesAdminController.cs create mode 100644 Controllers/TechniciansFilesController.cs create mode 100644 Controllers/ThematicGroupsFilesAdminController.cs create mode 100644 Controllers/ThematicGroupsFilesController.cs create mode 100644 Views/TechniciansFiles/TechniciansFiles.cshtml create mode 100644 Views/TechniciansFilesAdmin/readme.txt create mode 100644 Views/ThematicGroupsFiles/ThematicGroupsFiles.cshtml create mode 100644 Views/ThematicGroupsFilesAdmin/readme.txt diff --git a/Controllers/TechniciansFilesAdminController.cs b/Controllers/TechniciansFilesAdminController.cs new file mode 100644 index 0000000..aaca3f5 --- /dev/null +++ b/Controllers/TechniciansFilesAdminController.cs @@ -0,0 +1,7 @@ +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class TechniciansFilesAdminController : BaseAdminFileManagementController + { + + } +} \ No newline at end of file diff --git a/Controllers/TechniciansFilesController.cs b/Controllers/TechniciansFilesController.cs new file mode 100644 index 0000000..33fb54e --- /dev/null +++ b/Controllers/TechniciansFilesController.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class TechniciansFilesController : BaseFileManagementController + { + public ActionResult Index(string node_id = "") + { + return RedirectToAction("Show", "TechniciansFiles", new { area = "FMT", viewName = "TechniciansFiles", viewTitle = "Technicians Documents", rootMenu = "Technicians", node_id = node_id.Replace("\\", "_") }); + } + } +} \ No newline at end of file diff --git a/Controllers/ThematicGroupsFilesAdminController.cs b/Controllers/ThematicGroupsFilesAdminController.cs new file mode 100644 index 0000000..2ea8a86 --- /dev/null +++ b/Controllers/ThematicGroupsFilesAdminController.cs @@ -0,0 +1,7 @@ +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class ThematicGroupsFilesAdminController : BaseAdminFileManagementController + { + + } +} \ No newline at end of file diff --git a/Controllers/ThematicGroupsFilesController.cs b/Controllers/ThematicGroupsFilesController.cs new file mode 100644 index 0000000..11a465f --- /dev/null +++ b/Controllers/ThematicGroupsFilesController.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class ThematicGroupsFilesController : BaseFileManagementController + { + public ActionResult Index(string node_id = "") + { + return RedirectToAction("Show", "ThematicGroupsFiles", new { area = "FMT", viewName = "ThematicGroupsFiles", viewTitle = "ThematicGroups Documents", rootMenu = "ThematicGroups", node_id = node_id.Replace("\\", "_") }); + } + } +} \ No newline at end of file diff --git a/Views/TechniciansFiles/TechniciansFiles.cshtml b/Views/TechniciansFiles/TechniciansFiles.cshtml new file mode 100644 index 0000000..4459e7e --- /dev/null +++ b/Views/TechniciansFiles/TechniciansFiles.cshtml @@ -0,0 +1,168 @@ +@using Telerik.Web.Mvc.UI +@using System.Collections.Generic +@using BExIS.Modules.FMT.UI.Models + +@model List + +@{ + + if (ViewBag.UseLayout == null) + { + Layout = null; + } +} +
+ +
+ + @Html.ValidationMessage("Error")
+ @if (Model == null) + { + + } + else + { + @Html.Telerik().TreeView().Name("TreeView").ShowCheckBox(false).ExpandAll(false).ClientEvents(events => events + .OnSelect("onSelect").OnLoad("click_node") + + ).BindTo(Model, mappings => + { + mappings.For + (binding => binding.ItemDataBound((item, menuItem) => + { + item.Text = menuItem.Title; + item.Value = menuItem.Path; + item.LinkHtmlAttributes["id"] = menuItem.Path.Replace("\\", "_"); + item.ImageUrl = menuItem.MenuItems.Any() ? "~/Areas/FMT/Images/FMT_Images/Folders.png" : "~/Areas/FMT/Images/FMT_Images/Folder.png"; + }) + .Children(category => category.MenuItems)); + mappings.For + (binding => binding + .ItemDataBound((item, subMenuItem) => + { + item.Text = subMenuItem.Title; + item.Value = subMenuItem.Path; + item.LinkHtmlAttributes["id"] = subMenuItem.Path.Replace("\\", "_"); + item.ImageUrl = subMenuItem.MenuItems.Any() ? "~/Areas/FMT/Images/FMT_Images/Folders.png" : "~/Areas/FMT/Images/FMT_Images/Folder.png"; + })); + }); + + + } + +
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/Views/TechniciansFilesAdmin/readme.txt b/Views/TechniciansFilesAdmin/readme.txt new file mode 100644 index 0000000..678ffc4 --- /dev/null +++ b/Views/TechniciansFilesAdmin/readme.txt @@ -0,0 +1 @@ +emty folder needed! \ No newline at end of file diff --git a/Views/ThematicGroupsFiles/ThematicGroupsFiles.cshtml b/Views/ThematicGroupsFiles/ThematicGroupsFiles.cshtml new file mode 100644 index 0000000..9db69af --- /dev/null +++ b/Views/ThematicGroupsFiles/ThematicGroupsFiles.cshtml @@ -0,0 +1,167 @@ +@using Telerik.Web.Mvc.UI +@using System.Collections.Generic +@using BExIS.Modules.FMT.UI.Models + +@model List + +@{ + + if (ViewBag.UseLayout == null) + { + Layout = null; + } +} +
+ +
+ + @Html.ValidationMessage("Error")
+ @if (Model == null) + { + + } + else + { + @Html.Telerik().TreeView().Name("TreeView").ShowCheckBox(false).ExpandAll(false).ClientEvents(events => events + .OnSelect("onSelect").OnLoad("click_node") + + ).BindTo(Model, mappings => + { + mappings.For + (binding => binding.ItemDataBound((item, menuItem) => + { + item.Text = menuItem.Title; + item.Value = menuItem.Path; + item.LinkHtmlAttributes["id"] = menuItem.Path.Replace("\\", "_"); + item.ImageUrl = menuItem.MenuItems.Any() ? "~/Areas/FMT/Images/FMT_Images/Folders.png" : "~/Areas/FMT/Images/FMT_Images/Folder.png"; + }) + .Children(category => category.MenuItems)); + mappings.For + (binding => binding + .ItemDataBound((item, subMenuItem) => + { + item.Text = subMenuItem.Title; + item.Value = subMenuItem.Path; + item.LinkHtmlAttributes["id"] = subMenuItem.Path.Replace("\\", "_"); + item.ImageUrl = subMenuItem.MenuItems.Any() ? "~/Areas/FMT/Images/FMT_Images/Folders.png" : "~/Areas/FMT/Images/FMT_Images/Folder.png"; + })); + }); + + + } + +
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/Views/ThematicGroupsFilesAdmin/readme.txt b/Views/ThematicGroupsFilesAdmin/readme.txt new file mode 100644 index 0000000..678ffc4 --- /dev/null +++ b/Views/ThematicGroupsFilesAdmin/readme.txt @@ -0,0 +1 @@ +emty folder needed! \ No newline at end of file From 4dca7d3508b6b1975c48c7c131311455d1adc861 Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Wed, 19 Jun 2024 18:49:37 +0200 Subject: [PATCH 4/8] Create Page for DMPs #73 --- BExIS.Modules.Fmt.UI.csproj | 16 ++++++++++---- Controllers/DmpFilesAdminController.cs | 21 +++++++++++++++++++ Controllers/DmpFilesController.cs | 20 ++++++++++++++++++ .../SocialEcologicalFilesAdminController.cs | 7 ------- .../SocialEcologicalFilesController.cs | 16 -------------- FMT.Manifest.xml | 14 +++++++++++-- 6 files changed, 65 insertions(+), 29 deletions(-) create mode 100644 Controllers/DmpFilesAdminController.cs create mode 100644 Controllers/DmpFilesController.cs delete mode 100644 Controllers/SocialEcologicalFilesAdminController.cs delete mode 100644 Controllers/SocialEcologicalFilesController.cs diff --git a/BExIS.Modules.Fmt.UI.csproj b/BExIS.Modules.Fmt.UI.csproj index c98c229..06c7cff 100644 --- a/BExIS.Modules.Fmt.UI.csproj +++ b/BExIS.Modules.Fmt.UI.csproj @@ -181,6 +181,8 @@ + + @@ -191,9 +193,11 @@ - + + - + + @@ -229,8 +233,10 @@ - + + + web.config @@ -243,6 +249,7 @@ + @@ -250,7 +257,8 @@ - + + diff --git a/Controllers/DmpFilesAdminController.cs b/Controllers/DmpFilesAdminController.cs new file mode 100644 index 0000000..ed38ead --- /dev/null +++ b/Controllers/DmpFilesAdminController.cs @@ -0,0 +1,21 @@ +<<<<<<< Updated upstream +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class DmpFilesAdminFilesAdminController : BaseAdminFileManagementController + { + +======= +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class DmpFilesAdminController : BaseAdminFileManagementController + { + +>>>>>>> Stashed changes + } +} \ No newline at end of file diff --git a/Controllers/DmpFilesController.cs b/Controllers/DmpFilesController.cs new file mode 100644 index 0000000..35eb8b6 --- /dev/null +++ b/Controllers/DmpFilesController.cs @@ -0,0 +1,20 @@ +<<<<<<< Updated upstream +using System; +======= +using System; +>>>>>>> Stashed changes +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace BExIS.Modules.Fmt.UI.Controllers +{ + public class DmpFilesController : BaseFileManagementController + { + public ActionResult Index(string node_id = "") + { + return RedirectToAction("Show", "DmpFiles", new { area = "FMT", viewName = "DmpFiles", viewTitle = "Dmp Documents", rootMenu = "DMPs", node_id = node_id.Replace("\\", "_") }); + } + } +} \ No newline at end of file diff --git a/Controllers/SocialEcologicalFilesAdminController.cs b/Controllers/SocialEcologicalFilesAdminController.cs deleted file mode 100644 index d958e3c..0000000 --- a/Controllers/SocialEcologicalFilesAdminController.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BExIS.Modules.Fmt.UI.Controllers -{ - public class SocialEcologicalFilesAdminController : BaseAdminFileManagementController - { - - } -} \ No newline at end of file diff --git a/Controllers/SocialEcologicalFilesController.cs b/Controllers/SocialEcologicalFilesController.cs deleted file mode 100644 index 02ff450..0000000 --- a/Controllers/SocialEcologicalFilesController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; - -namespace BExIS.Modules.Fmt.UI.Controllers -{ - public class SocialEcologicalFilesController : BaseFileManagementController - { - public ActionResult Index(string node_id = "") - { - return RedirectToAction("Show", "SocialEcologicalFiles", new { area = "FMT", viewName = "SocialEcologicalFiles", viewTitle = "SocialEcological Documents", rootMenu = "SocialEcological", node_id = node_id.Replace("\\", "_") }); - } - } -} \ No newline at end of file diff --git a/FMT.Manifest.xml b/FMT.Manifest.xml index 8e8439d..19ed454 100644 --- a/FMT.Manifest.xml +++ b/FMT.Manifest.xml @@ -38,8 +38,18 @@ extends="./menubarRoot/documents" /> + + + + Date: Wed, 19 Jun 2024 18:50:00 +0200 Subject: [PATCH 5/8] Create Page for DMPs #73 --- Views/DrivingDirectionsFiles/DrivingDirectionsFiles.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Views/DrivingDirectionsFiles/DrivingDirectionsFiles.cshtml b/Views/DrivingDirectionsFiles/DrivingDirectionsFiles.cshtml index d28acf8..aa8763b 100644 --- a/Views/DrivingDirectionsFiles/DrivingDirectionsFiles.cshtml +++ b/Views/DrivingDirectionsFiles/DrivingDirectionsFiles.cshtml @@ -57,7 +57,7 @@
-
+ @*
*@

From f5d608632e23e117912f07b6b90ab732c70fd15b Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Wed, 19 Jun 2024 18:50:23 +0200 Subject: [PATCH 6/8] Create Page for DMPs #73 --- .../DmpFiles.cshtml} | 8 ++++---- .../readme.txt | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename Views/{SocialEcologicalFiles/SocialEcologicalFiles.cshtml => DmpFiles/DmpFiles.cshtml} (93%) rename Views/{SocialEcologicalFilesAdmin => DmpFilesAdmin}/readme.txt (100%) diff --git a/Views/SocialEcologicalFiles/SocialEcologicalFiles.cshtml b/Views/DmpFiles/DmpFiles.cshtml similarity index 93% rename from Views/SocialEcologicalFiles/SocialEcologicalFiles.cshtml rename to Views/DmpFiles/DmpFiles.cshtml index cecf4e3..97bb5cb 100644 --- a/Views/SocialEcologicalFiles/SocialEcologicalFiles.cshtml +++ b/Views/DmpFiles/DmpFiles.cshtml @@ -84,15 +84,15 @@ function loadFilesAndUploader() { val = SelectedValue; - contr = "SocialEcologicalFiles"; - adminContr = "SocialEcologicalFilesAdmin"; - $.get('@Url.Action("GetFileLists", "SocialEcologicalFiles", new { area="FMT"})', { menuItemPath: val, contollerName: contr }, function (data) { + contr = "DmpFiles"; + adminContr = "DmpFilesAdmin"; + $.get('@Url.Action("GetFileLists", "DmpFiles", new { area="FMT"})', { menuItemPath: val, contollerName: contr }, function (data) { $('#FMTFilesDIV').html(data); }); var adminrights = @Html.Raw(Json.Encode(ViewData["AdminRights"])); if (adminrights) { - $.get('@Url.Action("GetFileUploader", "SocialEcologicalFilesAdmin", new { area = "FMT" })', { menuItemPath: val, contollerName: adminContr }, function (data) { + $.get('@Url.Action("GetFileUploader", "DmpFilesAdmin", new { area = "FMT" })', { menuItemPath: val, contollerName: adminContr }, function (data) { $('#FMTFileUpload').html(data); }); } diff --git a/Views/SocialEcologicalFilesAdmin/readme.txt b/Views/DmpFilesAdmin/readme.txt similarity index 100% rename from Views/SocialEcologicalFilesAdmin/readme.txt rename to Views/DmpFilesAdmin/readme.txt From 409aa0637580fb21fa8223ef0b0d651a77e0a585 Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Wed, 19 Jun 2024 18:52:11 +0200 Subject: [PATCH 7/8] allow empty group rights in root nodes #71 --- Helper/MenuHelper.cs | 76 +++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/Helper/MenuHelper.cs b/Helper/MenuHelper.cs index 0ec0fc7..3dda7c4 100644 --- a/Helper/MenuHelper.cs +++ b/Helper/MenuHelper.cs @@ -48,15 +48,15 @@ private XmlDocument GetMenuXmlDoc() return xmlDoc; } - internal bool HasUserAccessRights(string root, string userName, string node = "") + internal bool HasUserAccessRights(string root, string userName = null, string node = "") { XmlDocument xmlDoc = GetMenuXmlDoc(); string[] rootGroups; bool hasRights = false; - + string temp = ""; try { - string temp = xmlDoc.SelectSingleNode(string.Format("//Items[@Name='{0}']", root)).Attributes.GetNamedItem("Group").Value; + temp = xmlDoc.SelectSingleNode(string.Format("//Items[@Name='{0}']", root)).Attributes.GetNamedItem("Group").Value; rootGroups = temp.Split(','); } catch (Exception ex) @@ -66,24 +66,31 @@ internal bool HasUserAccessRights(string root, string userName, string node = "" //if node is empty then check only root node access if (node == "") { - if (rootGroups.Length > 0) + if (!String.IsNullOrEmpty(temp)) { - using (UserManager userManager = new UserManager()) + if (!String.IsNullOrEmpty(userName)) { - foreach (string roleName in rootGroups) + using (UserManager userManager = new UserManager()) { - var userTask = userManager.FindByNameAsync(userName); - userTask.Wait(); - var user = userTask.Result; - - if (user.Groups.Select(a => a.Name).Contains(roleName)) + foreach (string roleName in rootGroups) { - hasRights = true; - break; + var userTask = userManager.FindByNameAsync(userName); + userTask.Wait(); + var user = userTask.Result; + + if (user.Groups.Select(a => a.Name).Contains(roleName)) + { + hasRights = true; + break; + } } } } } + else + { + hasRights = true; + } } //if node not empty check access rights to the singel node dependence on root. else @@ -91,24 +98,29 @@ internal bool HasUserAccessRights(string root, string userName, string node = "" //if node has an entry in Group check rights for user. If group empty skip access rights check try { - string temp = xmlDoc.SelectSingleNode(string.Format("//Items[@Name='{0}']", node)).Attributes.GetNamedItem("Group").Value; - if(String.IsNullOrEmpty(temp)) + temp = xmlDoc.SelectSingleNode(string.Format("//Items[@Name='{0}']", node)).Attributes.GetNamedItem("Group").Value; + if (String.IsNullOrEmpty(temp)) + { hasRights = true; + } else { - var nodeGroups = temp.Split(','); - using (UserManager userManager = new UserManager()) + if (!String.IsNullOrEmpty(userName)) { - foreach (string roleName in nodeGroups) + var nodeGroups = temp.Split(','); + using (UserManager userManager = new UserManager()) { - var userTask = userManager.FindByNameAsync(userName); - userTask.Wait(); - var user = userTask.Result; - - if (user.Groups.Select(a => a.Name).Contains(roleName)) + foreach (string roleName in nodeGroups) { - hasRights = true; - break; + var userTask = userManager.FindByNameAsync(userName); + userTask.Wait(); + var user = userTask.Result; + + if (user.Groups.Select(a => a.Name).Contains(roleName)) + { + hasRights = true; + break; + } } } } @@ -123,7 +135,7 @@ internal bool HasUserAccessRights(string root, string userName, string node = "" return hasRights; } - internal List GetMenu(string root, string userName) + internal List GetMenu(string root, string userName = null) { List menuItems = null; @@ -140,8 +152,11 @@ internal List GetMenu(string root, string userName) string path = FMTPath + @"\\" + root; foreach (var xmlMenuItem in GetMenuItems(xmlNodeList[0], path, root, userName).MenuItems) { - //check if user has rights to see menu entry (rights via groups) - bool hasRights = HasUserAccessRights(root, userName, xmlMenuItem.Name); + bool hasRights = false; + + //check if user has rights to see menu entry (rights via groups) + hasRights = HasUserAccessRights(root, userName, xmlMenuItem.Name); + if (hasRights) menuItems.Add(xmlMenuItem); } @@ -162,7 +177,7 @@ internal void AppendToRootMenu(XElement newXElement) xElement.Save(menuConfigPath); } - FMTMenuItem GetMenuItems(XmlNode xmlNode, string directory, string root, string userName) + FMTMenuItem GetMenuItems(XmlNode xmlNode, string directory, string root, string userName = null) { if (xmlNode.Name != "Item" && xmlNode.Name != "Items") return null; @@ -174,7 +189,8 @@ FMTMenuItem GetMenuItems(XmlNode xmlNode, string directory, string root, string foreach (XmlNode childXmlNode in xmlNode.ChildNodes) { //check if user has rights to see menu entry (rights via groups) - bool hasRights = HasUserAccessRights(root, userName, childXmlNode.Attributes["Name"].Value); + bool hasRights = HasUserAccessRights(root, userName, childXmlNode.Attributes["Name"].Value); + if (hasRights) item.MenuItems.Add(GetMenuItems(childXmlNode, directory + @"\\" + childXmlNode.Attributes["Name"].Value, root, userName)); } From 1b4133676bb210cff6331cc675b9c26390738471 Mon Sep 17 00:00:00 2001 From: Eleonora Petzold Date: Wed, 19 Jun 2024 18:52:33 +0200 Subject: [PATCH 8/8] allow empty group rights in root nodes #71 --- Controllers/BaseFileManagementController.cs | 62 ++++++++++++--------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/Controllers/BaseFileManagementController.cs b/Controllers/BaseFileManagementController.cs index 9f725cf..8d7fc10 100644 --- a/Controllers/BaseFileManagementController.cs +++ b/Controllers/BaseFileManagementController.cs @@ -23,13 +23,18 @@ public ActionResult Show(string viewName, string rootMenu, string viewTitle ) { ViewBag.Title = PresentationModel.GetViewTitleForTenant(viewTitle, this.Session.GetTenant()); bool hasAdminRights = false; - using (UserManager userManager = new UserManager()) - using (FeaturePermissionManager featurePermissionManager = new FeaturePermissionManager()) - using (FeatureManager featureManager = new FeatureManager()) + string userName = HttpContext.User.Identity.Name; + + if (!String.IsNullOrEmpty(userName)) { - var user = userManager.FindByNameAsync(HttpContext.User.Identity.Name).Result; - var feature = featureManager.FindByName(viewName + "Admin"); - hasAdminRights = featurePermissionManager.HasAccess(user.Id, feature.Id); + using (UserManager userManager = new UserManager()) + using (FeaturePermissionManager featurePermissionManager = new FeaturePermissionManager()) + using (FeatureManager featureManager = new FeatureManager()) + { + var user = userManager.FindByNameAsync(userName).Result; + var feature = featureManager.FindByName(viewName + "Admin"); + hasAdminRights = featurePermissionManager.HasAccess(user.Id, feature.Id); + } } if (String.IsNullOrEmpty(rootMenu)) @@ -39,11 +44,11 @@ public ActionResult Show(string viewName, string rootMenu, string viewTitle ) MenuHelper menuHelper = new MenuHelper(); - string userName = HttpContext.User.Identity.Name; + List menus = null; - bool hasUserRights = false; - if (userName != "" && rootMenu != "") + bool hasUserRights = false; + if (rootMenu != "") hasUserRights = menuHelper.HasUserAccessRights(rootMenu, userName); if (!hasUserRights) @@ -65,33 +70,36 @@ public ActionResult GetFileLists(string menuItemPath, string contollerName) { //string menuItem = new DirectoryInfo(menuItemPath).Name; + string userName = GetUsernameOrDefault(); bool hasDeleteRights = false; - //check user permissions for delete - using (var featurePermissionManager = new FeaturePermissionManager()) - using (var featureManager = new FeatureManager()) - using (UserManager userManager = new UserManager()) + if (!String.IsNullOrEmpty(userName)) { - - var userTask = userManager.FindByNameAsync(GetUsernameOrDefault()); - userTask.Wait(); - var user = userTask.Result; - List features = featureManager.FeatureRepository.Get().ToList(); - Feature feature = features.FirstOrDefault(f => f.Name.Equals(contollerName + "Admin")); - if (feature != null) + //check user permissions for delete + using (var featurePermissionManager = new FeaturePermissionManager()) + using (var featureManager = new FeatureManager()) + using (UserManager userManager = new UserManager()) { - if (featurePermissionManager.HasAccess(user.Id, feature.Id)) + + var userTask = userManager.FindByNameAsync(userName); + userTask.Wait(); + var user = userTask.Result; + List features = featureManager.FeatureRepository.Get().ToList(); + Feature feature = features.FirstOrDefault(f => f.Name.Equals(contollerName + "Admin")); + if (feature != null) { - hasDeleteRights = true; + if (featurePermissionManager.HasAccess(user.Id, feature.Id)) + { + hasDeleteRights = true; + } } } + } - var fileModelList = FileModel.GetFileModelList(menuItemPath, hasDeleteRights); - fileModelList.ForEach(a => a.controllerName = contollerName); + var fileModelList = FileModel.GetFileModelList(menuItemPath, hasDeleteRights); + fileModelList.ForEach(a => a.controllerName = contollerName); - return PartialView("~/Areas/FMT/Views/Shared/_fileList.cshtml", fileModelList); - } - + return PartialView("~/Areas/FMT/Views/Shared/_fileList.cshtml", fileModelList); } public ActionResult DownloadFile(string path, string mimeType)