public int AddTab( TabInfo objTab, bool AddAllTabsModules )
        {
            int intTabId;

            objTab.TabPath = Globals.GenerateTabPath( objTab.ParentId, objTab.TabName );
            intTabId = DataProvider.Instance().AddTab( objTab.PortalID, objTab.TabName, objTab.IsVisible, objTab.DisableLink, objTab.ParentId, objTab.IconFile, objTab.Title, objTab.Description, objTab.KeyWords, objTab.Url, objTab.SkinSrc, objTab.ContainerSrc, objTab.TabPath, objTab.StartDate, objTab.EndDate, objTab.RefreshInterval, objTab.PageHeadText );

            TabPermissionController objTabPermissionController = new TabPermissionController();

            if( objTab.TabPermissions != null )
            {
                TabPermissionCollection objTabPermissions = objTab.TabPermissions;

                foreach( TabPermissionInfo objTabPermission in objTabPermissions )
                {
                    objTabPermission.TabID = intTabId;
                    if( objTabPermission.AllowAccess )
                    {
                        objTabPermissionController.AddTabPermission( objTabPermission );
                    }
                }
            }
            if( !( Null.IsNull( objTab.PortalID ) ) )
            {
                UpdatePortalTabOrder( objTab.PortalID, intTabId, objTab.ParentId, 0, 0, objTab.IsVisible, true );
            }
            else // host tab
            {
                ArrayList arrTabs = GetTabsByParentId( objTab.ParentId, objTab.PortalID );
                UpdateTabOrder( objTab.PortalID, intTabId, ( arrTabs.Count*2 ) - 1, 1, objTab.ParentId );
            }

            if( AddAllTabsModules )
            {
                ModuleController objmodules = new ModuleController();
                ArrayList arrMods = objmodules.GetAllTabsModules( objTab.PortalID, true );

                foreach( ModuleInfo objModule in arrMods )
                {
                    objmodules.CopyModule( objModule.ModuleID, objModule.TabID, intTabId, "", true );
                }
            }

            ClearCache( objTab.PortalID );

            return intTabId;
        }
Example #2
0
        /// <summary>
        /// Restores the tab.
        /// </summary>
        /// <param name="tab">The obj tab.</param>
        /// <param name="portalSettings">The portal settings.</param>
        public void RestoreTab(TabInfo tab, PortalSettings portalSettings)
        {
            if (tab.DefaultLanguageTab != null)
            {
                //We are trying to restore the child, so recall this function with the master language's tab id
                RestoreTab(tab.DefaultLanguageTab, portalSettings);
                return;
            }

            tab.IsDeleted = false;
            UpdateTab(tab);

            //Restore any localized children
            foreach (TabInfo localizedtab in tab.LocalizedTabs.Values)
            {
                localizedtab.IsDeleted = false;
                UpdateTab(localizedtab);
            }

            var eventLogController = new EventLogController();
            eventLogController.AddLog(tab, portalSettings, portalSettings.UserId, "",
                                      EventLogController.EventLogType.TAB_RESTORED);

            var moduleController = new ModuleController();
            ArrayList allTabsModules = moduleController.GetAllTabsModules(tab.PortalID, true);
            foreach (ModuleInfo objModule in allTabsModules)
            {
                moduleController.CopyModule(objModule, tab, Null.NullString, true);
            }

            ClearCache(tab.PortalID);
        }
Example #3
0
 private static void AddAllTabsModules(TabInfo tab)
 {
     var objmodules = new ModuleController();
     var portalSettings = new PortalSettings(tab.TabID, tab.PortalID);
     foreach (ModuleInfo allTabsModule in objmodules.GetAllTabsModules(tab.PortalID, true))
     {
         //[DNN-6276]We need to check that the Module is not implicitly deleted.  ie If all instances are on Pages
         //that are all "deleted" then even if the Module itself is not deleted, we would not expect the 
         //Module to be added
         var canAdd =
         (from ModuleInfo allTabsInstance in objmodules.GetModuleTabs(allTabsModule.ModuleID) select new TabController().GetTab(allTabsInstance.TabID, tab.PortalID, false)).Any(
             t => !t.IsDeleted) && (!portalSettings.ContentLocalizationEnabled || allTabsModule.CultureCode == tab.CultureCode);
         if (canAdd)
         {
             objmodules.CopyModule(allTabsModule, tab, Null.NullString, true);
         }
     }
 }
        /// <summary>
        /// Restores selected tabs in the listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Adds a log entry for each restored tab to the EventLog
        /// Redirects to same page after restoring so the menu can be refreshed with restored tabs.
        /// This will not restore deleted modules for selected tabs, only the tabs are restored.
        /// </remarks>
        /// <history>
        /// 	[VMasanas]	18/08/2004	Added support for multiselect listbox
        ///                 30/09/2004  Child tabs cannot be restored until their parent is restored first.
        ///                             Change logic so log is only added when tab is actually restored
        /// </history>
        protected void cmdRestoreTab_Click( Object sender, ImageClickEventArgs e )
        {
            ListItem item;
            bool errors = false;

            foreach( ListItem tempLoopVar_item in lstTabs.Items )
            {
                item = tempLoopVar_item;
                if( item.Selected )
                {
                    EventLogController objEventLog = new EventLogController();
                    TabController objTabs = new TabController();

                    TabInfo objTab = objTabs.GetTab( int.Parse( item.Value ) );
                    if( objTab != null )
                    {
                        if( Null.IsNull( objTab.ParentId ) && lstTabs.Items.FindByValue( objTab.ParentId.ToString() ) != null )
                        {
                            UI.Skins.Skin.AddModuleMessage( this, string.Format( Localization.GetString( "ChildTab.ErrorMessage", this.LocalResourceFile ), objTab.TabName ), ModuleMessageType.YellowWarning );
                            errors = true;
                        }
                        else
                        {
                            objTab.IsDeleted = false;
                            objTabs.UpdateTab( objTab );
                            objEventLog.AddLog( objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_RESTORED );

                            ModuleController objmodules = new ModuleController();
                            ArrayList arrMods = objmodules.GetAllTabsModules( objTab.PortalID, true );

                            foreach( ModuleInfo objModule in arrMods )
                            {
                                objmodules.CopyModule( objModule.ModuleID, objModule.TabID, objTab.TabID, "", true );
                            }
                        }
                    }
                }
            }
            if( ! errors )
            {
                Response.Redirect( Globals.NavigateURL() );
            }
            else
            {
                BindData();
            }
        }