예제 #1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!TabPermissionController.CanExportPage())
            {
                Response.Redirect(Globals.AccessDeniedURL(), true);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 private bool IsPageAdmin()
 {
     return //TabPermissionController.CanAddContentToPage() ||
            (TabPermissionController.CanAddPage() ||
             TabPermissionController.CanAdminPage() ||
             TabPermissionController.CanCopyPage() ||
             TabPermissionController.CanDeletePage() ||
             TabPermissionController.CanExportPage() ||
             TabPermissionController.CanImportPage() ||
             TabPermissionController.CanManagePage());
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
 public virtual bool CanExportPage(int tabId)
 {
     return(this.CanAdminPage(tabId) || TabPermissionController.CanExportPage(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());
 }
예제 #10
0
        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);
            }
        }
예제 #11
0
        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);
        }