public static T ConvertToPageItem <T>(TabInfo tab, IEnumerable <TabInfo> portalTabs) where T : PageItem, new() { return(new T { Id = tab.TabID, Name = tab.LocalizedTabName, Url = tab.FullUrl, ChildrenCount = portalTabs?.Count(ct => ct.ParentId == tab.TabID) ?? 0, Status = GetTabStatus(tab), ParentId = tab.ParentId, Level = tab.Level, IsSpecial = TabController.IsSpecialTab(tab.TabID, PortalSettings.Current), TabPath = tab.TabPath.Replace("//", "/"), PageType = GetPageType(tab.Url), CanViewPage = TabPermissionController.CanViewPage(tab), CanManagePage = TabPermissionController.CanManagePage(tab), CanAddPage = TabPermissionController.CanAddPage(tab), CanAdminPage = TabPermissionController.CanAdminPage(tab), CanCopyPage = TabPermissionController.CanCopyPage(tab), CanDeletePage = TabPermissionController.CanDeletePage(tab), CanAddContentToPage = TabPermissionController.CanAddContentToPage(tab), CanNavigateToPage = TabPermissionController.CanNavigateToPage(tab), LastModifiedOnDate = tab.LastModifiedOnDate.ToString("MM/dd/yyyy h:mm:ss tt", CultureInfo.CreateSpecificCulture(tab.CultureCode ?? "en-US")), FriendlyLastModifiedOnDate = tab.LastModifiedOnDate.ToString("MM/dd/yyyy h:mm:ss tt"), PublishDate = tab.HasBeenPublished ? WorkflowHelper.GetTabLastPublishedOn(tab).ToString("MM/dd/yyyy h:mm:ss tt", CultureInfo.CreateSpecificCulture(tab.CultureCode ?? "en-US")) : "", PublishStatus = GetTabPublishStatus(tab), Tags = tab.Terms.Select(t => t.Name).ToArray(), TabOrder = tab.TabOrder }); }
public void DeleteTabs(IEnumerable <PageItem> tabs, StringBuilder errors, bool deleteDescendants = false) { if (tabs == null || !tabs.Any()) { return; } foreach ( var tab in tabs.OrderByDescending(t => t.Level) .Select(page => _tabController.GetTab(page.Id, PortalSettings.PortalId))) { if (tab == null) { continue; } if (TabPermissionController.CanDeletePage(tab) && tab.IsDeleted) { if (tab.HasChildren) { errors.Append(string.Format(LocalizeString("Service_RemoveTabError"), tab.TabName)); } else { HardDeleteTab(tab, deleteDescendants); } } } }
public List <TabInfo> GetDeletedTabs() { var adminTabId = PortalSettings.AdminTabId; var tabs = TabController.GetPortalTabs(PortalSettings.PortalId, adminTabId, true, true, true, true); var deletedtabs = tabs.Where(t => t.ParentId != adminTabId && t.IsDeleted && TabPermissionController.CanDeletePage(t)) .ToList(); return(deletedtabs); }
public List <TabInfo> GetDeletedTabs(out int totalRecords, int pageIndex = -1, int pageSize = -1) { var adminTabId = PortalSettings.AdminTabId; var tabs = TabController.GetPortalTabs(PortalSettings.PortalId, adminTabId, true, true, true, true); var deletedtabs = tabs.Where(t => t.ParentId != adminTabId && t.IsDeleted && TabPermissionController.CanDeletePage(t)); totalRecords = deletedtabs.Count(); return(pageIndex == -1 || pageSize == -1 ? deletedtabs.ToList() : deletedtabs.Skip(pageIndex * pageSize).Take(pageSize).ToList()); }
protected bool IsPageAdmin() { bool isPageAdmin = Null.NullBoolean; if (TabPermissionController.CanAddContentToPage() || TabPermissionController.CanAddPage() || TabPermissionController.CanAdminPage() || TabPermissionController.CanCopyPage() || TabPermissionController.CanDeletePage() || TabPermissionController.CanExportPage() || TabPermissionController.CanImportPage() || TabPermissionController.CanManagePage()) { isPageAdmin = true; } return(isPageAdmin); }
internal static bool IsPageAdminInternal() { bool _IsPageAdmin = Null.NullBoolean; if (TabPermissionController.CanAddContentToPage() || TabPermissionController.CanAddPage() || TabPermissionController.CanAdminPage() || TabPermissionController.CanCopyPage() || TabPermissionController.CanDeletePage() || TabPermissionController.CanExportPage() || TabPermissionController.CanImportPage() || TabPermissionController.CanManagePage()) { _IsPageAdmin = true; } return(_IsPageAdmin); }
private bool IsPageAdmin() { return //TabPermissionController.CanAddContentToPage() || (TabPermissionController.CanAddPage() || TabPermissionController.CanAdminPage() || TabPermissionController.CanCopyPage() || TabPermissionController.CanDeletePage() || TabPermissionController.CanExportPage() || TabPermissionController.CanImportPage() || TabPermissionController.CanManagePage()); }
public void DeletePage(PageItem page) { var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); var tab = TabController.Instance.GetTab(page.Id, portalSettings.PortalId); if (tab == null) { throw new PageNotFoundException(); } if (TabPermissionController.CanDeletePage(tab)) { TabController.Instance.SoftDeleteTab(tab.TabID, portalSettings); } }
public virtual JObject GetPagePermissions(TabInfo tab) { var permissions = new JObject { { "addContentToPage", TabPermissionController.CanAddContentToPage(tab) }, { "addPage", TabPermissionController.CanAddPage(tab) }, { "adminPage", TabPermissionController.CanAdminPage(tab) }, { "copyPage", TabPermissionController.CanCopyPage(tab) }, { "deletePage", TabPermissionController.CanDeletePage(tab) }, { "exportPage", TabPermissionController.CanExportPage(tab) }, { "importPage", TabPermissionController.CanImportPage(tab) }, { "managePage", TabPermissionController.CanManagePage(tab) } }; return(permissions); }
private void HardDeleteTab(TabInfo tab, bool deleteDescendants, StringBuilder errors) { if (TabPermissionController.CanDeletePage(tab) && tab.IsDeleted) { if (tab.HasChildren && !deleteDescendants) { errors.Append(string.Format(LocalizeString("Service_RemoveTabWithChildError"), tab.TabName)); return; } //get tab modules before deleting page var tabModules = _moduleController.GetTabModules(tab.TabID); //hard delete the tab _tabController.DeleteTab(tab.TabID, tab.PortalID, deleteDescendants); //delete modules that do not have other instances foreach (var kvp in tabModules) { //check if all modules instances have been deleted var delModule = _moduleController.GetModule(kvp.Value.ModuleID, Null.NullInteger, false); if (delModule == null || delModule.TabID == Null.NullInteger) { try { _moduleController.DeleteModule(kvp.Value.ModuleID); } catch (Exception exc) { Logger.Error(exc); } } } } else { errors.AppendFormat(!tab.IsDeleted ? LocalizeString("TabNotSoftDeleted") : LocalizeString("CanNotDeleteTab"), tab.TabID); } }
protected string BuildToolUrl(string toolName, bool isHostTool, string moduleFriendlyName, string controlKey, string navigateUrl, bool showAsPopUp) { if (isHostTool && !UserController.Instance.GetCurrentUserInfo().IsSuperUser) { return("javascript:void(0);"); } if (!string.IsNullOrEmpty(navigateUrl)) { return(navigateUrl); } string returnValue = "javascript:void(0);"; switch (toolName) { case "PageSettings": if (TabPermissionController.CanManagePage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=settingTab"); } break; case "CopyPage": if (TabPermissionController.CanCopyPage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "Tab", "action=copy&activeTab=copyTab"); } break; case "DeletePage": if (TabPermissionController.CanDeletePage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "Tab", "action=delete"); } break; case "PageTemplate": if (TabPermissionController.CanManagePage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=advancedTab"); } break; case "PageLocalization": if (TabPermissionController.CanManagePage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=localizationTab"); } break; case "PagePermission": if (TabPermissionController.CanAdminPage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=permissionsTab"); } break; case "ImportPage": if (TabPermissionController.CanImportPage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "ImportTab"); } break; case "ExportPage": if (TabPermissionController.CanExportPage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID, "ExportTab"); } break; case "NewPage": if (TabPermissionController.CanAddPage()) { returnValue = this._navigationManager.NavigateURL("Tab", "activeTab=settingTab"); } break; case "PublishPage": if (TabPermissionController.CanAdminPage()) { returnValue = this._navigationManager.NavigateURL(this.PortalSettings.ActiveTab.TabID); } break; default: if (!string.IsNullOrEmpty(moduleFriendlyName)) { var additionalParams = new List <string>(); returnValue = this.GetTabURL(additionalParams, toolName, isHostTool, moduleFriendlyName, controlKey, showAsPopUp); } break; } return(returnValue); }
protected virtual bool HasToolPermissions(string toolName) { bool isHostTool = false; if (this.ToolInfo.ToolName == toolName) { isHostTool = this.ToolInfo.IsHostTool; } else if (this.AllTools.ContainsKey(toolName)) { isHostTool = this.AllTools[toolName].IsHostTool; } if (isHostTool && !UserController.Instance.GetCurrentUserInfo().IsSuperUser) { return(false); } bool returnValue = true; switch (toolName) { case "PageSettings": case "CopyDesignToChildren": case "CopyPermissionsToChildren": returnValue = TabPermissionController.CanManagePage(); if (returnValue && toolName == "CopyPermissionsToChildren") { if (!PortalSecurity.IsInRole("Administrators")) { returnValue = false; } } break; case "CopyPage": returnValue = TabPermissionController.CanCopyPage(); break; case "DeletePage": returnValue = TabPermissionController.CanDeletePage(); break; case "ImportPage": returnValue = TabPermissionController.CanImportPage(); break; case "ExportPage": returnValue = TabPermissionController.CanExportPage(); break; case "NewPage": returnValue = TabPermissionController.CanAddPage(); break; case "Help": returnValue = !string.IsNullOrEmpty(Host.HelpURL); break; default: // if it has a module definition, look it up and check permissions // if it doesn't exist, assume no permission string friendlyName = string.Empty; if (this.ToolInfo.ToolName == toolName) { friendlyName = this.ToolInfo.ModuleFriendlyName; } else if (this.AllTools.ContainsKey(toolName)) { friendlyName = this.AllTools[toolName].ModuleFriendlyName; } if (!string.IsNullOrEmpty(friendlyName)) { returnValue = false; ModuleInfo moduleInfo; if (isHostTool) { moduleInfo = GetInstalledModule(Null.NullInteger, friendlyName); } else { moduleInfo = GetInstalledModule(PortalSettings.PortalId, friendlyName); } if (moduleInfo != null) { returnValue = ModulePermissionController.CanViewModule(moduleInfo); } } break; } return(returnValue); }
public virtual bool CanDeletePage(int tabId) { return(this.CanAdminPage(tabId) || TabPermissionController.CanDeletePage(this.GetTabById(tabId))); }
/// <summary> /// Checks if current user is page admin of the currentpage /// </summary> /// <returns>Returns true if current user has any admin permission. Otherwise returns false</returns> public static bool IsPageAdmin() { return(TabPermissionController.CanAddContentToPage() || TabPermissionController.CanAddPage() || TabPermissionController.CanAdminPage() || TabPermissionController.CanCopyPage() || TabPermissionController.CanDeletePage() || TabPermissionController.CanExportPage() || TabPermissionController.CanImportPage() || TabPermissionController.CanManagePage()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); imgAddModule.Click += imgAddModule_Click; optMode.SelectedIndexChanged += optMode_SelectedIndexChanged; optModuleType.SelectedIndexChanged += optModuleType_SelectedIndexChanged; cboTabs.SelectedIndexChanged += cboTabs_SelectedIndexChanged; cmdVisibility.Click += cmdVisibility_Click; cboPanes.SelectedIndexChanged += cboPanes_SelectedIndexChanged; cboPosition.SelectedIndexChanged += cboPosition_SelectedIndexChanged; imgAdmin.Click += imgAdmin_Click; cmdAdmin.Click += cmdAdmin_Click; imgHost.Click += imgHost_Click; cmdHost.Click += cmdHost_Click; cmdAddModule.Click += AddModule_Click; cmdAddTab.Click += PageFunctions_Click; cmdAddTabIcon.Click += PageFunctions_Click; cmdEditTab.Click += PageFunctions_Click; cmdEditTabIcon.Click += PageFunctions_Click; cmdDeleteTab.Click += PageFunctions_Click; cmdDeleteTabIcon.Click += PageFunctions_Click; cmdCopyTab.Click += PageFunctions_Click; cmdCopyTabIcon.Click += PageFunctions_Click; cmdExportTab.Click += PageFunctions_Click; cmdExportTabIcon.Click += PageFunctions_Click; cmdImportTab.Click += PageFunctions_Click; cmdImportTabIcon.Click += PageFunctions_Click; cmdExtensions.Click += CommonTasks_Click; cmdExtensionsIcon.Click += CommonTasks_Click; cmdFiles.Click += CommonTasks_Click; cmdFilesIcon.Click += CommonTasks_Click; cmdRoles.Click += CommonTasks_Click; cmdRolesIcon.Click += CommonTasks_Click; cmdSite.Click += CommonTasks_Click; cmdSiteIcon.Click += CommonTasks_Click; cmdUsers.Click += CommonTasks_Click; cmdUsersIcon.Click += CommonTasks_Click; try { if (IsPageAdmin()) { tblControlPanel.Visible = true; cmdVisibility.Visible = true; rowControlPanel.Visible = true; Localize(); if (Globals.IsAdminControl()) { cmdAddModule.Enabled = false; } if (!Page.IsPostBack) { optModuleType.Items.FindByValue("0").Selected = true; if (!TabPermissionController.CanAddPage()) { DisableAction(imgAddTabIcon, "iconbar_addtab_bw.gif", cmdAddTabIcon, cmdAddTab); } if (!TabPermissionController.CanManagePage()) { DisableAction(imgEditTabIcon, "iconbar_edittab_bw.gif", cmdEditTabIcon, cmdEditTab); } if (!TabPermissionController.CanDeletePage() || TabController.IsSpecialTab(TabController.CurrentPage.TabID, PortalSettings)) { DisableAction(imgDeleteTabIcon, "iconbar_deletetab_bw.gif", cmdDeleteTabIcon, cmdDeleteTab); } else { ClientAPI.AddButtonConfirm(cmdDeleteTab, Localization.GetString("DeleteTabConfirm", LocalResourceFile)); ClientAPI.AddButtonConfirm(cmdDeleteTabIcon, Localization.GetString("DeleteTabConfirm", LocalResourceFile)); } if (!TabPermissionController.CanCopyPage()) { DisableAction(imgCopyTabIcon, "iconbar_copytab_bw.gif", cmdCopyTabIcon, cmdCopyTab); } if (!TabPermissionController.CanExportPage()) { DisableAction(imgExportTabIcon, "iconbar_exporttab_bw.gif", cmdExportTabIcon, cmdExportTab); } if (!TabPermissionController.CanImportPage()) { DisableAction(imgImportTabIcon, "iconbar_importtab_bw.gif", cmdImportTabIcon, cmdImportTab); } if (!TabPermissionController.CanAddContentToPage()) { pnlModules.Visible = false; } if (!GetModulePermission(PortalSettings.PortalId, "Site Settings")) { DisableAction(imgSiteIcon, "iconbar_site_bw.gif", cmdSiteIcon, cmdSite); } if (GetModulePermission(PortalSettings.PortalId, "User Accounts") == false) { DisableAction(imgUsersIcon, "iconbar_users_bw.gif", cmdUsersIcon, cmdUsers); } if (GetModulePermission(PortalSettings.PortalId, "Security Roles") == false) { DisableAction(imgRolesIcon, "iconbar_roles_bw.gif", cmdRolesIcon, cmdRoles); } if (GetModulePermission(PortalSettings.PortalId, "Digital Asset Management") == false) { DisableAction(imgFilesIcon, "iconbar_files_bw.gif", cmdFilesIcon, cmdFiles); } if (GetModulePermission(PortalSettings.PortalId, "Extensions") == false) { DisableAction(imgExtensionsIcon, "iconbar_extensions_bw.gif", cmdExtensionsIcon, cmdExtensions); } UserInfo objUser = UserController.GetCurrentUserInfo(); if (objUser != null) { if (objUser.IsSuperUser) { hypMessage.ImageUrl = Upgrade.UpgradeIndicator(DotNetNukeContext.Current.Application.Version, Request.IsLocal, Request.IsSecureConnection); if (!String.IsNullOrEmpty(hypMessage.ImageUrl)) { hypMessage.ToolTip = Localization.GetString("hypUpgrade.Text", LocalResourceFile); hypMessage.NavigateUrl = Upgrade.UpgradeRedirect(); } cmdHost.Visible = true; } else //branding { if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) && Host.DisplayCopyright) { hypMessage.ImageUrl = "~/images/branding/iconbar_logo.png"; hypMessage.ToolTip = DotNetNukeContext.Current.Application.Description; hypMessage.NavigateUrl = Localization.GetString("hypMessageUrl.Text", LocalResourceFile); } else { hypMessage.Visible = false; } cmdHost.Visible = false; cmdAdmin.Visible = GetModulePermission(PortalSettings.PortalId, "Console"); } imgHost.Visible = cmdHost.Visible; imgAdmin.Visible = cmdAdmin.Visible; } BindData(); int intItem; for (intItem = 0; intItem <= PortalSettings.ActiveTab.Panes.Count - 1; intItem++) { cboPanes.Items.Add(Convert.ToString(PortalSettings.ActiveTab.Panes[intItem])); } if (cboPanes.Items.FindByValue(Globals.glbDefaultPane) != null) { cboPanes.Items.FindByValue(Globals.glbDefaultPane).Selected = true; } if (cboPermission.Items.Count > 0) { cboPermission.SelectedIndex = 0; //view } LoadPositions(); if (!string.IsNullOrEmpty(Host.HelpURL)) { var version = Globals.FormatVersion(DotNetNukeContext.Current.Application.Version, false); cmdHelp.NavigateUrl = Globals.FormatHelpUrl(Host.HelpURL, PortalSettings, version); cmdHelpIcon.NavigateUrl = cmdHelp.NavigateUrl; cmdHelp.Enabled = true; cmdHelpIcon.Enabled = true; } else { cmdHelp.Enabled = false; cmdHelpIcon.Enabled = false; } SetMode(false); SetVisibility(false); } //Register jQuery jQuery.RequestRegistration(); } else if (IsModuleAdmin()) { tblControlPanel.Visible = true; cmdVisibility.Visible = false; rowControlPanel.Visible = false; if (!Page.IsPostBack) { SetMode(false); SetVisibility(false); } } else { tblControlPanel.Visible = false; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected string BuildToolUrl(string toolName, bool isHostTool, string moduleFriendlyName, string controlKey, string navigateUrl, bool showAsPopUp) { if ((isHostTool && !UserController.GetCurrentUserInfo().IsSuperUser)) { return("javascript:void(0);"); } if ((!string.IsNullOrEmpty(navigateUrl))) { return(navigateUrl); } string returnValue = "javascript:void(0);"; switch (toolName) { case "PageSettings": if (TabPermissionController.CanManagePage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=settingTab"); } break; case "CopyPage": if (TabPermissionController.CanCopyPage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Tab", "action=copy&activeTab=copyTab"); } break; case "DeletePage": if (TabPermissionController.CanDeletePage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Tab", "action=delete"); } break; case "PageTemplate": if (TabPermissionController.CanManagePage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=advancedTab"); } break; case "PagePermission": if (TabPermissionController.CanAdminPage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Tab", "action=edit&activeTab=permissionsTab"); } break; case "ImportPage": if (TabPermissionController.CanImportPage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "ImportTab"); } break; case "ExportPage": if (TabPermissionController.CanExportPage()) { returnValue = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "ExportTab"); } break; case "NewPage": if (DotNetNuke.Security.Permissions.TabPermissionController.CanAddPage()) { returnValue = Globals.NavigateURL("Tab", "activeTab=settingTab"); } break; default: if ((!string.IsNullOrEmpty(moduleFriendlyName))) { var additionalParams = new List <string>(); if ((toolName == "UploadFile" || toolName == "HostUploadFile")) { additionalParams.Add("ftype=File"); additionalParams.Add("rtab=" + PortalSettings.ActiveTab.TabID); } returnValue = GetTabURL(additionalParams, toolName, isHostTool, moduleFriendlyName, controlKey, showAsPopUp); } break; } return(returnValue); }