var DataGridDataType = { Farm: "Farm", WebApplication: "WebApplication", SiteCollection: "SiteCollection", Web: "Web", List: "List", Library: "Library", Folder: "Folder", DocumentSet: "DocumentSet", Item: "Item" }; var DataGridSelectItems = function (siteId, webId, urlZone) { this.SiteId = siteId; this.WebId = webId; this.UrlZone = urlZone; this.Items = []; }; /* Note: RootWeb Always eq Web,unless root web has different opreation with normal web. */ var FuncMapping = { AccountPermission: { GrantAccountPermission: { Type: { RootWeb: true, Web: true, List: true, Folder: true, Item: true, RootWebs: false, Webs: true, Lists: true, Folders: true, Items: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "AddAccountPermission", Tab: ["Permission", "Search"] }, RemoveAccountPermission: { Type: { RootWeb: true, Web: true, List: true, Folder: true, Item: true, RootWebs: false, Webs: true, Lists: true, Folders: true, Items: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "RemoveAccountPermission", Tab: ["Permission", "Search"] }, CloneAccountPermission: { Type: { WebApplication: true, RootWeb: true, Web: true, List: true, Item: true, Folder: true, RootWebs: true, Webs: true, WebApplications: true, Lists: true, Folders: true, Items: true }, Permission: { Unique: true }, RefRibbonId: "CloneAccountPermission", Tab: ["Permission", "Search"] }, TransferAccountPermission: { Type: { RootWeb: true, Web: true, List: true, Folder: true, Item: true, RootWebs: true, Webs: true, Lists: true, Folders: true, Items: true }, Permission: { Unique: true }, RefRibbonId: "TransferAccountPermission" }, CleanDeadAccount: { Type: { RootWeb: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "CleanDeadAccount", Tab: ["Permission"] }, ViewGroups: { Type: { RootWeb: true, Web: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "ViewGroups", Tab: ["Permission"] }, ViewPermissions: { Type: { RootWeb: true, Web: true, List: true, Folder: true, Item:true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "ViewPermissions", Tab: ["Permission"] } }, SiteListPermission: { ExportPermissionSets: { Type: { RootWeb: true, Web: true, List: true, Folder: true, Item:true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "ExportPermissionSets", Tab: ["Permission"] }, ImportPermissionSets: { Type: { RootWeb: true, Web: true, List: true, Folder: true, Item:true, Webs: true, Lists: true, Folders: true, Items:true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "ImportPermissionSets", Tab: ["Permission"] }, ChangePermissionInheritance: { Type: { RootWeb: false, Web: true, List: true, Folder: true, Item: true, RootWebs: false, Webs: true, Lists: true, Folders: true, Items: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "ChangePermissionInheritance", Tab: ["Permission", "Search"] } }, Search: { SearchAccountPermission: { Type: { RootWeb: true, Web: true, List: true, Folder: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "SearchAccountPermission" }, SearchPermissionLevelAccess: { Type: { RootWeb: true, Web: true, List: true, Folder: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "SearchPermissionLevelAccess" }, SearchPermissionInheritance: { Type: { RootWeb: true, Web: true, List: true, Folder: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "SearchPermissionInheritance" } }, CVP: { CheckColumnPermission: { Type: { List: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "CheckColumnPermission" }, CheckViewPermission: { Type: { List: true }, Permission: { Unique: true, Inherit: true }, RefRibbonId: "CheckViewPermission" } }, SPGroups: { CreateGroup: { Type: { RootWeb: true, Web: true }, Permission: { Unique: true }, RefRibbonId: "CreateGroup" }, DeleteGroup: { Type: { RootWeb: true, Web: true }, Permission: { Unique: true }, RefRibbonId: "DeleteGroup" } }, PermissionLevel: { Add: { Type: { SiteCollection: true }, Permission: { Unique: true }, RefRibbonId: "Add" }, Modify: { Type: { SiteCollection: true }, Permission: { Unique: true }, RefRibbonId: "Modify" }, Delete: { Type: { SiteCollection: true }, Permission: { Unique: true }, RefRibbonId: "Delete" }, ExportOrImport: { Type: { SiteCollection: true }, Permission: { Unique: true }, RefRibbonId: "ExportOrImport" } } } var DataGridManager = function (gridid, subscribeName, currTabName) { _filterValue = ""; var _gridId = gridid; _subscribeName = subscribeName; _farmNode = { id: "", webId: "", siteId: "", label: "", type: "Farm", hasUniquePermission: false, urlZone: "Default" }; var currentContentNode = _farmNode; /* DataGridSelectItem{ SiteId:"", UrlZone:"", WebId:"", Id:"", ItemType:"" } */ this.GetSelectItems = function (bGetIds) { var grid = dijit.byId(_gridId); var items = grid.selection.getSelected(); var result = []; if (!bGetIds) return items; if (items && items.length > 0) { dojo.forEach(items, function (item) { result.push({ SiteId: item.SiteId, UrlZone: item.UrlZone, WebId: item.WebId, Id: item.Id, ItemType: item.ItemType }); }); return result; } return result; }; this.FilterItems = function (filter) { window.processBar.Show(true); var grid = dijit.byId(_gridId); if (!grid) return; if (currentContentNode) { var content = currentContentNode; SharePointBoost.EnterpriseSolution.Services.DataGrid.GetFilterItems(dojo.toJson(content), filter, function (result) { _filterValue = filter; var jsnResult = dojo.fromJson(result); jsnResult.Structure = _ExtendStructure(jsnResult); store = new dojo.store.Memory({ data: jsnResult.Items }); dataStore = new dojo.data.ObjectStore({ objectStore: store }); if (grid && grid.selection) grid.selection.clear(); grid.firstPage(); grid.set("structure", jsnResult.Structure); grid.setStore(dataStore); grid.focus.previousKey(); //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); window.processBar.Close(); }, function (e) { store = new dojo.store.Memory({ data: [] }); dataStore = new dojo.data.ObjectStore({ objectStore: store }); if (grid && grid.selection) grid.selection.clear(); grid.setStore(new dojo.data.ObjectStore({ objectStore: dataStore })); window.RedirectLoginPage(e); //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); window.processBar.Close(); }); } }; _Init = function () { SharePointBoost.EnterpriseSolution.Services.DataGrid.GetTreeNodeItems(dojo.toJson(_farmNode), function (result) { var jsnResult = dojo.fromJson(result); var store = new dojo.store.Memory({ data: jsnResult.Items }); var dataStore = new dojo.data.ObjectStore({ objectStore: store }); jsnResult.Structure = _ExtendStructure(jsnResult); var grid = new dojox.grid.EnhancedGrid({ store: dataStore, query: { Id: "*" }, structure: jsnResult.Structure, plugins: { pagination: { gotoButton: false, //pageSize: 10, defaultPageSize: 20, pageSizes: [20, 50, 100] }, indirectSelection: { headerSelector: true, width: "40px", styles: "text-align: center;" } }, autoHeight: true }, _gridId); grid.selection.clear(); grid.startup(); grid.views.updateRow = function (inRowIndex, skipRenorm) { for (var i = 0, v; v = this.views[i]; i++) { v.updateRow(inRowIndex); } if (!skipRenorm) { this.renormalizeRow(inRowIndex); } this.grid.selection.clear(); }; PublishSelected(); grid.focus.previousKey(); setGridRowSelectOrNotWhenRowClick(dijit.byId(_gridId)); RedefineMouseOverOrOutEventOnGridRow(grid); }, function (e) { var grid = new dojox.grid.EnhancedGrid({ store: null, query: { Id: "*" }, structure: null, plugins: { pagination: { gotoButton: false, //pageSize: 10, defaultPageSize: 20, pageSizes: [20, 50, 100] }, indirectSelection: { headerSelector: true, width: "40px", styles: "text-align: center;" } }, autoHeight: true }, _gridId); grid.startup(); window.RedirectLoginPage(e); }); //Subscribe TreeNode Click dojo.subscribe(this._subscribeName, function (obj) { //clear filter value _filterValue = ""; window.processBar.Show(true); var grid = dijit.byId(_gridId); if (!grid) return; var farmNode = { id: obj.item.id[0], webId: obj.item.webId[0], siteId: obj.item.siteId[0], label: obj.item.label[0], type: obj.item.type[0], hasUniquePermission: obj.item.hasUniquePermission[0], urlZone: obj.item.urlZone[0] }; currentContentNode = farmNode; if (window.PermissionSettingHelper) { if (farmNode.type == "Farm") { window.PermissionSettingHelper.Collapse(); } else { window.PermissionSettingHelper.Expand(); } } SharePointBoost.EnterpriseSolution.Services.DataGrid.GetTreeNodeItems(dojo.toJson(farmNode), function (result) { var jsnResult = dojo.fromJson(result); jsnResult.Structure = _ExtendStructure(jsnResult); store = new dojo.store.Memory({ data: jsnResult.Items }); dataStore = new dojo.data.ObjectStore({ objectStore: store }); if (grid && grid.selection) grid.selection.clear(); grid.firstPage(); grid.set("structure", jsnResult.Structure); grid.setStore(dataStore); grid.focus.previousKey(); window.permissionManagerSearchTextControl.reset(); //show top refresh button //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); PublishSelected(); window.processBar.Close(); }, function (e) { store = new dojo.store.Memory({ data: [] }); dataStore = new dojo.data.ObjectStore({ objectStore: store }); if (grid && grid.selection) grid.selection.clear(); grid.setStore(new dojo.data.ObjectStore({ objectStore: dataStore })); window.RedirectLoginPage(e); window.permissionManagerSearchTextControl.reset(); window.processBar.Close(); }); }); }; dataGridIcon = { SiteCollection: "sharepointWeb", Web: "sharepointWeb", List: "sharepointList", Library: "sharepointLibrary", Folder: "sharepointFolder", DocumentSet: "sharepointDocumentSet", Item: "sharepointItem" }; _GetIcon = function (data) { if (data.length == 2) { var item = dataGridIcon[data[1]]; return item ? ("
") : ""; } return ""; }; _ExtendStructure = function (jsonResult) { return jsonResult.DataGridType == "WebApplication" ? jsonResult.Structure : [].concat([{ name: "", formatter: function (data) { return _GetIcon(data); }, fields: ["HasUniquePermission", "ItemType"], width: "20px" }], jsonResult.Structure); }; /* Note:SiteCollection act as SiteCollection And Site dojo.subscribe("Prefix_dataItemSelected",function(data){ //data={RibbonId1:true,RibbonId2:false,ect} }); */ PublishSelected = function () { //window.processBar.Show(true); debugger; var grid = dijit.byId(_gridId); if (window.permissionManagerLicenseInfo && window.permissionManagerLicenseInfo.IsValid) { dojo.connect(grid, "onSelectionChanged", function () { var items = this.selection.getSelected(); if (items && items.length == 0) { dojo.publish(currTabName + "_dataItemSelected", null); dojo.publish(showPermissionDetailBroardCast, null); return; } var mulSel = items.length > 1; var outPutData = {}, item; var bUnique = true, bInherited = true; if (mulSel) { for (index = 0; index < items.length; index++) { item = items[index]; bUnique = bUnique && item.HasUniquePermission; bInherited = bInherited && (!item.HasUniquePermission); if (!bUnique && !bInherited) break; }; var itemType = item.ItemType + "s", tabs; if (itemType == "Librarys") itemType = "Lists"; if (itemType == "SiteCollections") itemType = "RootWebs"; if (itemType == "Document Sets" || itemType == "DocumentSets") itemType = "Folders"; for (var big in FuncMapping) { if (big == undefined) continue; var bPermission = (item.HasUniquePermission == undefined || item.HasUniquePermission == null); for (var small in FuncMapping[big]) { if (small == undefined) continue; tabs = FuncMapping[big][small].Tab; if (!tabs) continue; dojo.forEach(tabs, function (tabName) { if (currTabName == tabName) { if (bUnique) { outPutData[FuncMapping[big][small].RefRibbonId] = FuncMapping[big][small].Type[itemType] && (bPermission ? true : FuncMapping[big][small].Permission["Unique"]); } else if (bInherited) { outPutData[FuncMapping[big][small].RefRibbonId] = FuncMapping[big][small].Type[itemType] && (bPermission ? true : FuncMapping[big][small].Permission["Inherit"]); } else { outPutData[FuncMapping[big][small].RefRibbonId] = FuncMapping[big][small].Type[itemType] && (bPermission ? true : (FuncMapping[big][small].Permission["Unique"] && FuncMapping[big][small].Permission["Inherit"])); } outPutData[FuncMapping[big][small].RefRibbonId] = outPutData[FuncMapping[big][small].RefRibbonId] || false; } }); } } } else { //Unique && Type var item = items[0], tabs; var permissionKey = item.HasUniquePermission ? "Unique" : "Inherit"; var bPermission = (item.HasUniquePermission == undefined || item.HasUniquePermission == null); var itemType = item.ItemType; if (itemType == "Library") itemType = "List"; if (itemType == "SiteCollection") itemType = "RootWeb"; if (itemType == "Document Set" || itemType == "DocumentSet") itemType = "Folder"; for (var big in FuncMapping) { if (big == undefined) continue; for (var small in FuncMapping[big]) { if (small == undefined) continue; tabs = FuncMapping[big][small].Tab; if (!tabs) continue; dojo.forEach(tabs, function (tabName) { if (currTabName == tabName) { outPutData[FuncMapping[big][small].RefRibbonId] = FuncMapping[big][small].Type[itemType] && (bPermission ? true : FuncMapping[big][small].Permission[permissionKey]); outPutData[FuncMapping[big][small].RefRibbonId] = outPutData[FuncMapping[big][small].RefRibbonId] || false; } }); } } } if (items && items.length == 1) { var toExecArgs = items[0].ItemType != "WebApplication" ? items : null; if (toExecArgs == null) { //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); dojo.publish(showPermissionDetailBroardCast, toExecArgs); } else { dojo.publish(showPermissionDetailBroardCast, toExecArgs); //window.SharePointBoostRefresh.ShowBottomRefreshButton(); } } else { //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); dojo.publish(showPermissionDetailBroardCast, null); } dojo.publish(currTabName + "_dataItemSelected", outPutData); //SharePointBoostLoading.Close(); }); } else { dojo.connect(grid, "onSelectionChanged", function () { var items = this.selection.getSelected(); if (items && items.length != 1) { //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); dojo.publish(showPermissionDetailBroardCast, null); } else { var toExecArgs = items[0].ItemType != "WebApplication" ? items : null; if (toExecArgs == null) { //window.SharePointBoostRefresh.HiddenBottomRefreshButton(); dojo.publish(showPermissionDetailBroardCast, toExecArgs); } else { dojo.publish(showPermissionDetailBroardCast, toExecArgs); //window.SharePointBoostRefresh.ShowBottomRefreshButton(); } } }); } //window.processBar.Close(); }; this.DoPublishSelected = function () { window.processBar.Show(true); var handler = dojo.subscribe(showPermissionDetailBroardCast, function () { window.processBar.Close(); }); var grid = dijit.byId(_gridId); var items = grid.selection.getSelected(); if (items && items.length != 1) { dojo.publish(showPermissionDetailBroardCast, null); } else { var toExecArgs = items[0].ItemType != "WebApplication" ? items : null; if (toExecArgs == null) { dojo.publish(showPermissionDetailBroardCast, toExecArgs); } else { dojo.publish(showPermissionDetailBroardCast, toExecArgs); } } handler.remove(); } _Init(); };