public void btGo_Click(object sender, EventArgs e) { //Setup Child Page - Main View/Activity TabInfo tab = CreatePage(PortalSettings.ActiveTab, PortalId, TabId, "Group Activity", false); //Add Module to Child Page int groupViewModuleId = AddModule(tab, PortalId, "Social Groups", "ContentPaneProfile"); int journalModuleId = AddModule(tab, PortalId, "Journal", "ContentPaneProfile"); int consoleId = AddModule(tab, PortalId, "Console", "RightPaneProfile"); var mc = new ModuleController(); ModuleInfo groupConsoleModule = mc.GetModule(consoleId, tab.TabID); TabInfo memberTab = CreatePage(PortalSettings.ActiveTab, PortalId, tab.TabID, "Members", false); mc.CopyModule(groupConsoleModule, memberTab, "RightPaneProfile", true); ModuleInfo groupViewModule = mc.GetModule(groupViewModuleId, tab.TabID); mc.CopyModule(groupViewModule, memberTab, "ContentPaneProfile", true); AddModule(memberTab, PortalId, "DotNetNuke.Modules.MemberDirectory", "ContentPaneProfile"); //List Settings var modules = new ModuleController(); modules.UpdateTabModuleSetting(TabModuleId, Constants.GroupLoadView, GroupMode.List.ToString()); modules.UpdateTabModuleSetting(TabModuleId, Constants.GroupViewPage, tab.TabID.ToString(CultureInfo.InvariantCulture)); Response.Redirect(Request.RawUrl); }
public void btGo_Click(object sender, EventArgs e) { //Setup Child Page - Main View/Activity TabInfo tab = CreatePage(PortalSettings.ActiveTab, PortalId, TabId, "Group Activity", false); //Add Module to Child Page int groupViewModuleId = AddModule(tab, PortalId, "Social Groups", "ContentPane"); int journalModuleId = AddModule(tab, PortalId, "Journal", "ContentPane"); int consoleId = AddModule(tab, PortalId, "Console", "RightPane"); var mc = new ModuleController(); ModuleInfo groupConsoleModule = mc.GetModule(consoleId, tab.TabID); TabInfo memberTab = CreatePage(PortalSettings.ActiveTab, PortalId, tab.TabID, "Members", false); mc.CopyModule(groupConsoleModule, memberTab, "RightPane", true); ModuleInfo groupViewModule = mc.GetModule(groupViewModuleId, tab.TabID); mc.CopyModule(groupViewModule, memberTab, "ContentPane", true); AddModule(memberTab, PortalId, "DotNetNuke.Modules.MemberDirectory", "ContentPane"); //List Settings var modules = new ModuleController(); modules.UpdateTabModuleSetting(TabModuleId, Constants.GroupLoadView, GroupMode.List.ToString()); modules.UpdateTabModuleSetting(TabModuleId, Constants.GroupViewPage, tab.TabID.ToString(CultureInfo.InvariantCulture)); //Default Social Groups var defaultGroup = RoleController.GetRoleGroupByName(PortalId, Constants.DefaultGroupName); var groupId = -2; if (defaultGroup != null) { groupId = defaultGroup.RoleGroupID; } else { var groupInfo = new RoleGroupInfo(); groupInfo.PortalID = PortalId; groupInfo.RoleGroupName = Constants.DefaultGroupName; groupInfo.Description = Constants.DefaultGroupName; groupId = RoleController.AddRoleGroup(groupInfo); } modules.UpdateTabModuleSetting(TabModuleId, Constants.DefaultRoleGroupSetting, groupId.ToString()); Response.Redirect(Request.RawUrl); }
protected void submitTranslation_Click(object sender, EventArgs e) { var modCtrl = new ModuleController(); var tabCtrl = new TabController(); foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values) { //Make Deep copies of all modules var moduleCtrl = new ModuleController(); foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(Tab.TabID)) { ModuleInfo sourceModule = kvp.Value; ModuleInfo localizedModule = null; //Make sure module has the correct culture code if (string.IsNullOrEmpty(sourceModule.CultureCode)) { sourceModule.CultureCode = Tab.CultureCode; moduleCtrl.UpdateModule(sourceModule); } if (!sourceModule.LocalizedModules.TryGetValue(localizedTab.CultureCode, out localizedModule)) { if (!sourceModule.IsDeleted) { //Shallow (Reference Copy) { if (sourceModule.AllTabs) { foreach (ModuleInfo m in moduleCtrl.GetModuleTabs(sourceModule.ModuleID)) { //Get the tab TabInfo allTabsTab = tabCtrl.GetTab(m.TabID, m.PortalID, false); TabInfo localizedAllTabsTab = null; if (allTabsTab.LocalizedTabs.TryGetValue(localizedTab.CultureCode, out localizedAllTabsTab)) { moduleCtrl.CopyModule(m, localizedAllTabsTab, Null.NullString, true); } } } else { moduleCtrl.CopyModule(sourceModule, localizedTab, Null.NullString, true); } } //Fetch new module localizedModule = moduleCtrl.GetModule(sourceModule.ModuleID, localizedTab.TabID); //Convert to deep copy moduleCtrl.LocalizeModule(localizedModule, LocaleController.Instance.GetLocale(localizedTab.CultureCode)); } } } var users = new Dictionary<int, UserInfo>(); //Give default translators for this language and administrators permissions tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users); //Send Messages to all the translators of new content foreach (var translator in users.Values.Where(user => user.UserID != PortalSettings.AdministratorId)) { AddTranslationSubmittedNotification(localizedTab, translator); } } //Redirect to refresh page (and skinobjects) Response.Redirect(Request.RawUrl, true); }
protected void readyForTranslationButton_Click(object sender, EventArgs e) { var modCtrl = new ModuleController(); var tabCtrl = new TabController(); foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values) { //Make Deep copies of all modules var moduleCtrl = new ModuleController(); foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(Tab.TabID)) { ModuleInfo sourceModule = kvp.Value; ModuleInfo localizedModule = null; //Make sure module has the correct culture code if (string.IsNullOrEmpty(sourceModule.CultureCode)) { sourceModule.CultureCode = Tab.CultureCode; moduleCtrl.UpdateModule(sourceModule); } if (!sourceModule.LocalizedModules.TryGetValue(localizedTab.CultureCode, out localizedModule)) { if (!sourceModule.IsDeleted) { //Shallow (Reference Copy) { if (sourceModule.AllTabs) { foreach (ModuleInfo m in moduleCtrl.GetModuleTabs(sourceModule.ModuleID)) { //Get the tab TabInfo allTabsTab = tabCtrl.GetTab(m.TabID, m.PortalID, false); TabInfo localizedAllTabsTab = null; if (allTabsTab.LocalizedTabs.TryGetValue(localizedTab.CultureCode, out localizedAllTabsTab)) { moduleCtrl.CopyModule(m, localizedAllTabsTab, Null.NullString, true); } } } else { moduleCtrl.CopyModule(sourceModule, localizedTab, Null.NullString, true); } } //Fetch new module localizedModule = moduleCtrl.GetModule(sourceModule.ModuleID, localizedTab.TabID); //Convert to deep copy moduleCtrl.LocalizeModule(localizedModule, LocaleController.Instance.GetLocale(localizedTab.CultureCode)); } } } var users = new Dictionary<int, UserInfo>(); //Give default translators for this language and administrators permissions tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users); //Send Messages to all the translators of new content foreach (UserInfo translator in users.Values) { if (translator.UserID != PortalSettings.AdministratorId) { var message = new Message(); message.FromUserID = PortalSettings.AdministratorId; message.ToUserID = translator.UserID; message.Subject = Localization.GetString("NewContentMessage.Subject", LocalResourceFile); message.Status = MessageStatusType.Unread; message.Body = string.Format(Localization.GetString("NewContentMessage.Body", LocalResourceFile), localizedTab.TabName, Globals.NavigateURL(localizedTab.TabID, false, PortalSettings, Null.NullString, localizedTab.CultureCode, new string[] { })); var messageCtrl = new MessagingController(); messageCtrl.SaveMessage(message); } } } //Redirect to refresh page (and skinobjects) Response.Redirect(Request.RawUrl, true); }
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; }
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 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); }
/// <summary> /// cmdUpdate_Click runs when the Update LinkButton is clicked. /// It saves the current Site Settings /// </summary> /// <history> /// [cnurse] 10/18/2004 documented /// [cnurse] 10/19/2004 modified to support custm module specific settings /// </history> protected void cmdUpdate_Click( object Sender, EventArgs e ) { try { if( Page.IsValid ) { ModuleController objModules = new ModuleController(); bool AllTabsChanged = false; // tab administrators can only manage their own tab if( PortalSecurity.IsInRoles( PortalSettings.AdministratorRoleName ) == false ) { chkAllTabs.Enabled = false; chkDefault.Enabled = false; chkAllModules.Enabled = false; cboTab.Enabled = false; } // update module ModuleInfo objModule = objModules.GetModule( moduleId, TabId, false ); objModule.ModuleID = moduleId; objModule.ModuleTitle = txtTitle.Text; objModule.Alignment = cboAlign.SelectedItem.Value; objModule.Color = txtColor.Text; objModule.Border = txtBorder.Text; objModule.IconFile = ctlIcon.Url; if( !String.IsNullOrEmpty( txtCacheTime.Text ) ) { objModule.CacheTime = int.Parse( txtCacheTime.Text ); } else { objModule.CacheTime = 0; } objModule.TabID = TabId; if( objModule.AllTabs != chkAllTabs.Checked ) { AllTabsChanged = true; } objModule.AllTabs = chkAllTabs.Checked; switch( int.Parse( cboVisibility.SelectedItem.Value ) ) { case 0: objModule.Visibility = VisibilityState.Maximized; break; case 1: objModule.Visibility = VisibilityState.Minimized; break; case 2: objModule.Visibility = VisibilityState.None; break; } objModule.IsDeleted = false; objModule.Header = txtHeader.Text; objModule.Footer = txtFooter.Text; if( !String.IsNullOrEmpty( txtStartDate.Text ) ) { objModule.StartDate = Convert.ToDateTime( txtStartDate.Text ); } else { objModule.StartDate = Null.NullDate; } if( !String.IsNullOrEmpty( txtEndDate.Text ) ) { objModule.EndDate = Convert.ToDateTime( txtEndDate.Text ); } else { objModule.EndDate = Null.NullDate; } objModule.ContainerSrc = ctlModuleContainer.SkinSrc; objModule.ModulePermissions = dgPermissions.Permissions; objModule.InheritViewPermissions = chkInheritPermissions.Checked; objModule.DisplayTitle = chkDisplayTitle.Checked; objModule.DisplayPrint = chkDisplayPrint.Checked; objModule.DisplaySyndicate = chkDisplaySyndicate.Checked; objModule.IsDefaultModule = chkDefault.Checked; objModule.AllModules = chkAllModules.Checked; objModules.UpdateModule( objModule ); //Update Custom Settings if( ctlSpecific != null ) { ctlSpecific.UpdateSettings(); } //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 ) { int newTabId = int.Parse( cboTab.SelectedItem.Value ); if( TabId != newTabId ) { objModules.MoveModule( moduleId, TabId, newTabId, "" ); } } //'Check if Module is to be Added/Removed from all Tabs if( AllTabsChanged ) { ArrayList arrTabs = Globals.GetPortalTabs( PortalSettings.DesktopTabs, false, true ); if( chkAllTabs.Checked ) { objModules.CopyModule( moduleId, TabId, arrTabs, true ); } else { objModules.DeleteAllModules( moduleId, TabId, arrTabs, false, false ); } } // Navigate back to admin page Response.Redirect( Globals.NavigateURL(), true ); } } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } }
/// <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(); } }