Exemplo n.º 1
0
        protected void CtlPagesContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            SelectedNode = e.Node.Value;

            var objTabController = new TabController();
            var portalId = rblMode.SelectedValue == "H" ? Null.NullInteger : PortalId;
            var objTab = objTabController.GetTab(int.Parse(e.Node.Value), portalId, false);

            switch (e.MenuItem.Value.ToLower())
            {
                case "makehome":
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        var portalController = new PortalController();
                        PortalInfo portalInfo = portalController.GetPortal(PortalId);
                        portalInfo.HomeTabId = objTab.TabID;
                        PortalSettings.HomeTabId = objTab.TabID;
                        portalController.UpdatePortalInfo(portalInfo);
                        DataCache.ClearPortalCache(PortalId, false);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabMadeHome", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "view":
                    Response.Redirect(objTab.FullUrl);
                    break;
                case "edit":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        var editUrl = Globals.NavigateURL(objTab.TabID, "Tab", "action=edit", "returntabid=" + TabId);
                        // Prevent PageSettings of the current page in a popup if SSL is enabled and enforced, which causes redirection/javascript broswer security issues.
                        if (PortalSettings.EnablePopUps && !(objTab.TabID == TabId && (PortalSettings.SSLEnabled && PortalSettings.SSLEnforced)))
                        {
                            editUrl = UrlUtils.PopUpUrl(editUrl, this, PortalSettings, true, false);
                            var script = string.Format("<script type=\"text/javascript\">{0}</script>", editUrl);
                            ClientAPI.RegisterStartUpScript(this.Page, "EditInPopup", script);
                        }
                        else
                        {
                            Response.Redirect(editUrl, true);
                        }
                    }
                    break;
                case "delete":
                    if (TabPermissionController.CanDeletePage(objTab))
                    {
                        TabController.DeleteTab(objTab.TabID, PortalSettings, UserId);
                        BindTree();
                        //keep the parent tab selected
                        if (objTab.ParentId != Null.NullInteger)
                        {
                            SelectedNode = objTab.ParentId.ToString();
                            ctlPages.FindNodeByValue(SelectedNode).Selected = true;
                            ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes();
                            BindTab(objTab.ParentId);
                        }
                        else
                        {
                            pnlDetails.Visible = false;
                        }
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDeleted", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "moveup":
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        objTabController.MoveTab(objTab, TabMoveType.Up);
                        BindTree();
                    }
                    break;
                case "movedown":
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        objTabController.MoveTab(objTab, TabMoveType.Down);
                        BindTree();
                    }
                    break;
                case "add":
                    if ((objTab!= null && TabPermissionController.CanAddPage(objTab)) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)))
                    {
                        pnlBulk.Visible = true;
                        btnBulkCreate.CommandArgument = e.Node.Value;
                        ctlPages.FindNodeByValue(e.Node.Value).Selected = true;
                        txtBulk.Focus();
                        pnlDetails.Visible = false;
                        //Response.Redirect(NavigateURL(objTab.TabID, "Tab", "action=add", "returntabid=" & TabId.ToString), True)
                    }
                    break;
                case "hide":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = false;
                        objTabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabHidden", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "show":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = true;
                        objTabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabShown", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "disable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = true;
                        objTabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDisabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "enable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = false;
                        objTabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabEnabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
            }
        }