Exemplo n.º 1
0
        public TabDto GetPortalTabs(UserInfo userInfo, int portalId, string cultureCode, bool isMultiLanguage, bool excludeAdminTabs = true,
                                    string roles      = "", bool disabledNotSelectable = false, int sortOrder      = 0,
                                    int selectedTabId = -1, string validateTab         = "", bool includeHostPages = false, bool includeDisabled = false, bool includeDeleted = false, bool includeDeletedChildren = true)
        {
            var portalInfo = PortalController.Instance.GetPortal(portalId);

            var rootNode = new TabDto
            {
                Name        = portalInfo.PortalName,
                ImageUrl    = IconPortal,
                TabId       = Null.NullInteger.ToString(CultureInfo.InvariantCulture),
                ChildTabs   = new List <TabDto>(),
                HasChildren = true
            };
            var tabs = new List <TabInfo>();

            cultureCode = string.IsNullOrEmpty(cultureCode) ? portalInfo.CultureCode : cultureCode;
            if (portalId > -1)
            {
                tabs =
                    TabController.GetPortalTabs(
                        isMultiLanguage
                            ? TabController.GetTabsBySortOrder(portalId, portalInfo.DefaultLanguage, true)
                            : TabController.GetTabsBySortOrder(portalId, cultureCode, true), Null.NullInteger, false,
                        "<" + Localization.GetString("None_Specified") + ">", true, includeDeleted, true, false, false, includeDeletedChildren)
                    .Where(t => (!t.DisableLink || includeDisabled) && !t.IsSystem)
                    .ToList();

                if (userInfo.IsSuperUser && includeHostPages)
                {
                    tabs.AddRange(
                        TabController.Instance.GetTabsByPortal(-1)
                        .AsList()
                        .Where(t => !t.IsDeleted && !t.DisableLink && !t.IsSystem)
                        .ToList());
                }
            }
            else
            {
                if (userInfo.IsSuperUser)
                {
                    tabs = TabController.Instance.GetTabsByPortal(-1).AsList().Where(t => !t.IsDeleted && !t.DisableLink && !t.IsSystem).ToList();
                }
            }

            tabs = excludeAdminTabs
                ? tabs.Where(tab => tab.Level == 0 && tab.TabID != portalInfo.AdminTabId).ToList()
                : tabs.Where(tab => tab.Level == 0).ToList();

            if (!string.IsNullOrEmpty(validateTab))
            {
                tabs = ValidateModuleInTab(tabs, validateTab).ToList();
            }
            var filterTabs = FilterTabsByRole(tabs, roles, disabledNotSelectable);

            rootNode.HasChildren = tabs.Count > 0;
            rootNode.Selectable  = SecurityService.Instance.IsPagesAdminUser();
            foreach (var tab in tabs)
            {
                string tooltip;
                var    nodeIcon = GetNodeIcon(tab, out tooltip);
                var    node     = new TabDto
                {
                    Name        = tab.LocalizedTabName, //$"{tab.TabName} {GetNodeStatusIcon(tab)}",
                    TabId       = tab.TabID.ToString(CultureInfo.InvariantCulture),
                    ImageUrl    = nodeIcon,
                    Tooltip     = tooltip,
                    ParentTabId = tab.ParentId,
                    HasChildren = tab.HasChildren,
                    Selectable  = filterTabs.Contains(tab.TabID) && TabPermissionController.CanAddPage(tab),
                    ChildTabs   = new List <TabDto>()
                };
                rootNode.ChildTabs.Add(node);
            }
            rootNode.ChildTabs = ApplySort(rootNode.ChildTabs, sortOrder).ToList();

            return(selectedTabId > -1
                ? MarkSelectedTab(rootNode, selectedTabId, portalInfo, cultureCode, isMultiLanguage, validateTab)
                : rootNode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update LinkButton is clicked.
        /// It saves the current Site Settings
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	10/18/2004	documented
        ///     [cnurse]	10/19/2004	modified to support custm module specific settings
        /// </history>
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    var objModules        = new ModuleController();
                    var allTabsChanged    = false;
                    var searchOnceChanged = false;

                    //tab administrators can only manage their own tab
                    if (!TabPermissionController.CanAdminPage())
                    {
                        chkAllTabs.Enabled    = false;
                        chkNewTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllModules.Enabled = false;
                        chkSearchOnce.Enabled = false;
                        cboTab.Enabled        = false;
                    }
                    Module.ModuleID    = _moduleId;
                    Module.ModuleTitle = txtTitle.Text;
                    Module.Alignment   = cboAlign.SelectedItem.Value;
                    Module.Color       = txtColor.Text;
                    Module.Border      = txtBorder.Text;
                    Module.IconFile    = ctlIcon.Url;
                    if (!String.IsNullOrEmpty(txtCacheDuration.Text))
                    {
                        Module.CacheTime = Int32.Parse(txtCacheDuration.Text);
                    }
                    else
                    {
                        Module.CacheTime = 0;
                    }
                    Module.CacheMethod = cboCacheProvider.SelectedValue;
                    Module.TabID       = TabId;
                    if (Module.AllTabs != chkAllTabs.Checked)
                    {
                        allTabsChanged = true;
                    }
                    Module.AllTabs = chkAllTabs.Checked;
                    objModules.UpdateTabModuleSetting(Module.TabModuleID, "hideadminborder", chkAdminBorder.Checked.ToString());

                    //check whether searchonce value is changed
                    var searchOnce = Settings.ContainsKey("searchonce") ? Convert.ToBoolean(Settings["searchonce"]) : false;
                    if (searchOnce != chkSearchOnce.Checked)
                    {
                        searchOnceChanged = true;
                    }
                    objModules.UpdateTabModuleSetting(Module.TabModuleID, "searchonce", chkSearchOnce.Checked.ToString());
                    switch (Int32.Parse(cboVisibility.SelectedItem.Value))
                    {
                    case 0:
                        Module.Visibility = VisibilityState.Maximized;
                        break;

                    case 1:
                        Module.Visibility = VisibilityState.Minimized;
                        break;

                    case 2:
                        Module.Visibility = VisibilityState.None;
                        break;
                    }
                    Module.IsDeleted = false;
                    Module.Header    = txtHeader.Text;
                    Module.Footer    = txtFooter.Text;

                    if (startDatePicker.SelectedDate != null)
                    {
                        Module.StartDate = startDatePicker.SelectedDate.Value;
                    }
                    else
                    {
                        Module.StartDate = Null.NullDate;
                    }

                    if (endDatePicker.SelectedDate != null)
                    {
                        Module.EndDate = endDatePicker.SelectedDate.Value;
                    }
                    else
                    {
                        Module.EndDate = Null.NullDate;
                    }

                    Module.ContainerSrc = moduleContainerCombo.SelectedValue;
                    Module.ModulePermissions.Clear();
                    Module.ModulePermissions.AddRange(dgPermissions.Permissions);
                    Module.Terms.Clear();
                    Module.Terms.AddRange(termsSelector.Terms);
                    Module.InheritViewPermissions = chkInheritPermissions.Checked;
                    Module.DisplayTitle           = chkDisplayTitle.Checked;
                    Module.DisplayPrint           = chkDisplayPrint.Checked;
                    Module.DisplaySyndicate       = chkDisplaySyndicate.Checked;
                    Module.IsWebSlice             = chkWebSlice.Checked;
                    Module.WebSliceTitle          = txtWebSliceTitle.Text;

                    if (diWebSliceExpiry.SelectedDate != null)
                    {
                        Module.WebSliceExpiryDate = diWebSliceExpiry.SelectedDate.Value;
                    }
                    else
                    {
                        Module.WebSliceExpiryDate = Null.NullDate;
                    }

                    if (!string.IsNullOrEmpty(txtWebSliceTTL.Text))
                    {
                        Module.WebSliceTTL = Convert.ToInt32(txtWebSliceTTL.Text);
                    }
                    Module.IsDefaultModule = chkDefault.Checked;
                    Module.AllModules      = chkAllModules.Checked;
                    objModules.UpdateModule(Module);

                    //Update Custom Settings
                    if (SettingsControl != null)
                    {
                        try
                        {
                            SettingsControl.UpdateSettings();
                        }
                        catch (ThreadAbortException exc)
                        {
                            DnnLog.Debug(exc);

                            Thread.ResetAbort(); //necessary
                        }
                        catch (Exception ex)
                        {
                            Exceptions.LogException(ex);
                        }
                    }

                    //These Module Copy/Move statements must be
                    //at the end of the Update as the Controller code assumes all the
                    //Updates to the Module have been carried out.

                    //Check if the Module is to be Moved to a new Tab
                    if (!chkAllTabs.Checked)
                    {
                        var newTabId = Int32.Parse(cboTab.SelectedItem.Value);
                        if (TabId != newTabId)
                        {
                            //First check if there already is an instance of the module on the target page
                            var tmpModule = objModules.GetModule(_moduleId, newTabId);
                            if (tmpModule == null)
                            {
                                //Move module
                                objModules.MoveModule(_moduleId, TabId, newTabId, Globals.glbDefaultPane);
                            }
                            else
                            {
                                //Warn user
                                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ModuleExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                                return;
                            }
                        }
                    }

                    //Check if Module is to be Added/Removed from all Tabs
                    if (allTabsChanged)
                    {
                        var listTabs = TabController.GetPortalTabs(PortalSettings.PortalId, Null.NullInteger, false, true);
                        if (chkAllTabs.Checked)
                        {
                            if (!chkNewTabs.Checked)
                            {
                                foreach (var destinationTab in listTabs)
                                {
                                    var module = objModules.GetModule(_moduleId, destinationTab.TabID);
                                    if (module != null)
                                    {
                                        if (module.IsDeleted)
                                        {
                                            objModules.RestoreModule(module);
                                        }
                                    }
                                    else
                                    {
                                        objModules.CopyModule(Module, destinationTab, Module.PaneName, true);
                                    }
                                }
                            }
                        }
                        else
                        {
                            objModules.DeleteAllModules(_moduleId, TabId, listTabs);
                        }
                    }

                    //if searchonce is changed, then should update all other tabmodules to update the setting value.
                    if (searchOnceChanged)
                    {
                        objModules.GetAllTabsModulesByModuleID(_moduleId)
                        .Cast <ModuleInfo>()
                        .Where(t => t.TabID != TabId)
                        .ToList()
                        .ForEach(tm =>
                        {
                            if (chkSearchOnce.Checked)
                            {
                                objModules.UpdateTabModuleSetting(tm.TabModuleID, "DisableSearch", "true");
                            }
                            else
                            {
                                objModules.DeleteTabModuleSetting(tm.TabModuleID, "DisableSearch");
                            }
                        });
                    }

                    //Navigate back to admin page
                    Response.Redirect(Globals.NavigateURL(), true);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 3
0
        public override void LoadSettings()
        {
            try
            {
                if (Page.IsPostBack == false)
                {
                    var portalTabs = TabController.GetPortalTabs(PortalId, Null.NullInteger, false, true);

                    //Add host tabs
                    if (UserInfo != null && UserInfo.IsSuperUser)
                    {
                        var hostTabs = new TabController().GetTabsByPortal(Null.NullInteger);
                        portalTabs.AddRange(hostTabs.Values);
                    }
                    ParentTab.Items.Clear();
                    foreach (var t in portalTabs)
                    {
                        if ((TabPermissionController.CanViewPage(t)))
                        {
                            ParentTab.AddItem(t.IndentedTabName, t.TabID.ToString(CultureInfo.InvariantCulture));
                            //ParentTab.Items.Add(new ListItem(t.IndentedTabName, t.TabID.ToString(CultureInfo.InvariantCulture)));
                        }
                    }
                    //ParentTab.Items.Insert(0, "");
                    ParentTab.InsertItem(0, "", "");
                    SelectDropDownListItem(ref ParentTab, "ParentTabID");
                    foreach (string val in ConsoleController.GetSizeValues())
                    {
                        //DefaultSize.Items.Add(new ListItem(Localization.GetString(val, LocalResourceFile), val));
                        DefaultSize.AddItem(Localization.GetString(val, LocalResourceFile), val);
                    }
                    SelectDropDownListItem(ref DefaultSize, "DefaultSize");

                    SelectDropDownListItem(ref modeList, "Mode");

                    if (Settings.ContainsKey("AllowSizeChange"))
                    {
                        AllowResize.Checked = Convert.ToBoolean(Settings["AllowSizeChange"]);
                    }
                    foreach (var val in ConsoleController.GetViewValues())
                    {
                        //DefaultView.Items.Add(new ListItem(Localization.GetString(val, LocalResourceFile), val));
                        DefaultView.AddItem(Localization.GetString(val, LocalResourceFile), val);
                    }
                    SelectDropDownListItem(ref DefaultView, "DefaultView");
                    if (Settings.ContainsKey("IncludeParent"))
                    {
                        IncludeParent.Checked = Convert.ToBoolean(Settings["IncludeParent"]);
                    }
                    if (Settings.ContainsKey("AllowViewChange"))
                    {
                        AllowViewChange.Checked = Convert.ToBoolean(Settings["AllowViewChange"]);
                    }
                    if (Settings.ContainsKey("ShowTooltip"))
                    {
                        ShowTooltip.Checked = Convert.ToBoolean(Settings["ShowTooltip"]);
                    }
                    if (Settings.ContainsKey("OrderTabsByHierarchy"))
                    {
                        OrderTabsByHierarchy.Checked = Convert.ToBoolean(Settings["OrderTabsByHierarchy"]);
                    }
                    if (Settings.ContainsKey("ConsoleWidth"))
                    {
                        ConsoleWidth.Text = Convert.ToString(Settings["ConsoleWidth"]);
                    }

                    SwitchMode();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 4
0
    protected void LoadMenu(int ParentID, bool SubPages, bool ShowHidden)
    {
        try
        {
            string DefaultLocale = LC.GetDefaultLocale(PortalSettings.PortalId).Code.Substring(0, 2);

            //Menu options
            string currentitems = "";
            int    tabLevel     = TC.GetTab(ParentID, PortalSettings.PortalId).Level + 1;

            //Get list of pages

            foreach (TabInfo T in TabController.GetPortalTabs(PortalSettings.PortalId, -1, false, "", true, false, true, true, true))
            {
                Boolean usePage = false;
                if (ParentID == T.ParentId)
                {
                    usePage = true;
                }
                if (SubPages && (tabLevel + 1 == T.Level))
                {
                    if (TC.GetTab(TC.GetTab(T.TabID, PortalSettings.PortalId).ParentId, PortalSettings.PortalId).ParentId == ParentID)
                    {
                        usePage = true;
                    }
                }
                if (usePage)
                {
                    if (T.IsVisible || ShowHidden)
                    {
                        string link  = T.FullUrl;
                        string title = T.TabName;

                        if (DefaultLocale != ThisLocale)
                        {
                            Hashtable hash = TC.GetTabSettings(T.TabID);
                            if (hash["PageTitle" + ThisLocale] != null)
                            {
                                title = hash["PageTitle" + ThisLocale].ToString();
                            }
                        }

                        if (T.TabID == PortalSettings.ActiveTab.TabID)
                        {
                            currentitems += "<li class='active'><a href=\"" + link + "\">" + title + "</a></li>";
                        }
                        else
                        {
                            if (CheckSubPages(T.TabID) && T.Level == tabLevel)
                            {
                                currentitems += "<li class='bg-info'><a href=\"" + link + "\">" + title + "</a></li>";
                            }
                            else
                            {
                                currentitems += "<li><a href=\"" + link + "\">" + title + "</a></li>";
                            }
                        }
                    }
                }
            }

            ltlMenu.Text = currentitems;
        }
        catch (Exception ex)
        {
            if (PortalSettings.UserInfo.IsSuperUser)
            {
                ltlMenu.Text = ex.Message;
            }
            Exceptions.LogException(ex);
        }
    }
Exemplo n.º 5
0
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	10/18/2004	documented
        ///     [cnurse]	10/19/2004	modified to support custm module specific settings
        ///     [vmasanas]  11/28/2004  modified to support modules in admin tabs
        /// </history>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            chkAllTabs.CheckedChanged            += OnAllTabsCheckChanged;
            chkInheritPermissions.CheckedChanged += OnInheritPermissionsChanged;
            chkWebSlice.CheckedChanged           += OnWebSliceCheckChanged;
            cboCacheProvider.TextChanged         += OnCacheProviderIndexChanged;
            cmdDelete.Click         += OnDeleteClick;
            cmdUpdate.Click         += OnUpdateClick;
            dgOnTabs.NeedDataSource += OnPagesGridNeedDataSource;

            try
            {
                cancelHyperLink.NavigateUrl = Globals.NavigateURL();

                if (_moduleId != -1)
                {
                    ctlAudit.Entity = Module;
                }
                if (Page.IsPostBack == false)
                {
                    ctlIcon.FileFilter = Globals.glbImageFileTypes;

                    dgPermissions.TabId    = PortalSettings.ActiveTab.TabID;
                    dgPermissions.ModuleID = _moduleId;


                    cboTab.DataSource = TabController.GetPortalTabs(PortalId, -1, false, Null.NullString, true, false, true, false, true);
                    cboTab.DataBind();

                    //if tab is a  host tab, then add current tab
                    if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        cboTab.Items.Insert(0, new ListItem(PortalSettings.ActiveTab.LocalizedTabName, PortalSettings.ActiveTab.TabID.ToString()));
                    }
                    if (Module != null)
                    {
                        //parent tab might not be loaded in cbotab if user does not have edit rights on it
                        if (cboTab.Items.FindByValue(Module.TabID.ToString()) == null)
                        {
                            var objtabs = new TabController();
                            var objTab  = objtabs.GetTab(Module.TabID, Module.PortalID, false);
                            cboTab.Items.Add(new ListItem(objTab.LocalizedTabName, objTab.TabID.ToString()));
                        }
                    }

                    //only Portal Administrators can manage the visibility on all Tabs
                    rowAllTabs.Visible = PortalSecurity.IsInRole("Administrators");

                    //tab administrators can only manage their own tab
                    if (!TabPermissionController.CanAdminPage())
                    {
                        chkNewTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllModules.Enabled = false;
                        chkSearchOnce.Enabled = false;
                        cboTab.Enabled        = false;
                    }
                    if (_moduleId != -1)
                    {
                        BindData();
                        cmdDelete.Visible = ModulePermissionController.CanDeleteModule(Module) || TabPermissionController.CanAddContentToPage();
                    }
                    else
                    {
                        cboVisibility.SelectedIndex = 0; //maximized
                        chkAllTabs.Checked          = false;
                        chkSearchOnce.Checked       = false;
                        cmdDelete.Visible           = false;
                    }
                    cmdUpdate.Visible      = ModulePermissionController.HasModulePermission(Module.ModulePermissions, "EDIT,MANAGE") || TabPermissionController.CanAddContentToPage();
                    permissionsRow.Visible = ModulePermissionController.CanAdminModule(Module) || TabPermissionController.CanAddContentToPage();

                    //Set visibility of Specific Settings
                    if (SettingsControl == null == false)
                    {
                        //Get the module settings from the PortalSettings and pass the
                        //two settings hashtables to the sub control to process
                        SettingsControl.LoadSettings();
                        specificSettingsTab.Visible = true;
                        fsSpecific.Visible          = true;
                    }
                    else
                    {
                        specificSettingsTab.Visible = false;
                        fsSpecific.Visible          = false;
                    }

                    termsSelector.PortalId = Module.PortalID;
                    termsSelector.Terms    = Module.Terms;
                    termsSelector.DataBind();
                }
                cultureLanguageLabel.Language = Module.CultureCode;
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 6
0
 public DnnFormPagesItem()
 {
     this.ListSource     = TabController.GetPortalTabs(this.PortalSettings.PortalId, Null.NullInteger, true, "<" + Localization.GetString("None_Specified") + ">", true, false, true, true, false);
     this.ListTextField  = "TabName";
     this.ListValueField = "TabID";
 }
Exemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                cancelHyperLink.NavigateUrl = ReturnURL;

                if (_moduleId != -1)
                {
                    ctlAudit.Entity = Module;
                }
                if (Page.IsPostBack == false)
                {
                    ctlIcon.FileFilter = Globals.glbImageFileTypes;

                    dgPermissions.TabId    = PortalSettings.ActiveTab.TabID;
                    dgPermissions.ModuleID = _moduleId;

                    cboTab.DataSource = TabController.GetPortalTabs(PortalId, -1, false, Null.NullString, true, false, true, false, true);
                    cboTab.DataBind();

                    //if tab is a  host tab, then add current tab
                    if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        cboTab.InsertItem(0, PortalSettings.ActiveTab.LocalizedTabName, PortalSettings.ActiveTab.TabID.ToString());
                    }
                    if (Module != null)
                    {
                        if (cboTab.FindItemByValue(Module.TabID.ToString()) == null)
                        {
                            var objTab = TabController.Instance.GetTab(Module.TabID, Module.PortalID, false);
                            cboTab.AddItem(objTab.LocalizedTabName, objTab.TabID.ToString());
                        }
                    }

                    //only Portal Administrators can manage the visibility on all Tabs
                    var isAdmin = PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName);
                    rowAllTabs.Visible    = isAdmin;
                    chkAllModules.Enabled = isAdmin;

                    if (HideCancelButton)
                    {
                        cancelHyperLink.Visible = false;
                    }

                    //tab administrators can only manage their own tab
                    if (!TabPermissionController.CanAdminPage())
                    {
                        chkNewTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllowIndex.Enabled = false;
                        cboTab.Enabled        = false;
                    }

                    if (_moduleId != -1)
                    {
                        BindData();
                        cmdDelete.Visible = (ModulePermissionController.CanDeleteModule(Module) ||
                                             TabPermissionController.CanAddContentToPage()) && !HideDeleteButton;
                    }
                    else
                    {
                        isShareableCheckBox.Checked         = true;
                        isShareableViewOnlyCheckBox.Checked = true;
                        isShareableRow.Visible = true;

                        cboVisibility.SelectedIndex = 0; //maximized
                        chkAllTabs.Checked          = false;
                        cmdDelete.Visible           = false;
                    }
                    if (Module != null)
                    {
                        cmdUpdate.Visible      = ModulePermissionController.HasModulePermission(Module.ModulePermissions, "EDIT,MANAGE") || TabPermissionController.CanAddContentToPage();
                        permissionsRow.Visible = ModulePermissionController.CanAdminModule(Module) || TabPermissionController.CanAddContentToPage();
                    }

                    //Set visibility of Specific Settings
                    if (SettingsControl == null == false)
                    {
                        //Get the module settings from the PortalSettings and pass the
                        //two settings hashtables to the sub control to process
                        SettingsControl.LoadSettings();
                        specificSettingsTab.Visible = true;
                        fsSpecific.Visible          = true;
                    }
                    else
                    {
                        specificSettingsTab.Visible = false;
                        fsSpecific.Visible          = false;
                    }

                    if (Module != null)
                    {
                        termsSelector.PortalId = Module.PortalID;
                        termsSelector.Terms    = Module.Terms;
                    }
                    termsSelector.DataBind();
                }
                if (Module != null)
                {
                    cultureLanguageLabel.Language = Module.CultureCode;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        public static void UpdateModule(ModuleInfo moduleinfo, dynamic Data)
        {
            moduleinfo.InheritViewPermissions = bool.Parse(Data.PermissionsInherit.ToString());
            List <ModulePermissionInfo> ModulePerInfo = new List <ModulePermissionInfo>();

            moduleinfo.ModulePermissions.Clear();
            foreach (dynamic item in Data.PermissionsRoles)
            {
                foreach (dynamic p in item.Permissions)
                {
                    bool   AllowAcess   = bool.Parse(p.AllowAccess.ToString());
                    string PermissionID = p.PermissionId.ToString();
                    if (AllowAcess)
                    {
                        moduleinfo.ModulePermissions.Add(new ModulePermissionInfo {
                            AllowAccess = AllowAcess, RoleID = int.Parse(item.RoleId.ToString()), PermissionID = int.Parse(PermissionID)
                        });
                    }
                }
            }

            foreach (dynamic item in Data.PermissionsUsers)
            {
                foreach (dynamic p in item.Permissions)
                {
                    bool   AllowAcess   = bool.Parse(p.AllowAccess.ToString());
                    string PermissionID = p.PermissionId.ToString();
                    if (AllowAcess)
                    {
                        moduleinfo.ModulePermissions.Add(new ModulePermissionInfo {
                            AllowAccess = AllowAcess, UserID = int.Parse(item.UserId.ToString()), PermissionID = int.Parse(PermissionID)
                        });
                    }
                }
            }
            bool allTabsChanged = false;

            moduleinfo.StartDate = Data.StartDate == "" ? Null.NullDate : Data.StartDate;
            moduleinfo.EndDate   = Data.EndDate == "" ? Null.NullDate : Data.EndDate;
            if (moduleinfo.AllTabs != Data.chkAllTabs.Value)
            {
                allTabsChanged = true;
            }
            moduleinfo.AllTabs = Data.chkAllTabs.Value;
            ModuleController.Instance.UpdateModule(moduleinfo);
            if (allTabsChanged)
            {
                List <TabInfo> listTabs = TabController.GetPortalTabs(moduleinfo.PortalID, Null.NullInteger, false, true);
                if (Data.chkAllTabs.Value)
                {
                    if (!Data.chkNewTabs.Value)
                    {
                        foreach (TabInfo destinationTab in listTabs)
                        {
                            ModuleInfo module = ModuleController.Instance.GetModule(moduleinfo.ModuleID, destinationTab.TabID, false);
                            if (module != null)
                            {
                                if (module.IsDeleted)
                                {
                                    ModuleController.Instance.RestoreModule(module);
                                }
                            }
                            else
                            {
                                if (!PortalSettings.Current.ContentLocalizationEnabled || (moduleinfo.CultureCode == destinationTab.CultureCode))
                                {
                                    ModuleController.Instance.CopyModule(moduleinfo, destinationTab, moduleinfo.PaneName, true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    ModuleController.Instance.DeleteAllModules(moduleinfo.ModuleID, moduleinfo.TabID, listTabs, true, false, false);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Fills the module list.
        /// </summary>
        private void FillModuleList()
        {
            PortalSettings portalSettings = PortalController.Instance.GetCurrentPortalSettings();

            List <TabInfo> objTabs = TabController.GetPortalTabs(portalSettings.PortalId, -1, true, true);

            var objTabController = new TabController();

            var objDesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName(
                "DnnForge - NewsArticles",
                portalSettings.PortalId);

            if (objDesktopModuleInfo == null)
            {
                return;
            }

            foreach (var objTab in objTabs.Where(tab => !tab.IsDeleted))
            {
                var objModules = new ModuleController();

                foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID))
                {
                    ModuleInfo objModule = pair.Value;

                    if (objModule.IsDeleted)
                    {
                        continue;
                    }

                    if (objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }

                    string  strPath        = objTab.TabName;
                    TabInfo objTabSelected = objTab;

                    while (objTabSelected.ParentId != Null.NullInteger)
                    {
                        objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                        if (objTabSelected == null)
                        {
                            break;
                        }

                        strPath = string.Format("{0} -> {1}", objTabSelected.TabName, strPath);
                    }

                    var objListItem = new ListItem
                    {
                        Value =
                            string.Format(
                                "{0}-{1}",
                                objModule.TabID,
                                objModule.ModuleID),
                        Text = string.Format(
                            "{2}: {0} -> {3}: {1}",
                            strPath,
                            objModule.ModuleTitle,
                            Localization.GetString(
                                "Page.Text",
                                this.ResXFile,
                                this.LangCode),
                            Localization.GetString(
                                "ModuleInstance.Text",
                                this.ResXFile,
                                this.LangCode))
                    };

                    ModuleListDropDown.Items.Add(objListItem);
                }
            }
        }
Exemplo n.º 10
0
        private void LoadSettings()
        {
            try
            {
                var portalController = new PortalController();
                var portal           = portalController.GetPortal(PortalId, SelectedCultureCode);

                //Set up special page lists
                List <TabInfo> listTabs = TabController.GetPortalTabs(TabController.GetTabsBySortOrder(portal.PortalID, SelectedCultureCode, true),
                                                                      Null.NullInteger,
                                                                      true,
                                                                      "<" + Localization.GetString("None_Specified") + ">",
                                                                      true,
                                                                      false,
                                                                      false,
                                                                      false,
                                                                      false);

                var tabs = listTabs.Where(t => t.DisableLink == false).ToList();

                FriendlyUrlSettings fs = new DotNetNuke.Entities.Urls.FriendlyUrlSettings(PortalId);

                // AUM_UrlFormat
                //cbURLFormat.Checked = (fs.UrlFormat == UrlFormatType.Advanced.ToString().ToLower());

                // AUM_DeletedTabHandlingType
                ListItem liDeletedTabHandling = rblDeletedTabHandlingType.Items.FindByValue(fs.DeletedTabHandlingType.ToString());
                if (liDeletedTabHandling != null)
                {
                    rblDeletedTabHandlingType.ClearSelection();
                    liDeletedTabHandling.Selected = true;
                }

                // AUM_ErrorPage404
                if (fs.TabId404 > 0)
                {
                    ddlErrorPage404.SelectedPage = tabs.Where(i => i.TabID == portal.Custom404TabId).SingleOrDefault();
                }

                // AUM_ErrorPage500
                if (fs.TabId500 > 0)
                {
                    ddlErrorPage500.SelectedPage = tabs.Where(i => i.TabID == portal.Custom500TabId).SingleOrDefault();
                }

                // AUM_ForceLowerCase
                cbForceLowerCase.Checked = fs.ForceLowerCase;

                // AUM_PageExtension
                txtPageExtension.Text = fs.PageExtension;

                // AUM_PageExtensionUsage - reverse boolean because label is 'hide'
                if (fs.PageExtensionUsageType == DotNetNuke.Entities.Urls.PageExtensionUsageType.AlwaysUse)
                {
                    cbPageExtensionHandling.Checked = false;
                }
                else
                {
                    cbPageExtensionHandling.Checked = true;
                }

                // AUM_RedirectOldProfileUrl - skip

                // AUM_RedirectUnfriendly
                cbRedirectUnfriendly.Checked = fs.RedirectUnfriendly;

                // AUM_ReplaceSpaceWith, // AUM_ReplaceChars , // AUM_ReplaceCharWithChar
                if (fs.ReplaceSpaceWith == FriendlyUrlSettings.ReplaceSpaceWithNothing)
                {
                    cbCharacterReplacement.Checked = false;
                    txtReplaceChars.Text           = fs.ReplaceChars;
                }
                else
                {
                    cbCharacterReplacement.Checked = true;

                    ListItem liReplaceSpaceWith = ddlReplaceSpaceWith.Items.FindByValue(fs.ReplaceSpaceWith);
                    if (liReplaceSpaceWith != null)
                    {
                        liReplaceSpaceWith.Selected = true;
                    }

                    txtReplaceChars.Text = fs.ReplaceChars;
                }
                txtFindReplaceTheseCharacters.Text = DotNetNuke.Entities.Portals.PortalController.GetPortalSetting(FriendlyUrlSettings.ReplaceCharWithCharSetting, PortalId, string.Empty);

                // AUM_RedirectMixedCase
                cbRedirectMixedCase.Checked = fs.RedirectWrongCase;

                // AUM_SpaceEncodingValue
                ListItem liSpaceEncodingValue = rblSpaceEncodingValue.Items.FindByValue(fs.SpaceEncodingValue);
                if (liSpaceEncodingValue != null)
                {
                    rblSpaceEncodingValue.ClearSelection();
                    liSpaceEncodingValue.Selected = true;
                }

                // AUM_AutoAsciiConvert
                cbAutoAsciiConvert.Checked = fs.AutoAsciiConvert;

                // AUM_CheckForDuplicatedUrls
                cbCheckForDuplicatedUrls.Checked = fs.CheckForDuplicateUrls;

                // AUM_FriendlyAdminHostUrls - skip

                // AUM_EnableCustomProviders
                cbEnableCustomProviders.Checked = fs.EnableCustomProviders;

                // AUM_IgnoreUrlRegex
                txtIgnoreUrlRegex.Text = fs.IgnoreRegex;

                // AUM_DoNotRewriteRegEx
                txtDoNotRewriteRegEx.Text = fs.DoNotRewriteRegex;

                // AUM_SiteUrlsOnlyRegex
                txtSiteUrlsOnlyRegex.Text = fs.UseSiteUrlsRegex;

                // AUM_DoNotRedirectUrlRegex
                txtDoNotRedirectUrlRegex.Text = fs.DoNotRedirectRegex;

                // AUM_DoNotRedirectHttpsUrlRegex
                txtDoNotRedirectHttpsUrlRegex.Text = fs.DoNotRedirectSecureRegex;

                // AUM_PreventLowerCaseUrlRegex
                txtPreventLowerCaseUrlRegex.Text = fs.ForceLowerCaseRegex;

                // AUM_DoNotUseFriendlyUrlRegex
                txtDoNotUseFriendlyUrlRegex.Text = fs.NoFriendlyUrlRegex;

                // AUM_KeepInQueryStringRegex
                txtKeepInQueryStringRegex.Text = fs.DoNotIncludeInPathRegex;

                // AUM_UrlsWithNoExtensionRegex
                txtUrlsWithNoExtensionRegex.Text = fs.ValidExtensionlessUrlsRegex;

                // AUM_ValidFriendlyUrlRegex
                txtValidFriendlyUrlRegex.Text = fs.RegexMatch;

                // AUM_UsePortalDefaultLanguage
                // AUM_AllowDebugCode
                // AUM_LogCacheMessages

                CheckPageExtension();
                CheckCharacterReplacement();
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 11
0
        private void LoadCategoryDisplayTabDropDown()
        {
            this.ddlDisplayTabId.Items.Clear();

            var modules = new[]
            {
                Utility.DnnFriendlyModuleName
            };

            // ListItem l = new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1");
            // this.ddlDisplayTabId.Items.Insert(0, l);

            // foreach (DataRow dr in dt.Rows)
            // {
            // ListItem li = new ListItem(dr["TabName"] + " (" + dr["TabID"] + ")", dr["TabID"].ToString());
            // this.ddlDisplayTabId.Items.Add(li);
            // }
            DataTable dt = Utility.GetDisplayTabIds(modules);

            // this.ddlDisplayTabId.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1"));
            this.ddlDisplayTabId.DataSource = TabController.GetPortalTabs(this.PortalId, Null.NullInteger, false, true);
            this.ddlDisplayTabId.DataBind();

            foreach (DataRow dr in dt.Rows)
            {
                if (this.ddlDisplayTabId.Items.FindByValue(dr["TabID"].ToString()) != null)
                {
                    this.ddlDisplayTabId.Items.FindByValue(dr["TabID"].ToString()).Text += Localization.GetString(
                        "PublishOverrideable", this.LocalSharedResourceFile);
                }

                // ListItem li = new ListItem(dr["TabName"] + " (" + dr["TabID"] + ")", dr["TabID"].ToString());
                // this.ddlDisplayTabId.Items.Add(li);
            }

            if (!this.VersionInfoObject.IsNew)
            {
                ListItem li = this.ddlDisplayTabId.Items.FindByValue(this.VersionInfoObject.DisplayTabId.ToString(CultureInfo.InvariantCulture));
                if (li != null)
                {
                    this.ddlDisplayTabId.ClearSelection();
                    li.Selected = true;
                }
            }
            else
            {
                Category parent = null;
                if (this.ParentId != -1)
                {
                    parent = Category.GetCategory(this.ParentId, this.PortalId);
                    this.parentCategoryRelationships.AddToSelectedItems(parent);
                }

                // look for display tab id
                if (parent != null && parent.ChildDisplayTabId > 0)
                {
                    if (this.ddlDisplayTabId.Items.FindByValue(parent.ChildDisplayTabId.ToString(CultureInfo.InvariantCulture)) != null)
                    {
                        this.ddlDisplayTabId.SelectedIndex = -1;
                        this.ddlDisplayTabId.Items.FindByValue(parent.ChildDisplayTabId.ToString(CultureInfo.InvariantCulture)).Selected = true;
                    }
                }
                else
                {
                    // load the default display tab
                    ListItem li = this.ddlDisplayTabId.Items.FindByValue(this.DefaultDisplayTabId.ToString(CultureInfo.InvariantCulture));
                    if (li != null)
                    {
                        this.ddlDisplayTabId.ClearSelection();
                        li.Selected = true;
                    }
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取当前用户可以看到的菜单
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="uInfo"></param>
        /// <returns></returns>
        public List <TabInfo> GetUserTabs(PortalSettings ps, UserInfo uInfo)
        {
            int portalId = ps.PortalId;

            new TabController();

            List <TabInfo> list2 = new List <TabInfo>();

            if (ShowDNN)
            {
                var desktopTabs = TabController.GetPortalTabs(ps.PortalId, Null.NullInteger, false, "none available", false, false, true, true, false);

                list2.AddRange(desktopTabs);
                //List<TabInfo> desktopTabs = TabController.GetPortalTabs(portalId, Null.NullInteger, false, false);

                //int num = 0;
                //int portalID = uInfo.PortalID;
                //if (uInfo.IsSuperUser)
                //    num = 999;//超级管理员权限
                //else if (uInfo.IsInRole("Administrators"))
                //    num = 1;//管理员权限
                //else if (uInfo.UserID > 0)
                //    num = 0;//登录用户权限
                //else
                //    num = -1;//匿名用户权限
                //foreach (TabInfo item in desktopTabs)
                //{



                //    if (!item.IsDeleted && item.IsVisible)
                //    {
                //        switch (num)
                //        {
                //            case 999:
                //                {
                //                    list2.Add(item);
                //                    continue;
                //                }
                //            case 1:
                //                {
                //                    if (item.PortalID == portalID && (item.AuthorizedRoles.Contains("All Users") || item.AuthorizedRoles.Contains("Administrators"))) list2.Add(item);
                //                    continue;
                //                }
                //            case 0:
                //                {
                //                    if (item.PortalID == portalID && !Refusal(uInfo, item.TabPermissions) && (item.AuthorizedRoles.Contains("All Users") || IsRoles(uInfo.Roles, item.AuthorizedRoles) || IsUsers(uInfo, item.TabPermissions))) list2.Add(item);
                //                    continue;
                //                }
                //        }
                //        if (num == -1 && !Refusal(uInfo, item.TabPermissions) && (item.AuthorizedRoles.Contains("All Users") || item.AuthorizedRoles.Contains("Unauthenticated Users"))) list2.Add(item);
                //    }
                //}
            }

            if (ShowXml)
            {
                //加入XML中的数据
                list2.AddRange(GetXmlTabs());
            }

            return(list2);
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MyEditUrl(lbTestHtml, "TestHtml");

            MyEditUrl(lbViewRules, "rules_view");
            MyEditUrl(lbAddRule, "rules_edit");
            MyEditUrl(lbViewCache, "cache_view");
            MyEditUrl(lbViewLog, "log_view");
            //lbLogSettings.Attributes.Add("onclick", "return " + MyEditUrl("log_settings"));

            ShowCache();
            ShowLogs();
            ShowRules();

            ShowProviders();
            //ShowPortals();


            ddlTab.DataSource = TabController.GetPortalTabs(PortalId, -1, false, true);
            ddlTab.DataBind();

            if (!Page.IsPostBack)
            {
                cbDisableSiteIndex.Checked   = UrlRewiterSettings.IsDisableSiteIndex(PortalId);
                cbDisableTermsIndex.Checked  = UrlRewiterSettings.IsDisableTermsIndex(PortalId);
                cbDisablePivacyIndex.Checked = UrlRewiterSettings.IsDisablePrivacyIndex(PortalId);

                cbLogAuthentificatedUsers.Checked = UrlRewiterSettings.IsLogAuthentificatedUsers(PortalId);
                cbLogEachUrlOneTime.Checked       = UrlRewiterSettings.IsLogEachUrlOneTime(PortalId);
                cbLogStatusCode200.Checked        = UrlRewiterSettings.IsLogStatusCode200(PortalId);
                cbLogEnabled.Checked  = UrlRewiterSettings.IsLogEnabled(PortalId);
                cbW3C.Checked         = UrlRewiterSettings.IsW3C(PortalId);
                cbEnhanced404.Checked = UrlRewiterSettings.IsManage404(PortalId);
                ddlTab.SelectedValue  = PortalController.GetPortalSetting(UrlRewiterSettings.ErrorPage404Setting, PortalId, "-1");

                XmlDocument xmlConfig = Config.Load();

                XmlNode xmlSitemap      = xmlConfig.SelectSingleNode("/configuration/dotnetnuke/sitemap/providers/add[@name='openUrlRewriterSitemapProvider']");
                XmlNode xmlFriendlyUrl  = xmlConfig.SelectSingleNode("/configuration/dotnetnuke/friendlyUrl/providers/add[@name='OpenFriendlyUrl']");
                XmlNode xmlFriendlyUrl2 = xmlConfig.SelectSingleNode("/configuration/dotnetnuke/friendlyUrl");

                XmlNode xmlUrlRewriter1 = xmlConfig.SelectSingleNode("/configuration/system.webServer/modules/add[@name='UrlRewrite']");
                XmlNode xmlUrlRewriter2 = xmlConfig.SelectSingleNode("/configuration/system.web/httpModules/add[@name='UrlRewrite']");

                //XmlNode xmlCaching = xmlConfig.SelectSingleNode("/configuration/dotnetnuke/caching/providers/add[@name='OpenUrlRewriterFBCachingProvider']");

                XmlNode xmlSitemapHandler1 = xmlConfig.SelectSingleNode("/configuration/system.webServer/handlers/add[@name='SitemapHandler']");
                XmlNode xmlSitemapHandler2 = xmlConfig.SelectSingleNode("/configuration/system.web/httpHandlers/add[@path='Sitemap.aspx']");

                //cbSitemapProvider.Checked = xmlSitemap != null;

                if (xmlFriendlyUrl != null && xmlFriendlyUrl2.Attributes["defaultProvider"].Value == "OpenFriendlyUrl")
                {
                    lFriendlyUrlProvider.CssClass = cssSucces;
                }
                else
                {
                    lFriendlyUrlProvider.CssClass = cssError;
                }

                if (HttpRuntime.UsingIntegratedPipeline)
                {
                    if (xmlUrlRewriter1 != null && xmlUrlRewriter1.Attributes["type"].Value == "Satrabel.HttpModules.UrlRewriteModule, Satrabel.OpenUrlRewriter")
                    {
                        lUrlRewriter.CssClass = cssSucces;
                    }
                    else
                    {
                        lUrlRewriter.CssClass = cssError;
                    }
                }
                else
                {
                    if (xmlUrlRewriter2 != null && xmlUrlRewriter2.Attributes["type"].Value == "Satrabel.HttpModules.UrlRewriteModule, Satrabel.OpenUrlRewriter")
                    {
                        lUrlRewriter.CssClass = cssSucces;
                    }
                    else
                    {
                        lUrlRewriter.CssClass = cssError;
                    }
                }
                if (xmlSitemap != null)
                {
                    lSitemapProvider.CssClass = cssSucces;
                }
                else
                {
                    lSitemapProvider.CssClass = cssError;
                }

                if (xmlSitemap != null)
                {
                    lSitemapProvider.CssClass = cssSucces;
                }
                else
                {
                    lSitemapProvider.CssClass = cssError;
                }

                /*
                 * if (xmlCaching != null)
                 *  lCachingProvider.CssClass = cssSucces;
                 * else
                 *  lCachingProvider.CssClass = cssError;
                 */

                if (HttpRuntime.UsingIntegratedPipeline)
                {
                    if (xmlSitemapHandler1 != null && xmlSitemapHandler1.Attributes["type"].Value == "Satrabel.Services.Sitemap.OpenSitemapHandler, Satrabel.OpenUrlRewriter")
                    {
                        lSitemapHandler.CssClass = cssSucces;
                    }
                    else
                    {
                        lSitemapHandler.CssClass = cssError;
                    }
                }
                else
                {
                    if (xmlSitemapHandler2 != null && xmlSitemapHandler2.Attributes["type"].Value == "Satrabel.Services.Sitemap.OpenSitemapHandler, Satrabel.OpenUrlRewriter")
                    {
                        lSitemapHandler.CssClass = cssSucces;
                    }
                    else
                    {
                        lSitemapHandler.CssClass = cssError;
                    }
                }

                lbSaveMeta.Enabled = EditMode;
                lbTestHtml.Visible = UserInfo.IsSuperUser;
            }

            /*
             * Locale DefaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);
             * PortalInfo objPortal = new PortalController().GetPortal(PortalId, DefaultLocale.Code);
             * int DefaultHomeTabId = -1;
             * if (objPortal != null)
             *  DefaultHomeTabId = objPortal.HomeTabId;
             *
             * bool RemoveHomePage = PortalController.GetPortalSettingAsBoolean( "TabUrlRuleProvider" + "_"+ "RemoveHomePage", PortalId, false);
             *
             * lTrace.Text = PortalId + "/" + DefaultLocale.Code + "/" + DefaultHomeTabId + "/" + RemoveHomePage;
             */
        }
Exemplo n.º 14
0
        /// <summary>
        /// Fills the active forums list.
        /// </summary>
        private void FillActiveForumsList()
        {
            var objTabController = new TabController();

            var objDesktopModuleInfo =
                DesktopModuleController.GetDesktopModuleByModuleName("Active Forums", this.PortalId);

            if (objDesktopModuleInfo == null)
            {
                this.ActiveForumsPlaceHolder.Visible = false;
                return;
            }

            var tabs = TabController.GetPortalTabs(this.PortalSettings.PortalId, -1, true, true);

            foreach (var tabInfo in tabs.Where(tab => !tab.IsDeleted))
            {
                var moduleController = new ModuleController();

                foreach (var pair in moduleController.GetTabModules(tabInfo.TabID))
                {
                    var moduleInfo = pair.Value;

                    if (moduleInfo.IsDeleted)
                    {
                        continue;
                    }

                    if (moduleInfo.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }

                    var path        = tabInfo.TabName;
                    var tabSelected = tabInfo;

                    while (tabSelected.ParentId != Null.NullInteger)
                    {
                        tabSelected = objTabController.GetTab(tabSelected.ParentId, tabInfo.PortalID, false);
                        if (tabSelected == null)
                        {
                            break;
                        }

                        path = "{0} -> {1}".FormatWith(tabSelected.TabName, path);
                    }

                    var objListItem = new ListItem
                    {
                        Value = moduleInfo.ModuleID.ToString(),
                        Text  = "{0} -> {1}".FormatWith(path, moduleInfo.ModuleTitle)
                    };

                    this.ActiveForums.Items.Add(objListItem);
                }
            }

            if (this.ActiveForums.Items.Count == 0)
            {
                this.ActiveForumsPlaceHolder.Visible = false;
            }
        }
        /// <Description>
        /// 绑定页面项
        /// </Description>
        private void BindPageItem()
        {
            //链接
            String Element_UrlLink = FieldItem != null ? FieldItem.DefaultValue : String.Empty;

            //imgUrlLink.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/1-1.png'", ModulePath));

            WebHelper.BindList <TabInfo>(ddlUrlLink, TabController.GetPortalTabs(PortalId, Null.NullInteger, true, true, false, false), "IndentedTabName", "TabId");

            List <EnumEntity> EnumList = EnumHelper.GetEnumList(typeof(EnumUrlControls));


            //设置和选择哪些类型可以显示出来

            if (!String.IsNullOrEmpty(FieldItem.ListContent))
            {
                if (!FindUrlType(FieldItem.ListContent, "U"))
                {
                    EnumList.RemoveAll(r => r.Value == 1);
                }
                if (!FindUrlType(FieldItem.ListContent, "P"))
                {
                    EnumList.RemoveAll(r => r.Value == 2);
                }
                if (!FindUrlType(FieldItem.ListContent, "F"))
                {
                    EnumList.RemoveAll(r => r.Value == 3);
                }

                if (EnumList.Count == 1)
                {
                    rblUrlLink.Visible = false;
                }

                WebHelper.BindList <EnumEntity>(rblUrlLink, EnumList, "Text", "Value");

                String defaultType = WebHelper.leftx(FieldItem.ListContent, 1).ToUpper();
                if (!String.IsNullOrEmpty(defaultType))
                {
                    ShowHideControl(defaultType);
                }
            }
            else
            {
                WebHelper.BindList <EnumEntity>(rblUrlLink, EnumList, "Text", "Value");
                ShowHideControl("U");
            }



            if (!String.IsNullOrEmpty(Element_UrlLink) && Element_UrlLink.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) == 0)
            {
                WebHelper.SelectedListByValue(ddlUrlLink, Element_UrlLink.Replace("TabID=", ""));
                //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Page);
                //txtUrlLink.Attributes.Add("style", "display:none");
                //panUrlLink.Attributes.Add("style", "display:none");
                ShowHideControl("P");
            }
            else if (!String.IsNullOrEmpty(Element_UrlLink) && Element_UrlLink.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) == 0)
            {
                TemplateFormat xf = new TemplateFormat(this);
                hfUrlLink.Value = Element_UrlLink;
                //imgUrlLink.ImageUrl = xf.ViewLinkUrl(Element_UrlLink);

                div_Image.Attributes.Add("data-MediaID", Element_UrlLink);

                ShowHideControl("F");
                //hlRemoveUrlLink.Attributes.Add("style", "display:;");
                //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Files);
                //txtUrlLink.Attributes.Add("style", "display:none");
                //ddlUrlLink.Attributes.Add("style", "display:none");
            }
            else
            {
                if (!String.IsNullOrEmpty(Element_UrlLink))
                {
                    if (Element_UrlLink.IndexOf("FileID=", StringComparison.CurrentCultureIgnoreCase) == 0)
                    {
                        int FileID = 0;
                        if (int.TryParse(Element_UrlLink.Replace("FileID=", ""), out FileID) && FileID > 0)
                        {
                            var fi = DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(FileID);
                            if (fi != null && fi.FileId > 0)
                            {
                                txtUrlLink.Text = string.Format("{0}{1}{2}", PortalSettings.HomeDirectory, fi.Folder, Server.UrlPathEncode(fi.FileName));
                            }
                        }
                    }
                    else
                    {
                        txtUrlLink.Text = Element_UrlLink;
                    }
                    ShowHideControl("U");
                }

                //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Url);
                //ddlUrlLink.Attributes.Add("style", "display:none");
                //panUrlLink.Attributes.Add("style", "display:none");
            }
        }
Exemplo n.º 16
0
        private void BindData()
        {
            switch (optModuleType.SelectedItem.Value)
            {
            case "0":     //new module
                cboTabs.Visible           = false;
                cboModules.Visible        = false;
                cboDesktopModules.Visible = true;
                txtTitle.Visible          = true;
                lblModule.Text            = Localization.GetString("Module", LocalResourceFile);
                lblTitle.Text             = Localization.GetString("Title", LocalResourceFile);
                cboPermission.Enabled     = true;

                //get list of modules
                cboDesktopModules.DataSource = DesktopModuleController.GetPortalDesktopModules(PortalSettings.PortalId).Values;
                cboDesktopModules.DataBind();
                cboDesktopModules.Items.Insert(0, new ListItem("<" + Localization.GetString("SelectModule", LocalResourceFile) + ">", "-1"));

                //select default module
                int intDesktopModuleID = -1;
                if (!String.IsNullOrEmpty(Localization.GetString("DefaultModule", LocalResourceFile)))
                {
                    DesktopModuleInfo objDesktopModule;
                    objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(Localization.GetString("DefaultModule", LocalResourceFile, PortalSettings, null, true),
                                                                                            PortalSettings.PortalId);
                    if (objDesktopModule != null)
                    {
                        intDesktopModuleID = objDesktopModule.DesktopModuleID;
                    }
                }
                if (intDesktopModuleID != -1 && (cboDesktopModules.Items.FindByValue(intDesktopModuleID.ToString()) != null))
                {
                    cboDesktopModules.Items.FindByValue(intDesktopModuleID.ToString()).Selected = true;
                }
                else
                {
                    cboDesktopModules.SelectedIndex = 0;
                }
                break;

            case "1":     //existing module
                cboTabs.Visible           = true;
                cboModules.Visible        = true;
                cboDesktopModules.Visible = false;
                txtTitle.Visible          = false;
                lblModule.Text            = Localization.GetString("Tab", LocalResourceFile);
                lblTitle.Text             = Localization.GetString("Module", LocalResourceFile);
                cboPermission.Enabled     = false;
                cboTabs.DataSource        = TabController.GetPortalTabs(PortalSettings.PortalId,
                                                                        PortalSettings.ActiveTab.TabID,
                                                                        true,
                                                                        "<" + Localization.GetString("SelectPage", LocalResourceFile) + ">",
                                                                        true,
                                                                        false,
                                                                        false,
                                                                        false,
                                                                        true);
                cboTabs.DataBind();
                break;
            }
        }
        private IEnumerable <ItemDto> GetPageDescendantsInternal(int portalId, int parentId, int sortOrder, string searchText, bool includeDisabled = false, bool includeAllTypes = false)
        {
            List <TabInfo> tabs;

            if (portalId == -1)
            {
                portalId = GetActivePortalId(parentId);
            }
            else
            {
                if (!IsPortalIdValid(portalId))
                {
                    return(new List <ItemDto>());
                }
            }

            Func <TabInfo, bool> searchFunc;

            if (String.IsNullOrEmpty(searchText))
            {
                searchFunc = page => true;
            }
            else
            {
                searchFunc = page => page.LocalizedTabName.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase) > -1;
            }

            if (portalId > -1)
            {
                var includeHiddenTabs = PortalSettings.UserInfo.IsSuperUser || PortalSettings.UserInfo.IsInRole("Administrators");
                tabs =
                    TabController.GetPortalTabs(portalId, Null.NullInteger, false, null, includeHiddenTabs, false, false, true, false)
                    .Where(tab => searchFunc(tab) && tab.ParentId == parentId && (includeDisabled || !tab.DisableLink) && (includeAllTypes || tab.TabType == TabType.Normal))
                    .OrderBy(tab => tab.TabOrder)
                    .ToList();
            }
            else
            {
                if (PortalSettings.UserInfo.IsSuperUser)
                {
                    var tabController = new TabController();

                    tabs = tabController.GetTabsByPortal(-1).AsList()
                           .Where(tab => searchFunc(tab) && tab.ParentId == parentId && !tab.IsDeleted && !tab.DisableLink)
                           .OrderBy(tab => tab.TabOrder)
                           .ToList();
                }
                else
                {
                    return(new List <ItemDto>());
                }
            }

            var pages = tabs.Select(tab => new ItemDto
            {
                Key         = tab.TabID.ToString(CultureInfo.InvariantCulture),
                Value       = tab.LocalizedTabName,
                HasChildren = tab.HasChildren,
                Selectable  = true
            });

            return(ApplySort(pages, sortOrder));
        }
Exemplo n.º 18
0
        private void BindTree(PortalInfo portal)
        {
            ctlPages.Nodes.Clear();

            var tabController = new TabController();
            var rootNode      = new RadTreeNode
            {
                Text              = PortalSettings.PortalName,
                ImageUrl          = IconPortal,
                Value             = Null.NullInteger.ToString(CultureInfo.InvariantCulture),
                Expanded          = true,
                AllowEdit         = false,
                EnableContextMenu = true,
                Checked           = true
            };

            rootNode.Attributes.Add("isPortalRoot", "True");

            //var tabs = new TabCollection();
            List <TabInfo> tabs;

            if (chkMultilanguage.Checked)
            {
                tabs = TabController.GetPortalTabs(TabController.GetTabsBySortOrder(portal.PortalID, portal.DefaultLanguage, true),
                                                   Null.NullInteger,
                                                   false,
                                                   "<" + Localization.GetString("None_Specified") + ">",
                                                   true,
                                                   false,
                                                   true,
                                                   false,
                                                   false);

                //Tabs = tabController.GetTabsByPortal(portal.PortalID).WithCulture(portal.DefaultLanguage, true);
            }
            else
            {
                tabs = TabController.GetPortalTabs(TabController.GetTabsBySortOrder(portal.PortalID, languageComboBox.SelectedValue, true),
                                                   Null.NullInteger,
                                                   false,
                                                   "<" + Localization.GetString("None_Specified") + ">",
                                                   true,
                                                   false,
                                                   true,
                                                   false,
                                                   false);
                //tabs = tabController.GetTabsByPortal(portal.PortalID);
            }

            foreach (var tab in tabs) //.Values)
            {
                if (tab.Level == 0)
                {
                    string tooltip;
                    var    nodeIcon = GetNodeIcon(tab, out tooltip);
                    var    node     = new RadTreeNode
                    {
                        Text      = string.Format("{0} {1}", tab.TabName, GetNodeStatusIcon(tab)),
                        Value     = tab.TabID.ToString(CultureInfo.InvariantCulture),
                        AllowEdit = true,
                        ImageUrl  = nodeIcon,
                        ToolTip   = tooltip,
                        Checked   = true
                    };

                    AddChildNodes(node, portal);
                    rootNode.Nodes.Add(node);
                }
            }

            ctlPages.Nodes.Add(rootNode);
        }
            public static dynamic Edit(PortalSettings PortalSettings, CustomBlock CustomBlock)
            {
                dynamic Result = new ExpandoObject();

                try
                {
                    CustomBlock cb = BlockFactory.GetAll(PortalSettings.PortalId).Where(b => b.Guid.ToLower() == CustomBlock.Guid.ToLower() && b.Locale == PageManager.GetCultureCode(PortalSettings)).FirstOrDefault();
                    if (cb == null)
                    {
                        cb = BlockFactory.GetAll(PortalSettings.PortalId).Where(b => b.Guid.ToLower() == CustomBlock.Guid.ToLower() && b.Locale == null).FirstOrDefault();
                        if (cb != null)
                        {
                            cb.Locale = PageManager.GetCultureCode(PortalSettings);
                            cb.ID     = 0;
                            BlockFactory.AddUpdate(cb);
                        }
                    }
                    if (cb != null)
                    {
                        cb.Name     = CustomBlock.Name;
                        cb.Category = CustomBlock.Category;

                        if (CustomBlock.IsGlobal && !string.IsNullOrEmpty(CustomBlock.Html))
                        {
                            HtmlDocument html = new HtmlDocument();
                            html.LoadHtml(CustomBlock.Html);
                            IEnumerable <HtmlNode> query = html.DocumentNode.Descendants("div");
                            foreach (HtmlNode item in query.ToList())
                            {
                                if (item.Attributes.Where(a => a.Name == "dmid").FirstOrDefault() != null && item.Attributes.Where(a => a.Name == "mid").FirstOrDefault() != null && !string.IsNullOrEmpty(item.Attributes.Where(a => a.Name == "mid").FirstOrDefault().Value))
                                {
                                    int        mid   = int.Parse(item.Attributes.Where(a => a.Name == "mid").FirstOrDefault().Value);
                                    ModuleInfo minfo = ModuleController.Instance.GetModule(mid, Null.NullInteger, false);
                                    if (minfo != null && !minfo.AllTabs)
                                    {
                                        minfo.AllTabs = true;
                                        ModuleController.Instance.UpdateModule(minfo);
                                        List <TabInfo> listTabs = TabController.GetPortalTabs(minfo.PortalID, Null.NullInteger, false, true);
                                        foreach (TabInfo destinationTab in listTabs)
                                        {
                                            ModuleInfo module = ModuleController.Instance.GetModule(minfo.ModuleID, destinationTab.TabID, false);
                                            if (module != null)
                                            {
                                                if (module.IsDeleted)
                                                {
                                                    ModuleController.Instance.RestoreModule(module);
                                                }
                                            }
                                            else
                                            {
                                                if (!PortalSettings.Current.ContentLocalizationEnabled || (minfo.CultureCode == destinationTab.CultureCode))
                                                {
                                                    ModuleController.Instance.CopyModule(minfo, destinationTab, minfo.PaneName, true);
                                                }
                                            }
                                        }
                                    }
                                    item.InnerHtml = "<div vjmod=\"true\"><app id=\"" + mid + "\"></app>";
                                }
                                else if (item.Attributes.Where(a => a.Name == "data-block-type").FirstOrDefault() != null)
                                {
                                    if (item.Attributes.Where(a => a.Name == "data-block-type").FirstOrDefault().Value.ToLower() != "global")
                                    {
                                        item.InnerHtml = item.Attributes.Where(a => a.Name == "data-block-type").FirstOrDefault().Value;
                                    }
                                }
                            }
                            CustomBlock.Html = html.DocumentNode.OuterHtml;
                        }

                        cb.Html      = CustomBlock.Html;
                        cb.Css       = CustomBlock.Css;
                        cb.IsGlobal  = CustomBlock.IsGlobal;
                        cb.UpdatedBy = PortalSettings.Current.UserId;
                        cb.UpdatedOn = DateTime.UtcNow;
                        BlockFactory.AddUpdate(cb);
                        Result.Status      = "Success";
                        Result.Guid        = cb.Guid;
                        Result.CustomBlock = cb;
                    }
                    else
                    {
                        Result.Status = "Not exist";
                    }
                }
                catch (Exception ex)
                {
                    Result.Status = ex.Message.ToString();
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
                return(Result);
            }
        public IEnumerable <Page> GetPagesList(int portalId, out int total, string searchKey = "", int pageIndex = -1, int pageSize = 10, string sortBy = "", string sortType = "", bool?deleted = false)
        {
            try
            {
                pageIndex = ((pageIndex > 0) ? pageIndex : 0);
                pageSize  = ((pageSize > 0 && pageSize <= 100) ? pageSize : 10);

                var portalSettings = new PortalSettings(portalId);
                var adminTabId     = portalSettings.AdminTabId;

                bool includeHidden   = true;
                bool includeDeleted  = true;
                bool includeSubpages = true;
                bool?visible         = null;

                var tabs  = TabController.GetPortalTabs(portalSettings.PortalId, adminTabId, false, includeHidden, includeDeleted, true);
                var pages = from t in tabs
                            where (t.ParentId != adminTabId || t.ParentId == Null.NullInteger) &&
                            t.IsSystem == false &&
                            ((string.IsNullOrEmpty(searchKey) && includeSubpages) ||
                             (string.IsNullOrEmpty(searchKey) == false &&
                              (t.TabName.IndexOf(searchKey, StringComparison.OrdinalIgnoreCase) > Null.NullInteger ||
                               t.LocalizedTabName.IndexOf(searchKey, StringComparison.OrdinalIgnoreCase) > Null.NullInteger ||
                               t.Title.IndexOf(searchKey, StringComparison.OrdinalIgnoreCase) > Null.NullInteger ||
                               t.Description.IndexOf(searchKey, StringComparison.OrdinalIgnoreCase) > Null.NullInteger ||
                               t.KeyWords.IndexOf(searchKey, StringComparison.OrdinalIgnoreCase) > Null.NullInteger ||
                               t.Url.IndexOf(searchKey, StringComparison.OrdinalIgnoreCase) > Null.NullInteger
                              )))
                            select Mapper.Map <Page>(t);

                pages = includeSubpages ? pages.OrderBy(x => x.ParentId > -1 ? x.ParentId : x.TabID).ThenBy(x => x.TabID) : pages;

                var finalList = new List <Page>();
                if (deleted.HasValue)
                {
                    pages = pages.Where(tab => tab.IsDeleted == deleted);
                }

                if (visible.HasValue)
                {
                    pages = pages.Where(tab => tab.IsVisible == visible);
                }

                string sortOn    = sortBy.ToLowerInvariant();
                string sortOrder = sortType.ToLowerInvariant();

                if (String.IsNullOrEmpty(sortBy) == false)
                {
                    switch (sortBy.ToLowerInvariant())
                    {
                    case Constants.NAME:
                        pages = sortOrder == Constants.ASC ? pages.OrderBy(x => x.LocalizedTabName) : pages.OrderByDescending(x => x.LocalizedTabName);
                        break;

                    case Constants.TITLE:
                        pages = sortOrder == Constants.ASC ? pages.OrderBy(x => x.Title) : pages.OrderByDescending(x => x.Title);
                        break;

                    default:
                        break;
                    }
                }

                finalList.AddRange(pages);

                total = finalList.Count;
                return(pageIndex == -1 || pageSize == -1 ? finalList : finalList.Skip(pageIndex * pageSize).Take(pageSize));
            }
            catch (Exception ex)
            {
                LogError(ex);
                Exceptions.LogException(ex);
                total = 0;
                return(new List <Page>());
            }
        }
Exemplo n.º 21
0
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    var allTabsChanged = false;
                    //TODO: REMOVE IF UNUSED
                    //var allowIndexChanged = false;

                    //only Portal Administrators can manage the visibility on all Tabs
                    var isAdmin = PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName);
                    chkAllModules.Enabled = isAdmin;

                    //tab administrators can only manage their own tab
                    if (!TabPermissionController.CanAdminPage())
                    {
                        chkAllTabs.Enabled    = false;
                        chkNewTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllowIndex.Enabled = false;
                        cboTab.Enabled        = false;
                    }
                    Module.ModuleID    = _moduleId;
                    Module.ModuleTitle = txtTitle.Text;
                    Module.Alignment   = cboAlign.SelectedItem.Value;
                    Module.Color       = txtColor.Text;
                    Module.Border      = txtBorder.Text;
                    Module.IconFile    = ctlIcon.Url;
                    Module.CacheTime   = !String.IsNullOrEmpty(txtCacheDuration.Text)
                                            ? Int32.Parse(txtCacheDuration.Text)
                                            : 0;
                    Module.CacheMethod = cboCacheProvider.SelectedValue;
                    Module.TabID       = TabId;
                    if (Module.AllTabs != chkAllTabs.Checked)
                    {
                        allTabsChanged = true;
                    }
                    Module.AllTabs = chkAllTabs.Checked;

                    // collect these first as any settings update will clear the cache
                    var originalChecked = Settings["hideadminborder"] != null && bool.Parse(Settings["hideadminborder"].ToString());
                    var allowIndex      = Settings.ContainsKey("AllowIndex") && Convert.ToBoolean(Settings["AllowIndex"]);
                    var oldMoniker      = ((string)Settings["Moniker"] ?? "").TrimToLength(100);
                    var newMoniker      = txtMoniker.Text.TrimToLength(100);
                    if (!oldMoniker.Equals(txtMoniker.Text))
                    {
                        var ids = TabModulesController.Instance.GetTabModuleIdsBySetting("Moniker", newMoniker);
                        if (ids != null && ids.Count > 0)
                        {
                            //Warn user - duplicate moniker value
                            Skin.AddModuleMessage(this, Localization.GetString("MonikerExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }
                        ModuleController.Instance.UpdateTabModuleSetting(Module.TabModuleID, "Moniker", newMoniker);
                    }

                    if (originalChecked != chkAdminBorder.Checked)
                    {
                        ModuleController.Instance.UpdateTabModuleSetting(Module.TabModuleID, "hideadminborder", chkAdminBorder.Checked.ToString());
                    }

                    //check whether allow index value is changed
                    if (allowIndex != chkAllowIndex.Checked)
                    {
                        ModuleController.Instance.UpdateTabModuleSetting(Module.TabModuleID, "AllowIndex", chkAllowIndex.Checked.ToString());
                    }

                    switch (Int32.Parse(cboVisibility.SelectedItem.Value))
                    {
                    case 0:
                        Module.Visibility = VisibilityState.Maximized;
                        break;

                    case 1:
                        Module.Visibility = VisibilityState.Minimized;
                        break;

                    //case 2:
                    default:
                        Module.Visibility = VisibilityState.None;
                        break;
                    }

                    Module.IsDeleted = false;
                    Module.Header    = txtHeader.Text;
                    Module.Footer    = txtFooter.Text;

                    Module.StartDate = startDatePicker.SelectedDate != null
                                        ? startDatePicker.SelectedDate.Value
                                        : Null.NullDate;

                    Module.EndDate = endDatePicker.SelectedDate != null
                                        ? endDatePicker.SelectedDate.Value
                                        : Null.NullDate;

                    Module.ContainerSrc = moduleContainerCombo.SelectedValue;
                    Module.ModulePermissions.Clear();
                    Module.ModulePermissions.AddRange(dgPermissions.Permissions);
                    Module.Terms.Clear();
                    Module.Terms.AddRange(termsSelector.Terms);

                    if (!Module.IsShared)
                    {
                        Module.InheritViewPermissions = chkInheritPermissions.Checked;
                        Module.IsShareable            = isShareableCheckBox.Checked;
                        Module.IsShareableViewOnly    = isShareableViewOnlyCheckBox.Checked;
                    }

                    Module.DisplayTitle     = chkDisplayTitle.Checked;
                    Module.DisplayPrint     = chkDisplayPrint.Checked;
                    Module.DisplaySyndicate = chkDisplaySyndicate.Checked;
                    Module.IsWebSlice       = chkWebSlice.Checked;
                    Module.WebSliceTitle    = txtWebSliceTitle.Text;

                    Module.WebSliceExpiryDate = diWebSliceExpiry.SelectedDate != null
                                                ? diWebSliceExpiry.SelectedDate.Value
                                                : Null.NullDate;

                    if (!string.IsNullOrEmpty(txtWebSliceTTL.Text))
                    {
                        Module.WebSliceTTL = Convert.ToInt32(txtWebSliceTTL.Text);
                    }
                    Module.IsDefaultModule = chkDefault.Checked;
                    Module.AllModules      = chkAllModules.Checked;
                    ModuleController.Instance.UpdateModule(Module);

                    //Update Custom Settings
                    if (SettingsControl != null)
                    {
                        try
                        {
                            SettingsControl.UpdateSettings();
                        }
                        catch (ThreadAbortException exc)
                        {
                            Logger.Debug(exc);

                            Thread.ResetAbort(); //necessary
                        }
                        catch (Exception ex)
                        {
                            Exceptions.LogException(ex);
                        }
                    }

                    //These Module Copy/Move statements must be
                    //at the end of the Update as the Controller code assumes all the
                    //Updates to the Module have been carried out.

                    //Check if the Module is to be Moved to a new Tab
                    if (!chkAllTabs.Checked)
                    {
                        var newTabId = Int32.Parse(cboTab.SelectedValue);
                        if (TabId != newTabId)
                        {
                            //First check if there already is an instance of the module on the target page
                            var tmpModule = ModuleController.Instance.GetModule(_moduleId, newTabId, false);
                            if (tmpModule == null)
                            {
                                //Move module
                                ModuleController.Instance.MoveModule(_moduleId, TabId, newTabId, Globals.glbDefaultPane);
                            }
                            else
                            {
                                //Warn user
                                Skin.AddModuleMessage(this, Localization.GetString("ModuleExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                                return;
                            }
                        }
                    }

                    //Check if Module is to be Added/Removed from all Tabs
                    if (allTabsChanged)
                    {
                        var listTabs = TabController.GetPortalTabs(PortalSettings.PortalId, Null.NullInteger, false, true);
                        if (chkAllTabs.Checked)
                        {
                            if (!chkNewTabs.Checked)
                            {
                                foreach (var destinationTab in listTabs)
                                {
                                    var module = ModuleController.Instance.GetModule(_moduleId, destinationTab.TabID, false);
                                    if (module != null)
                                    {
                                        if (module.IsDeleted)
                                        {
                                            ModuleController.Instance.RestoreModule(module);
                                        }
                                    }
                                    else
                                    {
                                        if (!PortalSettings.ContentLocalizationEnabled || (Module.CultureCode == destinationTab.CultureCode))
                                        {
                                            ModuleController.Instance.CopyModule(Module, destinationTab, Module.PaneName, true);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            ModuleController.Instance.DeleteAllModules(_moduleId, TabId, listTabs, true, false, false);
                        }
                    }

                    if (!DoNotRedirectOnUpdate)
                    {
                        //Navigate back to admin page
                        Response.Redirect(ReturnURL, true);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 22
0
        private void LoadDisplayTabDropDown()
        {
            ddlDisplayTabId.Items.Clear();

            var modules = new[] { Utility.DnnFriendlyModuleName };
            //we're going to get all pages no matter if they have a Publish module on them or not. We'll only highlight Overrideable ones later
            //if (chkForceDisplayTab.Checked)
            //{
            //    //if the ForceDisplayTab is checked we need to make sure we get ALL publish modules, not just overrideable ones
            //    dt = Utility.GetDisplayTabIdsAll(modules);
            //}
            //else
            //{
            //    dt = Utility.GetDisplayTabIds(modules);
            //    if (dt.Rows.Count < 1)
            //    {
            //        //if there are no items in the list, meaning there are no modules set to be overrideable, then get the list of all Publish pages.
            //        dt = Utility.GetDisplayTabIdsAll(modules);
            //    }
            //}
            DataTable dt = Utility.GetDisplayTabIds(modules);

            //this.ddlDisplayTabId.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-1"));

            ddlDisplayTabId.DataSource = TabController.GetPortalTabs(PortalId, 0, false, true);
            ddlDisplayTabId.DataBind();
            foreach (DataRow dr in dt.Rows)
            {
                if (ddlDisplayTabId.Items.FindByValue(dr["TabID"].ToString()) != null)
                {
                    ddlDisplayTabId.Items.FindByValue(dr["TabID"].ToString()).Text += Localization.GetString("PublishOverrideable", LocalSharedResourceFile);
                }
                //    ListItem li = new ListItem(dr["TabName"] + " (" + dr["TabID"] + ")", dr["TabID"].ToString());
                //    this.ddlDisplayTabId.Items.Add(li);
            }

            //check if the DisplayTabId should be set.
            var av = (Article)VersionInfoObject;

            if (!VersionInfoObject.IsNew)
            {
                ListItem li = ddlDisplayTabId.Items.FindByValue(av.DisplayTabId.ToString(CultureInfo.InvariantCulture));
                if (li != null)
                {
                    ddlDisplayTabId.ClearSelection();
                    li.Selected = true;
                }
                else
                {
                    //if we made it here we've hit an article who is pointing to a page that is no longer overrideable, set the default page.
                    if (DefaultDisplayTabId > 0)
                    {
                        li = ddlDisplayTabId.Items.FindByValue(DefaultDisplayTabId.ToString(CultureInfo.InvariantCulture));
                        if (li != null)
                        {
                            ddlDisplayTabId.ClearSelection();
                            li.Selected = true;
                        }
                    }
                }
            }
            else
            {
                Category parent = null;
                if (ParentId != -1)
                {
                    parent = Category.GetCategory(ParentId, PortalId);
                }

                //look for display tab id
                if (parent != null && parent.ChildDisplayTabId > 0)
                {
                    if (ddlDisplayTabId.Items.FindByValue(parent.ChildDisplayTabId.ToString(CultureInfo.InvariantCulture)) != null)
                    {
                        ddlDisplayTabId.SelectedIndex = -1;
                        ddlDisplayTabId.Items.FindByValue(parent.ChildDisplayTabId.ToString(CultureInfo.InvariantCulture)).Selected = true;
                    }
                }

                else
                {
                    //load the default display tab
                    ListItem li = ddlDisplayTabId.Items.FindByValue(DefaultDisplayTabId.ToString(CultureInfo.InvariantCulture));
                    if (li != null)
                    {
                        ddlDisplayTabId.ClearSelection();
                        li.Selected = true;
                    }
                }
            }
        }