diff --git a/BExIS.Modules.Fmt.UI.csproj b/BExIS.Modules.Fmt.UI.csproj index 97955c3..06c7cff 100644 --- a/BExIS.Modules.Fmt.UI.csproj +++ b/BExIS.Modules.Fmt.UI.csproj @@ -181,6 +181,8 @@ + + @@ -191,9 +193,11 @@ - + + - + + @@ -221,14 +225,18 @@ + + - + + + web.config @@ -241,6 +249,7 @@ + @@ -248,7 +257,8 @@ - + + 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) 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/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 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/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/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" /> + + + + 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)); } 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 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 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 @@
-
+ @*
*@

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