diff --git a/DNN Platform/JavaScript Libraries/Selectize/dnn.combobox.js b/DNN Platform/JavaScript Libraries/Selectize/dnn.combobox.js index 38bfc642389..8e7b5e68137 100644 --- a/DNN Platform/JavaScript Libraries/Selectize/dnn.combobox.js +++ b/DNN Platform/JavaScript Libraries/Selectize/dnn.combobox.js @@ -77,15 +77,18 @@ this.$control.find('input.summary').remove(); var $summary = $('').prependTo(this.$control); - var options = this.get_options().length; - var items = this.items.length; + var options = this.options; + var items = this.items; + var labels = items.map(function(i) { + return options[i][opts.labelField]; + }); var summaryText = ""; - if (items === options) { + if (items.length === this.get_options().length) { summaryText = opts.localization["AllItemsChecked"]; - } else if (items === 1) { - summaryText = this.items.join(','); + } else if (items.length === 1) { + summaryText = labels.join(','); } else { - summaryText = items + ' ' + opts.localization["ItemsChecked"]; + summaryText = items.length + ' ' + opts.localization["ItemsChecked"]; } $summary.val(summaryText); diff --git a/DNN Platform/Library/Services/Search/Controllers/UserResultController.cs b/DNN Platform/Library/Services/Search/Controllers/UserResultController.cs index 60691afa92d..7ac02b6b802 100644 --- a/DNN Platform/Library/Services/Search/Controllers/UserResultController.cs +++ b/DNN Platform/Library/Services/Search/Controllers/UserResultController.cs @@ -94,6 +94,20 @@ public override bool HasViewPermission(SearchResult searchResult) if (searchResult.UniqueKey.Contains("allusers")) { + var scopeForRoles = + PortalController.GetPortalSetting("SearchResult_ScopeForRoles", searchResult.PortalId, string.Empty) + .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + + if (scopeForRoles.Count > 0) + { + if (userInSearchResult.IsSuperUser) + { + return scopeForRoles.Contains("Superusers"); + } + + return scopeForRoles.Any(i => userInSearchResult.IsInRole(i)); + } + return true; } diff --git a/Website/DesktopModules/Admin/SearchResults/App_LocalResources/ResultsSettings.ascx.resx b/Website/DesktopModules/Admin/SearchResults/App_LocalResources/ResultsSettings.ascx.resx index 520b15beaa9..d51cf96573d 100644 --- a/Website/DesktopModules/Admin/SearchResults/App_LocalResources/ResultsSettings.ascx.resx +++ b/Website/DesktopModules/Admin/SearchResults/App_LocalResources/ResultsSettings.ascx.resx @@ -153,6 +153,12 @@ Results Scope for Site(s) + + Limit the search results by selecting the role(s). + + + Results Scope for Role(s) + Show Description diff --git a/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx b/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx index 042b72b6fc4..b8f3c656e91 100644 --- a/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx +++ b/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx @@ -27,6 +27,12 @@ + +
+ + + +
@@ -64,16 +70,34 @@ diff --git a/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.cs b/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.cs index 4cbbc40ccfd..5872866980b 100644 --- a/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.cs +++ b/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.cs @@ -30,6 +30,7 @@ using DotNetNuke.Common.Utilities; using DotNetNuke.Entities.Modules; using DotNetNuke.Entities.Portals; +using DotNetNuke.Security.Roles; using DotNetNuke.Services.Exceptions; using DotNetNuke.Services.Search.Internals; @@ -107,6 +108,18 @@ public override void LoadSettings() } } + var scopeForRoles = + PortalController.GetPortalSetting("SearchResult_ScopeForRoles", PortalId, string.Empty) + .Split(new []{','}, StringSplitOptions.RemoveEmptyEntries); + var roles = RoleController.Instance.GetRoles(PortalId, r => !r.IsSystemRole || r.RoleName == "Registered Users"); + roles.Insert(0, new RoleInfo(){RoleName = "Superusers" }); + + foreach (var role in roles) + { + var item = new ListItem(role.RoleName, role.RoleName) { Selected = scopeForRoles.Length == 0 || scopeForRoles.Contains(role.RoleName) }; + comboBoxRoles.Items.Add(item); + } + chkEnableWildSearch.Checked = GetBooleanSetting("EnableWildSearch", true); chkShowDescription.Checked = GetBooleanSetting("ShowDescription", true); chkShowFriendlyTitle.Checked = GetBooleanSetting("ShowFriendlyTitle", true); @@ -140,6 +153,9 @@ public override void UpdateSettings() ModuleController.Instance.UpdateModuleSetting(ModuleId, "ScopeForFilters", selectedFilters.ToString()); + var selectedRoles = comboBoxRoles.Value; + PortalController.UpdatePortalSetting(PortalId, "SearchResult_ScopeForRoles", selectedRoles); + ModuleController.Instance.UpdateModuleSetting(ModuleId, "EnableWildSearch", chkEnableWildSearch.Checked.ToString()); ModuleController.Instance.UpdateModuleSetting(ModuleId, "ShowDescription", chkShowDescription.Checked.ToString()); ModuleController.Instance.UpdateModuleSetting(ModuleId, "ShowFriendlyTitle", chkShowFriendlyTitle.Checked.ToString()); diff --git a/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.designer.cs b/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.designer.cs index a554651ec77..48e6198e2f9 100644 --- a/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.designer.cs +++ b/Website/DesktopModules/Admin/SearchResults/ResultsSettings.ascx.designer.cs @@ -93,6 +93,24 @@ public partial class ResultsSettings { /// protected global::System.Web.UI.WebControls.RequiredFieldValidator filtersRequiredFieldValidator; + /// + /// plResultsScopeForRoles control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plResultsScopeForRoles; + + /// + /// comboBoxRoles control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.Web.UI.WebControls.Internal.DnnComboBox comboBoxRoles; + /// /// plEnableWildSearch control. ///