//this has an overload of whether or not to create a cloned module private void DoAddExistingModule(int moduleId, int tabId, string paneName, int position, string align, bool cloneModule) { var moduleCtrl = new ModuleController(); ModuleInfo moduleInfo = moduleCtrl.GetModule(moduleId, tabId, false); int userID = -1; if (Request.IsAuthenticated) { UserInfo user = UserController.GetCurrentUserInfo(); if (((user != null))) { userID = user.UserID; } } if ((moduleInfo != null)) { // clone the module object ( to avoid creating an object reference to the data cache ) ModuleInfo newModule = moduleInfo.Clone(); newModule.UniqueId = Guid.NewGuid(); // Cloned Module requires a different uniqueID newModule.TabID = PortalSettings.Current.ActiveTab.TabID; newModule.ModuleOrder = position; newModule.PaneName = paneName; newModule.Alignment = align; if ((cloneModule)) { newModule.ModuleID = Null.NullInteger; //reset the module id newModule.ModuleID = moduleCtrl.AddModule(newModule); if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass)) { object objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass); if (objObject is IPortable) { string content = Convert.ToString(((IPortable)objObject).ExportModule(moduleId)); if (!string.IsNullOrEmpty(content)) { ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, userID); } } } } else { moduleCtrl.AddModule(newModule); } //Add Event Log var objEventLog = new EventLogController(); objEventLog.AddLog(newModule, PortalSettings.Current, userID, "", EventLogController.EventLogType.MODULE_CREATED); } }
protected void AddExistingModule(int moduleId, int tabId, string paneName, int position, string align) { ModuleController objModules = new ModuleController(); ModuleInfo objModule; Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); int UserId = -1; if (Request.IsAuthenticated) { UserInfo objUserInfo = UserController.GetCurrentUserInfo(); UserId = objUserInfo.UserID; } objModule = objModules.GetModule(moduleId, tabId, false); if (objModule != null) { ModuleInfo objClone = objModule.Clone(); objClone.TabID = PortalSettings.ActiveTab.TabID; objClone.ModuleOrder = position; objClone.PaneName = paneName; objClone.Alignment = align; objModules.AddModule(objClone); objEventLog.AddLog(objClone, PortalSettings, UserId, "", Services.Log.EventLog.EventLogController.EventLogType.MODULE_CREATED); } }
private void AddModuleToTab(TabInfo ti, DesktopModuleInfo dmi, string title = "", string paneName = "ContentPane", Dictionary <String, String> settings = null) { if (title == "") { title = dmi.ContentTitle; } PortalSettings ps = new PortalSettings(); int portalId = ps.PortalId; DesktopModuleInfo desktopModuleInfo = null; foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(portalId)) { DesktopModuleInfo mod = kvp.Value; if (mod != null) { if ((mod.FriendlyName == dmi.FriendlyName || mod.ModuleName == dmi.FriendlyName)) { desktopModuleInfo = mod; } } } if (desktopModuleInfo != null && ti != null) { foreach (ModuleDefinitionInfo moduleDefinitionInfo in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleInfo.DesktopModuleID).Values) { ModuleInfo moduleInfo = new ModuleInfo(); moduleInfo.PortalID = portalId; moduleInfo.TabID = ti.TabID; moduleInfo.ModuleOrder = 1; moduleInfo.ModuleTitle = title; moduleInfo.PaneName = paneName; moduleInfo.ModuleDefID = moduleDefinitionInfo.ModuleDefID; moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime; moduleInfo.InheritViewPermissions = true; moduleInfo.AllTabs = false; ModuleController moduleController = new ModuleController(); if (settings != null) { foreach (KeyValuePair <String, String> kvp in settings) { if (kvp.Key.Contains("tabid")) { TabController tc = new TabController(); int id = tc.GetTabByName(kvp.Value, portalId).TabID; moduleInfo.ModuleSettings.Add(kvp.Key, id); moduleController.UpdateModuleSetting(moduleInfo.ModuleID, kvp.Key, "" + id); } else { moduleInfo.ModuleSettings.Add(kvp.Key, kvp.Value); moduleController.UpdateModuleSetting(moduleInfo.ModuleID, kvp.Key, kvp.Value); } } } int moduleId = moduleController.AddModule(moduleInfo); } } }
private static void GenerateAdminTab(string friendlyModuleName, int portalId) { var tabId = TabController.GetTabByTabPath(portalId, $"//Admin//{friendlyModuleName}", Null.NullString); if (tabId == Null.NullInteger) { var adminTabId = TabController.GetTabByTabPath(portalId, @"//Admin", Null.NullString); // create new page int parentTabId = adminTabId; var tabName = friendlyModuleName; var tabPath = Globals.GenerateTabPath(parentTabId, tabName); tabId = TabController.GetTabByTabPath(portalId, tabPath, Null.NullString); if (tabId == Null.NullInteger) { //Create a new page var newTab = new TabInfo { TabName = tabName, ParentId = parentTabId, PortalID = portalId, IsVisible = true, IconFile = "~/Images/icon_search_16px.gif", IconFileLarge = "~/Images/icon_search_32px.gif" }; newTab.TabID = new TabController().AddTab(newTab, false); tabId = newTab.TabID; } } // create new module var moduleCtl = new ModuleController(); if (moduleCtl.GetTabModules(tabId).Count == 0) { var dm = DesktopModuleController.GetDesktopModuleByModuleName(friendlyModuleName, portalId); var md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(friendlyModuleName, dm.DesktopModuleID); var objModule = new ModuleInfo { PortalID = portalId, TabID = tabId, ModuleOrder = Null.NullInteger, ModuleTitle = friendlyModuleName, PaneName = Globals.glbDefaultPane, ModuleDefID = md.ModuleDefID, InheritViewPermissions = true, AllTabs = false, IconFile = "~/Images/icon_search_32px.gif" }; moduleCtl.AddModule(objModule); } }
public static int AddModuleToPage(TabInfo page, int moduleDefId, string moduleTitle, string moduleIconFile, bool inheritPermissions) { var moduleController = new ModuleController(); ModuleInfo moduleInfo; var moduleId = Null.NullInteger; if ((page != null)) { var isDuplicate = false; foreach (var kvp in moduleController.GetTabModules(page.TabID)) { moduleInfo = kvp.Value; if (moduleInfo.ModuleDefID == moduleDefId) { isDuplicate = true; moduleId = moduleInfo.ModuleID; } } if (!isDuplicate) { moduleInfo = new ModuleInfo { ModuleID = Null.NullInteger, PortalID = page.PortalID, TabID = page.TabID, ModuleOrder = -1, ModuleTitle = moduleTitle, PaneName = Globals.glbDefaultPane, ModuleDefID = moduleDefId, CacheTime = 0, IconFile = moduleIconFile, AllTabs = false, Visibility = VisibilityState.None, InheritViewPermissions = inheritPermissions }; try { moduleId = moduleController.AddModule(moduleInfo); } catch (Exception) { //DnnLog.Error(exc); } } } return(moduleId); }
/// <summary> /// Copies the module to page. /// </summary> /// <param name="moduleToCopy">The module to copy.</param> /// <param name="destinationTabID">The destination tab ID.</param> private static void CopyModuleToPage(ModuleInfo moduleToCopy, int destinationTabID) { var moduleController = new ModuleController(); // duplicate the module and assign it the new page ModuleInfo newModule = moduleToCopy.Clone(); newModule.ModuleID = -1; newModule.TabID = destinationTabID; // add it to the system - this takes care of adding the // module and the tab module newModule.ModuleID = moduleController.AddModule(newModule); // duplicate the settings for the module DuplicateModuleSettings(moduleToCopy, newModule.ModuleID); // duplicate the settings for the tabmodule moduleController.CopyTabModuleSettings(moduleToCopy, newModule); }
/// <summary> /// Adds the module to page. /// </summary> /// <param name="portalId">The portal id.</param> /// <param name="tabId">The tab id.</param> /// <exception cref="System.ArgumentException">desktopModuleId</exception> private void AddModuleToPage(int portalId, int tabId) { TabPermissionCollection objTabPermissions = new TabController().GetTab(tabId, portalId, false).TabPermissions; var objPermissionController = new PermissionController(); var objModules = new ModuleController(); new EventLogController(); int desktopModuleId = DesktopModuleController.GetDesktopModuleByFriendlyName("VanityURLs").DesktopModuleID; try { DesktopModuleInfo desktopModule; if (!DesktopModuleController.GetDesktopModules(portalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.PortalID = portalId; objModule.TabID = tabId; objModule.ModuleOrder = 0; objModule.ModuleTitle = objModuleDefinition.FriendlyName; objModule.PaneName = "ContentPane"; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; objModule.InheritViewPermissions = true; objModule.CultureCode = Null.NullString; objModule.AllTabs = false; objModules.AddModule(objModule); } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } try { if (moduleId == 0) //add new module { ModuleInfo newmodule = new ModuleInfo(); newmodule.ModuleName = txtModuleName.Text.Trim(); newmodule.ModuleTitle = txtModuleTitle.Text.Trim(); newmodule.ModuleDescription = txtModuleDescription.Text.Trim(); newmodule.ModuleFolder = txtModuleFolder.Text.Trim(); txtID.Text = ModuleController.AddModule(newmodule).ToString(); this.btnAddControl.Visible = true; this.btnDelete.Visible = true; } else //update module { module = ModuleController.GetModule(moduleId); if (module == null) { return; } module.ModuleName = txtModuleName.Text.Trim(); module.ModuleTitle = txtModuleTitle.Text.Trim(); module.ModuleDescription = txtModuleDescription.Text.Trim(); module.ModuleFolder = txtModuleFolder.Text.Trim(); ModuleController.UpdateModule(module); txtID.Text = module.ModuleID.ToString(); } this.lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS; } catch (Exception ex) { Response.Write(ex.Message); } }
public void CopyTab(int PortalId, int FromTabId, int ToTabId, bool IncludeContent) { ModuleController objModules = new ModuleController(); foreach (KeyValuePair <int, ModuleInfo> kvp in objModules.GetTabModules(FromTabId)) { ModuleInfo objModule = kvp.Value; // if the module shows on all pages does not need to be copied since it will // be already added to this page if (!objModule.AllTabs) { if (IncludeContent == false) { objModule.ModuleID = Null.NullInteger; } objModule.TabID = ToTabId; objModules.AddModule(objModule); } } }
/// ----------------------------------------------------------------------------- /// <summary> /// Adds a New Module to a Pane /// </summary> /// <param name="align">The alignment for the Modue</param> /// <param name="desktopModuleId">The Id of the DesktopModule</param> /// <param name="permissionType">The View Permission Type for the Module</param> /// <param name="title">The Title for the resulting module</param> /// <param name="paneName">The pane to add the module to</param> /// <param name="position">The relative position within the pane for the module</param> /// <history> /// [cnurse] 01/11/2008 documented /// </history> /// ----------------------------------------------------------------------------- protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align) { TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions; var objPermissionController = new PermissionController(); var objModules = new ModuleController(); try { DesktopModuleInfo desktopModule; if (!DesktopModuleController.GetDesktopModules(PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } int UserId = -1; if (Request.IsAuthenticated) { UserInfo objUserInfo = UserController.GetCurrentUserInfo(); UserId = objUserInfo.UserID; } foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.PortalId); objModule.PortalID = PortalSettings.PortalId; objModule.TabID = PortalSettings.ActiveTab.TabID; objModule.ModuleOrder = position; if (String.IsNullOrEmpty(title)) { objModule.ModuleTitle = objModuleDefinition.FriendlyName; } else { objModule.ModuleTitle = title; } objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; if (objModuleDefinition.DefaultCacheTime > 0) { objModule.CacheTime = objModuleDefinition.DefaultCacheTime; if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger) { ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if (defaultModule != null) { objModule.CacheTime = defaultModule.CacheTime; } } } switch (permissionType) { case ViewPermissionType.View: objModule.InheritViewPermissions = true; break; case ViewPermissionType.Edit: objModule.InheritViewPermissions = false; break; } //get the default module view permissions ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); //get the permissions from the page foreach (TabPermissionInfo objTabPermission in objTabPermissions) { if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View) { //Don't need to explicitly add View permisisons if "Same As Page" continue; } //get the system module permissions for the permissionkey ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); //loop through the system module permissions int j; for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++) { PermissionInfo objSystemModulePermission; objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j]; if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT") { //Only Page Editors get View permissions if "Page Editors Only" continue; } ModulePermissionInfo objModulePermission = AddModulePermission(objModule, objSystemModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); //ensure that every EDIT permission which allows access also provides VIEW permission if (objModulePermission.PermissionKey == "EDIT" && objModulePermission.AllowAccess) { ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule, (PermissionInfo)arrSystemModuleViewPermissions[0], objModulePermission.RoleID, objModulePermission.UserID, true); } } //Get the custom Module Permissions, Assume that roles with Edit Tab Permissions //are automatically assigned to the Custom Module Permissions if (objTabPermission.PermissionKey == "EDIT") { ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID); //loop through the custom module permissions for (j = 0; j <= arrCustomModulePermissions.Count - 1; j++) { //create the module permission PermissionInfo objCustomModulePermission; objCustomModulePermission = (PermissionInfo)arrCustomModulePermissions[j]; AddModulePermission(objModule, objCustomModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); } } } objModule.AllTabs = false; objModule.Alignment = align; objModules.AddModule(objModule); } }
protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align) { TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions; PermissionController objPermissionController = new PermissionController(); ModuleController objModules = new ModuleController(); ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController(); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); int intIndex; try { DesktopModuleController objDesktopModules = new DesktopModuleController(); ArrayList arrDM = objDesktopModules.GetDesktopModulesByPortal(PortalSettings.PortalId); bool isSelectable = false; for (int intloop = 0; intloop < arrDM.Count; intloop++) { if (((DesktopModuleInfo)(arrDM[intloop])).DesktopModuleID == desktopModuleId) { isSelectable = true; break; } } if (isSelectable == false) { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } int UserId = -1; if (Request.IsAuthenticated) { UserInfo objUserInfo = UserController.GetCurrentUserInfo(); UserId = objUserInfo.UserID; } ArrayList arrModuleDefinitions = objModuleDefinitions.GetModuleDefinitions(desktopModuleId); for (intIndex = 0; intIndex < arrModuleDefinitions.Count; intIndex++) { ModuleDefinitionInfo objModuleDefinition = (ModuleDefinitionInfo)(arrModuleDefinitions[intIndex]); ModuleInfo objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.PortalId); objModule.PortalID = PortalSettings.PortalId; objModule.TabID = PortalSettings.ActiveTab.TabID; objModule.ModuleOrder = position; if (String.IsNullOrEmpty(title)) { objModule.ModuleTitle = objModuleDefinition.FriendlyName; } else { objModule.ModuleTitle = title; } objModule.ModuleTitle = title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; objModule.CacheTime = objModuleDefinition.DefaultCacheTime; // initialize module permissions ModulePermissionCollection objModulePermissions = new ModulePermissionCollection(); objModule.ModulePermissions = objModulePermissions; objModule.InheritViewPermissions = false; // get the default module view permissions ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); // get the permissions from the page foreach (TabPermissionInfo objTabPermission in objTabPermissions) { // get the system module permissions for the permissionkey ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); // loop through the system module permissions int j; for (j = 0; j < arrSystemModulePermissions.Count; j++) { // create the module permission PermissionInfo objSystemModulePermission = (PermissionInfo)(arrSystemModulePermissions[j]); ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objSystemModulePermission, objTabPermission.RoleID); // add the permission to the collection if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess) { objModulePermissions.Add(objModulePermission); } // ensure that every EDIT permission which allows access also provides VIEW permission if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess) { ModulePermissionInfo objModuleViewperm = new ModulePermissionInfo(); objModuleViewperm.ModuleID = objModulePermission.ModuleID; objModuleViewperm.PermissionID = ((PermissionInfo)(arrSystemModuleViewPermissions[0])).PermissionID; objModuleViewperm.RoleID = objModulePermission.RoleID; objModuleViewperm.PermissionKey = "VIEW"; objModuleViewperm.AllowAccess = true; if (!(objModulePermissions.Contains(objModuleViewperm))) { objModulePermissions.Add(objModuleViewperm); } } } //Get the custom Module Permissions, Assume that roles with Edit Tab Permissions //are automatically assigned to the Custom Module Permissions if (objTabPermission.PermissionKey == "EDIT") { ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID); // loop through the custom module permissions for (j = 0; j < arrCustomModulePermissions.Count; j++) { // create the module permission PermissionInfo objCustomModulePermission = (PermissionInfo)(arrCustomModulePermissions[j]); ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objCustomModulePermission, objTabPermission.RoleID); // add the permission to the collection if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess) { objModulePermissions.Add(objModulePermission); } } } } switch (permissionType) { case ViewPermissionType.View: objModule.InheritViewPermissions = true; break; case ViewPermissionType.Edit: objModule.ModulePermissions = objModulePermissions; break; } objModule.AllTabs = false; objModule.Visibility = VisibilityState.Maximized; objModule.Alignment = align; objModules.AddModule(objModule); objEventLog.AddLog(objModule, PortalSettings, UserId, "", Services.Log.EventLog.EventLogController.EventLogType.MODULE_CREATED); } }
protected void cmdCreate_Click(object sender, EventArgs e) { try { ModuleDefinitionInfo moduleDefinition = null; string strMessage = Null.NullString; switch (cboCreate.SelectedValue) { case "": break; case "New": if (String.IsNullOrEmpty(cboModule.SelectedValue)) { strMessage = Localization.GetString("ModuleFolder", LocalResourceFile); break; } if (String.IsNullOrEmpty(rblLanguage.SelectedValue)) { strMessage = Localization.GetString("LanguageError", LocalResourceFile); break; } //remove spaces so file is created correctly var controlSrc = txtFile.Text.Replace(" ", ""); if (InvalidFilename(controlSrc)) { strMessage = Localization.GetString("InvalidFilename", LocalResourceFile); break; } if (String.IsNullOrEmpty(controlSrc)) { strMessage = Localization.GetString("MissingControl", LocalResourceFile); break; } if (String.IsNullOrEmpty(txtName.Text)) { strMessage = Localization.GetString("MissingFriendlyname", LocalResourceFile); break; } if (!controlSrc.EndsWith(".ascx")) { controlSrc += ".ascx"; } var uniqueName = true; var packages = new List <PackageInfo>(); foreach (var package in PackageController.Instance.GetExtensionPackages(Null.NullInteger)) { if (package.Name == txtName.Text || package.FriendlyName == txtName.Text) { uniqueName = false; break; } } if (!uniqueName) { strMessage = Localization.GetString("NonuniqueName", LocalResourceFile); break; } //First create the control strMessage = CreateControl(controlSrc); if (String.IsNullOrEmpty(strMessage)) { //Next import the control moduleDefinition = ImportControl(controlSrc); } break; case "Control": if (!String.IsNullOrEmpty(cboFile.SelectedValue)) { moduleDefinition = ImportControl(cboFile.SelectedValue); } else { strMessage = Localization.GetString("NoControl", LocalResourceFile); } break; case "Template": break; case "Manifest": if (String.IsNullOrEmpty(cboFile.SelectedValue)) { strMessage = Localization.GetString("MissingManifest", LocalResourceFile); } else { moduleDefinition = ImportManifest(); } break; } if (moduleDefinition == null) { UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError); } else { if (!string.IsNullOrEmpty(cboCreate.SelectedValue) && chkAddPage.Checked) { var tabName = "Test " + txtName.Text + " Page"; var tabPath = Globals.GenerateTabPath(Null.NullInteger, tabName); var tabID = TabController.GetTabByTabPath(ModuleContext.PortalId, tabPath, Null.NullString); if (tabID == Null.NullInteger) { //Create a new page var newTab = new TabInfo(); newTab.TabName = "Test " + txtName.Text + " Page"; newTab.ParentId = Null.NullInteger; newTab.PortalID = ModuleContext.PortalId; newTab.IsVisible = true; newTab.TabID = new TabController().AddTabBefore(newTab, ModuleContext.PortalSettings.AdminTabId); var objModule = new ModuleInfo(); objModule.Initialize(ModuleContext.PortalId); objModule.PortalID = ModuleContext.PortalId; objModule.TabID = newTab.TabID; objModule.ModuleOrder = Null.NullInteger; objModule.ModuleTitle = moduleDefinition.FriendlyName; objModule.PaneName = Globals.glbDefaultPane; objModule.ModuleDefID = moduleDefinition.ModuleDefID; objModule.InheritViewPermissions = true; objModule.AllTabs = false; var moduleCtl = new ModuleController(); moduleCtl.AddModule(objModule); Response.Redirect(Globals.NavigateURL(newTab.TabID), true); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } } else { //Redirect to main extensions page Response.Redirect(Globals.NavigateURL(), true); } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// Restores selected modules in the listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Adds a log entry for each restored module to the EventLog /// </remarks> /// <history> /// [VMasanas] 18/08/2004 Added support for multiselect listbox /// </history> protected void cmdRestoreModule_Click(Object sender, ImageClickEventArgs e) { EventLogController objEventLog = new EventLogController(); ModuleController objModules = new ModuleController(); ListItem item; if (cboTab.SelectedItem != null) { foreach (ListItem tempLoopVar_item in lstModules.Items) { item = tempLoopVar_item; if (item.Selected) { ModuleInfo objModule = objModules.GetModule(int.Parse(item.Value), Null.NullInteger); if (objModule != null) { objModule.IsDeleted = false; objModule.TabID = Null.NullInteger; objModules.UpdateModule(objModule); // set defaults objModule.CacheTime = 0; objModule.Alignment = ""; objModule.Color = ""; objModule.Border = ""; objModule.IconFile = ""; objModule.Visibility = VisibilityState.Maximized; objModule.ContainerSrc = ""; objModule.DisplayTitle = true; objModule.DisplayPrint = true; objModule.DisplaySyndicate = false; objModule.AllTabs = false; // get default module settings Hashtable settings = PortalSettings.GetSiteSettings(PortalId); if (Convert.ToString(settings["defaultmoduleid"]) != "" && Convert.ToString(settings["defaulttabid"]) != "") { ModuleInfo objDefaultModule = objModules.GetModule(int.Parse(Convert.ToString(settings["defaultmoduleid"])), int.Parse(Convert.ToString(settings["defaulttabid"]))); if (objDefaultModule != null) { objModule.CacheTime = objDefaultModule.CacheTime; objModule.Alignment = objDefaultModule.Alignment; objModule.Color = objDefaultModule.Color; objModule.Border = objDefaultModule.Border; objModule.IconFile = objDefaultModule.IconFile; objModule.Visibility = objDefaultModule.Visibility; objModule.ContainerSrc = objDefaultModule.ContainerSrc; objModule.DisplayTitle = objDefaultModule.DisplayTitle; objModule.DisplayPrint = objDefaultModule.DisplayPrint; objModule.DisplaySyndicate = objDefaultModule.DisplaySyndicate; } } // add tab module objModule.TabID = int.Parse(cboTab.SelectedItem.Value); objModule.PaneName = Globals.glbDefaultPane; objModule.ModuleOrder = -1; objModules.AddModule(objModule); objEventLog.AddLog(objModule, PortalSettings, UserId, "", EventLogController.EventLogType.MODULE_RESTORED); } } } BindData(); } }
protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align) { TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions; PermissionController objPermissionController = new PermissionController(); ModuleController objModules = new ModuleController(); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); int j; try { DesktopModuleInfo desktopModule = null; if (!DesktopModuleController.GetDesktopModules(PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } int UserId = -1; if (Request.IsAuthenticated) { UserInfo objUserInfo = UserController.GetCurrentUserInfo(); UserId = objUserInfo.UserID; } foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { ModuleInfo objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.PortalId); objModule.PortalID = PortalSettings.PortalId; objModule.TabID = PortalSettings.ActiveTab.TabID; objModule.ModuleOrder = position; if (String.IsNullOrEmpty(title)) { objModule.ModuleTitle = objModuleDefinition.FriendlyName; } else { objModule.ModuleTitle = title; } objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; if (objModuleDefinition.DefaultCacheTime > 0) { objModule.CacheTime = objModuleDefinition.DefaultCacheTime; if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger) { ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if (defaultModule != null) { objModule.CacheTime = defaultModule.CacheTime; } } } switch (permissionType) { case ViewPermissionType.View: objModule.InheritViewPermissions = true; break; case ViewPermissionType.Edit: objModule.InheritViewPermissions = false; break; } ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); foreach (TabPermissionInfo objTabPermission in objTabPermissions) { if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View) { continue; } ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++) { PermissionInfo objSystemModulePermission; objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j]; if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT") { continue; } ModulePermissionInfo objModulePermission = AddModulePermission(objModule, objSystemModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); if (objModulePermission.PermissionKey == "EDIT" && objModulePermission.AllowAccess) { ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule, (PermissionInfo)arrSystemModuleViewPermissions[0], objModulePermission.RoleID, objModulePermission.UserID, true); } } if (objTabPermission.PermissionKey == "EDIT") { ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID); for (j = 0; j <= arrCustomModulePermissions.Count - 1; j++) { PermissionInfo objCustomModulePermission; objCustomModulePermission = (PermissionInfo)arrCustomModulePermissions[j]; AddModulePermission(objModule, objCustomModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); } } } objModule.AllTabs = false; objModule.Alignment = align; objModules.AddModule(objModule); } }
public int AddModuleToPage(TabInfo t, ModuleType type) { string DesktopModuleFriendlyName = ""; string ModuleDefFriendlyName = ""; ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo(); ModuleInfo moduleInfo = new ModuleInfo(); moduleInfo.PortalID = t.PortalID; moduleInfo.TabID = t.TabID; moduleInfo.ModuleOrder = 1; moduleInfo.ModuleTitle = ""; moduleInfo.DisplayPrint = false; moduleInfo.IsShareable = true; moduleInfo.IsShareableViewOnly = true; switch (type) { case ModuleType.DisplayPlugg: moduleInfo.PaneName = "RowTwo_Grid8_Pane"; DesktopModuleFriendlyName = "DisplayPlugg"; ModuleDefFriendlyName = "DisplayPlugg"; break; case ModuleType.DisplayCourse: moduleInfo.PaneName = "RowTwo_Grid8_Pane"; DesktopModuleFriendlyName = "DisplayCourse"; ModuleDefFriendlyName = "DisplayCourse"; break; case ModuleType.CourseMenu: moduleInfo.PaneName = "RowTwo_Grid4_Pane"; DesktopModuleFriendlyName = "CourseMenu"; ModuleDefFriendlyName = "CourseMenu"; break; case ModuleType.Rating: moduleInfo.PaneName = "RowTwo_Grid4_Pane"; DesktopModuleFriendlyName = "DNNCentric RnC"; ModuleDefFriendlyName = "DNNCentric.RatingAndComments"; break; case ModuleType.Comments: moduleInfo.PaneName = "RowTwo_Grid8_Pane"; DesktopModuleFriendlyName = "DNNCentric RnC"; ModuleDefFriendlyName = "DNNCentric.RatingAndComments"; break; case ModuleType.DisplayPluggeTitle: moduleInfo.PaneName = "RowTwo_Grid4_Pane"; DesktopModuleFriendlyName = "DisplayPluggeTitle"; ModuleDefFriendlyName = "DisplayPluggeTitle"; break; } DesktopModuleInfo myModule = null; foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(t.PortalID)) { DesktopModuleInfo mod = kvp.Value; if (mod != null) { if (mod.FriendlyName == DesktopModuleFriendlyName) { myModule = mod; break; } } } int moduleId = 0; if (myModule != null) { var mc = new ModuleDefinitionController(); var mInfo = new ModuleDefinitionInfo(); mInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefFriendlyName, myModule.DesktopModuleID); moduleInfo.ModuleDefID = mInfo.ModuleDefID; moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime; //Default Cache Time is 0 moduleInfo.InheritViewPermissions = true; //Inherit View Permissions from Tab moduleInfo.AllTabs = false; moduleInfo.Alignment = "Top"; ModuleController moduleController = new ModuleController(); moduleId = moduleController.AddModule(moduleInfo); } DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(t.TabID); DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(t.PortalID); DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(t.PortalID, false); //Add settings for RnC ModuleController m = new ModuleController(); if (type == ModuleType.Rating) { AddModuleSettingsRnCCommon(moduleId); m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID); m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyRatings"); m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "357"); } if (type == ModuleType.Comments) { AddModuleSettingsRnCCommon(moduleId); m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID); m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyComments"); m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "744"); } if (type == ModuleType.Rating || type == ModuleType.Comments) { RnCController c = new RnCController(); DCC_PRC_CommentObject myCO = new DCC_PRC_CommentObject(); myCO.CommentObject = "tabid:" + t.TabID; myCO.CommentObjectViewCount = 0; myCO.PortalID = t.PortalID; c.CreateCommentObject(myCO); } return(moduleId); }
private int DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align) { var objModules = new ModuleController(); try { DesktopModuleInfo desktopModule; if (!DesktopModuleController.GetDesktopModules(PortalSettings.Current.PortalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } var tabModuleId = Null.NullInteger; foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.Current.ActiveTab.PortalID); objModule.PortalID = PortalSettings.Current.ActiveTab.PortalID; objModule.TabID = PortalSettings.Current.ActiveTab.TabID; objModule.ModuleOrder = position; objModule.ModuleTitle = string.IsNullOrEmpty(title) ? objModuleDefinition.FriendlyName : title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; if (objModuleDefinition.DefaultCacheTime > 0) { objModule.CacheTime = objModuleDefinition.DefaultCacheTime; if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger) { ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if ((defaultModule != null)) { objModule.CacheTime = defaultModule.CacheTime; } } } objModules.InitialModulePermission(objModule, objModule.TabID, permissionType); if (PortalSettings.Current.ContentLocalizationEnabled) { Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId); //set the culture of the module to that of the tab var tabInfo = new TabController().GetTab(objModule.TabID, PortalSettings.Current.PortalId, false); objModule.CultureCode = tabInfo != null ? tabInfo.CultureCode : defaultLocale.Code; } else { objModule.CultureCode = Null.NullString; } objModule.AllTabs = false; objModule.Alignment = align; objModules.AddModule(objModule); if (tabModuleId == Null.NullInteger) { tabModuleId = objModule.ModuleID; } //update the position to let later modules with add after previous one. position = objModules.GetTabModule(objModule.TabModuleID).ModuleOrder + 1; } return(tabModuleId); }
/// <summary> /// Add the module to a page /// </summary> /// <param name="friendlyNameModule"></param> /// <returns></returns> protected bool AddModuleToPage(String friendlyNameModule) { TextBox tbx = (TextBox)FindControl("tbx_nom"); PortalSettings portalSettings = new PortalSettings(); int portalId = portalSettings.PortalId; //Creating page TabController tabController = new TabController(); TabInfo tab = null; //Checking if the page already exists if (!tabController.GetTabsByPortal(portalId).Values.Contains(tabController.GetTabByName(tbx.Text, portalId))) { tab = new TabInfo(); tab.PortalID = portalId; tab.TabName = tbx.Text; tab.Title = tbx.Text; tab.Description = tbx.Text; tab.KeyWords = tbx.Text; tab.IsVisible = true; tab.DisableLink = false; tab.IsDeleted = false; tab.Url = ""; tab.IsSuperTab = true; AddPermissionsOnTab(tab); int tabId = tabController.AddTab(tab, false); tbx.Text = ""; } else if (!tabController.GetTabByName(tbx.Text, portalId).IsDeleted) { tab = tabController.GetTabByName(tbx.Text, portalId); } else { return(false); } DesktopModuleInfo desktopModuleInfo = null; foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(portalId)) { DesktopModuleInfo mod = kvp.Value; if (mod != null) { if ((mod.FriendlyName == friendlyNameModule || mod.ModuleName == friendlyNameModule) && (mod.FriendlyName != "AIS_Installer" || mod.ModuleName != "AIS.Installer")) { desktopModuleInfo = mod; } } } if (desktopModuleInfo != null && tab != null) { foreach (ModuleDefinitionInfo moduleDefinitionInfo in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleInfo.DesktopModuleID).Values) { ModuleInfo moduleInfo = new ModuleInfo(); moduleInfo.PortalID = portalId; moduleInfo.TabID = tab.TabID; moduleInfo.ModuleOrder = 1; moduleInfo.ModuleTitle = desktopModuleInfo.FriendlyName; moduleInfo.PaneName = "ContentPane"; moduleInfo.ModuleDefID = moduleDefinitionInfo.ModuleDefID; moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime; moduleInfo.InheritViewPermissions = true; moduleInfo.AllTabs = false; ModuleController moduleController = new ModuleController(); int moduleId = moduleController.AddModule(moduleInfo); } } //Clearing cache DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(tab.TabID); DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(PortalId); DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(PortalId, false); return(true); }
private int AddNewModule(TabInfo tab, string title, int desktopModuleId, string paneName, int permissionType, string align) { TabPermissionCollection objTabPermissions = tab.TabPermissions; var objPermissionController = new PermissionController(); var objModules = new ModuleController(); int j; var mdc = new ModuleDefinitionController(); foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.Initialize(tab.PortalID); objModule.PortalID = tab.PortalID; objModule.TabID = tab.TabID; if (string.IsNullOrEmpty(title)) { objModule.ModuleTitle = objModuleDefinition.FriendlyName; } else { objModule.ModuleTitle = title; } objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; objModule.CacheTime = 0; objModule.InheritViewPermissions = true; objModule.DisplayTitle = false; // get the default module view permissions ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); // get the permissions from the page foreach (TabPermissionInfo objTabPermission in objTabPermissions) { if (objTabPermission.PermissionKey == "VIEW" && permissionType == 0) { //Don't need to explicitly add View permisisons if "Same As Page" continue; } // get the system module permissions for the permissionkey ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); // loop through the system module permissions for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++) { // create the module permission PermissionInfo objSystemModulePermission = default(PermissionInfo); objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j]; if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && objTabPermission.PermissionKey != "EDIT") { //Only Page Editors get View permissions if "Page Editors Only" continue; } ModulePermissionInfo objModulePermission = AddModulePermission(objModule, objSystemModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); // ensure that every EDIT permission which allows access also provides VIEW permission if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess) { ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule, (PermissionInfo)arrSystemModuleViewPermissions[0], objModulePermission.RoleID, objModulePermission.UserID, true); } } } objModule.AllTabs = false; objModule.Alignment = align; return(objModules.AddModule(objModule)); } return(-1); }
/// <summary> /// SaveTabData saves the Tab to the Database /// </summary> /// <param name="action">The action to perform "edit" or "add"</param> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> public int SaveTabData(string action) { EventLogController objEventLog = new EventLogController(); string strIcon = ctlIcon.Url; TabController objTabs = new TabController(); TabInfo objTab = new TabInfo(); objTab.TabID = TabId; objTab.PortalID = PortalId; objTab.TabName = txtTabName.Text; objTab.Title = txtTitle.Text; objTab.Description = txtDescription.Text; objTab.KeyWords = txtKeyWords.Text; objTab.IsVisible = !chkHidden.Checked; objTab.DisableLink = chkDisableLink.Checked; objTab.ParentId = int.Parse(cboTab.SelectedItem.Value); objTab.IconFile = strIcon; objTab.IsDeleted = false; objTab.Url = ctlURL.Url; objTab.TabPermissions = dgPermissions.Permissions; objTab.SkinSrc = ctlSkin.SkinSrc; objTab.ContainerSrc = ctlContainer.SkinSrc; objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName); if (!String.IsNullOrEmpty(txtStartDate.Text)) { objTab.StartDate = Convert.ToDateTime(txtStartDate.Text); } else { objTab.StartDate = Null.NullDate; } if (!String.IsNullOrEmpty(txtEndDate.Text)) { objTab.EndDate = Convert.ToDateTime(txtEndDate.Text); } else { objTab.EndDate = Null.NullDate; } int refreshInt; if (txtRefreshInterval.Text.Length > 0 && Int32.TryParse(txtRefreshInterval.Text, out refreshInt)) { objTab.RefreshInterval = Convert.ToInt32(txtRefreshInterval.Text); } objTab.PageHeadText = txtPageHeadText.Text; if (action == "edit") { // trap circular tab reference if (objTab.TabID != int.Parse(cboTab.SelectedItem.Value) && !IsCircularReference(int.Parse(cboTab.SelectedItem.Value))) { objTabs.UpdateTab(objTab); objEventLog.AddLog(objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_UPDATED); } } else // add or copy { objTab.TabID = objTabs.AddTab(objTab); objEventLog.AddLog(objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_CREATED); if (int.Parse(cboCopyPage.SelectedItem.Value) != -1) { ModuleController objModules = new ModuleController(); foreach (DataGridItem objDataGridItem in grdModules.Items) { CheckBox chkModule = (CheckBox)objDataGridItem.FindControl("chkModule"); if (chkModule.Checked) { int intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]); //RadioButton optNew = (RadioButton)objDataGridItem.FindControl( "optNew" ); RadioButton optCopy = (RadioButton)objDataGridItem.FindControl("optCopy"); RadioButton optReference = (RadioButton)objDataGridItem.FindControl("optReference"); TextBox txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle"); ModuleInfo objModule = objModules.GetModule(intModuleID, Int32.Parse(cboCopyPage.SelectedItem.Value), false); if (objModule != null) { if (!optReference.Checked) { objModule.ModuleID = Null.NullInteger; } objModule.TabID = objTab.TabID; objModule.ModuleTitle = txtCopyTitle.Text; objModule.ModuleID = objModules.AddModule(objModule); if (optCopy.Checked) { if (!String.IsNullOrEmpty(objModule.BusinessControllerClass)) { object objObject = Reflection.CreateObject(objModule.BusinessControllerClass, objModule.BusinessControllerClass); if (objObject is IPortable) { try { string Content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID)); if (!String.IsNullOrEmpty(Content)) { ((IPortable)objObject).ImportModule(objModule.ModuleID, Content, objModule.Version, UserInfo.UserID); } } catch (Exception exc) { // the export/import operation failed Exceptions.ProcessModuleLoadException(this, exc); } } } } } } } } else { // create the page from a template if (cboTemplate.SelectedItem != null) { if (!String.IsNullOrEmpty(cboTemplate.SelectedItem.Value)) { // open the XML file try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(cboTemplate.SelectedItem.Value); PortalController objPortals = new PortalController(); objPortals.ParsePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), objTab.PortalID, objTab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable()); } catch { // error opening page template } } } } } // url tracking UrlController objUrls = new UrlController(); objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow); return(objTab.TabID); }
public static void DeserializeModule(XmlNode nodeModule, XmlNode nodePane, int portalId, int tabId, PortalTemplateModuleAction mergeTabs, Hashtable hModules) { var moduleController = new ModuleController(); var objModuleDefinition = GetModuleDefinition(nodeModule); // will be instance or module var templateModuleId = XmlUtils.GetNodeValueInt(nodeModule, "moduleID"); var isInstance = CheckIsInstance(templateModuleId, hModules); //remove containersrc node if container is missing var containerNode = nodeModule.SelectSingleNode("containersrc"); if (containerNode != null) { var container = containerNode.Value; if (!File.Exists(HttpContext.Current.Server.MapPath(container))) { nodeModule.RemoveChild(containerNode); } } if (objModuleDefinition != null) { //If Mode is Merge Check if Module exists if (!FindModule(nodeModule, tabId, mergeTabs)) { var module = DeserializeModule(nodeModule, nodePane, portalId, tabId, objModuleDefinition.ModuleDefID); int intModuleId; if (!isInstance) { //Add new module intModuleId = moduleController.AddModule(module); if (templateModuleId > 0) { hModules.Add(templateModuleId, intModuleId); } } else { //Add instance module.ModuleID = Convert.ToInt32(hModules[templateModuleId]); intModuleId = moduleController.AddModule(module); } if (XmlUtils.GetNodeValue(nodeModule, "content", "") != "") { GetModuleContent(nodeModule, intModuleId, tabId, portalId, isInstance); } // Process permissions and moduleSettings only once if (!isInstance) { var nodeModulePermissions = nodeModule.SelectNodes("modulepermissions/permission"); DeserializeModulePermissions(nodeModulePermissions, portalId, module); //Persist the permissions to the Data base ModulePermissionController.SaveModulePermissions(module); var nodeModuleSettings = nodeModule.SelectNodes("modulesettings/setting"); DeserializeModuleSettings(nodeModuleSettings, intModuleId); } //apply TabModuleSettings var nodeTabModuleSettings = nodeModule.SelectNodes("tabmodulesettings/setting"); DeserializeTabModuleSettings(nodeTabModuleSettings, intModuleId, tabId); } } }
private TabInfo CreateSubTab(string tabName, int departmentId, string settingsName = "department", int?parentTabID = null) { //Create Tab TabController tabController = new TabController(); TabInfo tab = new TabInfo(); tab.PortalID = PortalId; tab.TabName = tabName; tab.Title = tabName; //works for include in menu option. if true, will be shown in menus, else will not be shown, we have to redirect internally tab.IsVisible = true; tab.DisableLink = false; //if this tab has any parents provide parent tab id, so that it will be shown in parent tab menus sub menu list, else is NULL //and will be in main menu list if (parentTabID == null) { tab.ParentId = TabId; } else { tab.ParentId = parentTabID.Value; } tab.IsDeleted = false; tab.Url = ""; tab.IsSuperTab = false; //if true, it has no parents, else false tab.SkinSrc = "[G]Skins/Artfolio001/page.ascx"; //provide skin src, else will take default skin tab.ContainerSrc = "[G]Containers/Artfolio001/Block.ascx"; int tabId = tabController.AddTab(tab, true); //true to load defalut modules //Set Tab Permission TabPermissionController objTPC = new TabPermissionController(); TabPermissionInfo tpi = new TabPermissionInfo(); tpi.TabID = tabId; tpi.PermissionID = 3; //for view tpi.PermissionKey = "VIEW"; tpi.PermissionName = "View Tab"; tpi.AllowAccess = true; tpi.RoleID = 0; //Role ID of administrator objTPC.AddTabPermission(tpi); TabPermissionInfo tpi1 = new TabPermissionInfo(); tpi1.TabID = tabId; tpi1.PermissionID = 4; //for edit tpi1.PermissionKey = "EDIT"; tpi1.PermissionName = "Edit Tab"; tpi1.AllowAccess = true; tpi1.RoleID = 0; //Role ID of administrator objTPC.AddTabPermission(tpi1); TabPermissionInfo tpi4 = new TabPermissionInfo(); tpi4.TabID = tabId; tpi4.PermissionID = 3; tpi4.PermissionKey = "VIEW"; tpi4.PermissionName = "View Tab"; tpi4.AllowAccess = true; tpi4.RoleID = -1; //All users objTPC.AddTabPermission(tpi4); //Add Module DesktopModuleController objDMC = new DesktopModuleController(); DesktopModuleInfo desktopModuleInfo = objDMC.GetDesktopModuleByName("Clothes"); ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo(); ModuleInfo moduleInfo = new ModuleInfo(); moduleInfo.PortalID = PortalId; moduleInfo.TabID = tabId; moduleInfo.ModuleOrder = 1; moduleInfo.ModuleTitle = "Clothes"; moduleInfo.PaneName = "Clothes"; moduleInfo.ModuleDefID = 160; moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime; //Default Cache Time is 0 moduleInfo.InheritViewPermissions = true; //Inherit View Permissions from Tab moduleInfo.AllTabs = false; moduleInfo.ModuleSettings[settingsName] = departmentId; ModuleController moduleController = new ModuleController(); int moduleId = moduleController.AddModule(moduleInfo); //Set Module Permission ModulePermissionController objMPC = new ModulePermissionController(); ModulePermissionInfo mpi1 = new ModulePermissionInfo(); mpi1.ModuleID = moduleId; mpi1.PermissionID = 1; //View Permission mpi1.AllowAccess = true; mpi1.RoleID = 0; //Role ID of Administrator objMPC.AddModulePermission(mpi1); ModulePermissionInfo mpi2 = new ModulePermissionInfo(); mpi2.ModuleID = moduleId; mpi2.PermissionID = 2; //Edit Permission mpi2.AllowAccess = true; mpi2.RoleID = 0; //Role ID of Administrator objMPC.AddModulePermission(mpi2); ModulePermissionInfo mpi5 = new ModulePermissionInfo(); mpi5.ModuleID = moduleId; mpi5.PermissionID = 1; //View Permission mpi5.AllowAccess = true; mpi5.RoleID = 1; //Role ID of Registered User objMPC.AddModulePermission(mpi5); return(tab); }
private static void DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align) { TabPermissionCollection objTabPermissions = PortalSettings.Current.ActiveTab.TabPermissions; var objPermissionController = new PermissionController(); var objModules = new ModuleController(); new EventLogController(); try { DesktopModuleInfo desktopModule; if (!DesktopModuleController.GetDesktopModules(PortalSettings.Current.PortalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.Current.ActiveTab.PortalID); objModule.PortalID = PortalSettings.Current.ActiveTab.PortalID; objModule.TabID = PortalSettings.Current.ActiveTab.TabID; objModule.ModuleOrder = position; objModule.ModuleTitle = string.IsNullOrEmpty(title) ? objModuleDefinition.FriendlyName : title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; if (objModuleDefinition.DefaultCacheTime > 0) { objModule.CacheTime = objModuleDefinition.DefaultCacheTime; if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger) { ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if ((defaultModule != null)) { objModule.CacheTime = defaultModule.CacheTime; } } } switch (permissionType) { case 0: objModule.InheritViewPermissions = true; break; case 1: objModule.InheritViewPermissions = false; break; } // get the default module view permissions ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); // get the permissions from the page foreach (TabPermissionInfo objTabPermission in objTabPermissions) { if (objTabPermission.PermissionKey == "VIEW" && permissionType == 0) { //Don't need to explicitly add View permisisons if "Same As Page" continue; } // get the system module permissions for the permissionkey ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); // loop through the system module permissions int j; for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++) { // create the module permission var objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j]; if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && objTabPermission.PermissionKey != "EDIT") { //Only Page Editors get View permissions if "Page Editors Only" continue; } ModulePermissionInfo objModulePermission = AddModulePermission(objModule, objSystemModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); // ensure that every EDIT permission which allows access also provides VIEW permission if (objModulePermission.PermissionKey == "EDIT" && objModulePermission.AllowAccess) { AddModulePermission(objModule, (PermissionInfo)arrSystemModuleViewPermissions[0], objModulePermission.RoleID, objModulePermission.UserID, true); } } //Get the custom Module Permissions, Assume that roles with Edit Tab Permissions //are automatically assigned to the Custom Module Permissions if (objTabPermission.PermissionKey == "EDIT") { ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID); // loop through the custom module permissions for (j = 0; j <= arrCustomModulePermissions.Count - 1; j++) { // create the module permission var objCustomModulePermission = (PermissionInfo)arrCustomModulePermissions[j]; AddModulePermission(objModule, objCustomModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess); } } } if (PortalSettings.Current.ContentLocalizationEnabled) { Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId); //check whether original tab is exists, if true then set culture code to default language, //otherwise set culture code to current. if (new TabController().GetTabByCulture(objModule.TabID, PortalSettings.Current.PortalId, defaultLocale) != null) { objModule.CultureCode = defaultLocale.Code; } else { objModule.CultureCode = PortalSettings.Current.CultureCode; } } else { objModule.CultureCode = Null.NullString; } objModule.AllTabs = false; objModule.Alignment = align; objModules.AddModule(objModule); } }
private void Create() { //Create new Folder string folderMapPath = Server.MapPath(string.Format("~/DesktopModules/RazorModules/{0}", txtFolder.Text)); if (Directory.Exists(folderMapPath)) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FolderExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } else { //Create folder Directory.CreateDirectory(folderMapPath); } //Create new Module Control string moduleControlMapPath = folderMapPath + "/" + ModuleControl; try { using (var moduleControlWriter = new StreamWriter(moduleControlMapPath)) { moduleControlWriter.Write(Localization.GetString("ModuleControlText.Text", LocalResourceFile)); moduleControlWriter.Flush(); } } catch (Exception ex) { Exceptions.LogException(ex); UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ModuleControlCreationError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } //Copy Script to new Folder string scriptSourceFile = Server.MapPath(string.Format(razorScriptFileFormatString, scriptList.SelectedValue)); string scriptTargetFile = folderMapPath + "/" + scriptList.SelectedValue; try { File.Copy(scriptSourceFile, scriptTargetFile); } catch (Exception ex) { Exceptions.LogException(ex); UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ScriptCopyError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } //Create new Manifest in target folder string manifestMapPath = folderMapPath + "/" + ModuleControl.Replace(".ascx", ".dnn"); try { using (var manifestWriter = new StreamWriter(manifestMapPath)) { string manifestTemplate = Localization.GetString("ManifestText.Text", LocalResourceFile); string manifest = string.Format(manifestTemplate, txtName.Text, txtDescription.Text, txtFolder.Text, ModuleControl, scriptList.SelectedValue); manifestWriter.Write(manifest); manifestWriter.Flush(); } } catch (Exception ex) { Exceptions.LogException(ex); UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ManifestCreationError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } //Register Module ModuleDefinitionInfo moduleDefinition = ImportManifest(manifestMapPath); //Optionally goto new Page if (chkAddPage.Checked) { string tabName = "Test " + txtName.Text + " Page"; string tabPath = Globals.GenerateTabPath(Null.NullInteger, tabName); int tabID = TabController.GetTabByTabPath(ModuleContext.PortalId, tabPath, ModuleContext.PortalSettings.CultureCode); if (tabID == Null.NullInteger) { //Create a new page var newTab = new TabInfo(); newTab.TabName = "Test " + txtName.Text + " Page"; newTab.ParentId = Null.NullInteger; newTab.PortalID = ModuleContext.PortalId; newTab.IsVisible = true; newTab.TabID = new TabController().AddTabBefore(newTab, ModuleContext.PortalSettings.AdminTabId); var objModule = new ModuleInfo(); objModule.Initialize(ModuleContext.PortalId); objModule.PortalID = ModuleContext.PortalId; objModule.TabID = newTab.TabID; objModule.ModuleOrder = Null.NullInteger; objModule.ModuleTitle = moduleDefinition.FriendlyName; objModule.PaneName = Globals.glbDefaultPane; objModule.ModuleDefID = moduleDefinition.ModuleDefID; objModule.InheritViewPermissions = true; objModule.AllTabs = false; var moduleCtl = new ModuleController(); moduleCtl.AddModule(objModule); Response.Redirect(Globals.NavigateURL(newTab.TabID), true); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } } else { //Redirect to main extensions page Response.Redirect(Globals.NavigateURL(), true); } }
private int DoAddExistingModule(int moduleId, int tabId, string paneName, int position, string align, bool cloneModule) { var moduleCtrl = new ModuleController(); ModuleInfo moduleInfo = moduleCtrl.GetModule(moduleId, tabId, false); int userID = -1; UserInfo user = UserController.GetCurrentUserInfo(); if (user != null) { userID = user.UserID; } if ((moduleInfo != null)) { // Is this from a site other than our own? (i.e., is the user requesting "module sharing"?) var remote = moduleInfo.PortalID != PortalSettings.Current.PortalId; if (remote) { switch (moduleInfo.DesktopModule.Shareable) { case ModuleSharing.Unsupported: // Should never happen since the module should not be listed in the first place. throw new ApplicationException(string.Format("Module '{0}' does not support Shareable and should not be listed in Add Existing Module from a different source site", moduleInfo.DesktopModule.FriendlyName)); case ModuleSharing.Supported: break; case ModuleSharing.Unknown: break; } } // clone the module object ( to avoid creating an object reference to the data cache ) ModuleInfo newModule = moduleInfo.Clone(); newModule.UniqueId = Guid.NewGuid(); // Cloned Module requires a different uniqueID newModule.TabID = PortalSettings.Current.ActiveTab.TabID; newModule.ModuleOrder = position; newModule.PaneName = paneName; newModule.Alignment = align; if ((cloneModule)) { newModule.ModuleID = Null.NullInteger; //reset the module id newModule.ModuleID = moduleCtrl.AddModule(newModule); if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass)) { object objObject = DotNetNuke.Framework.Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass); if (objObject is IPortable) { string content = Convert.ToString(((IPortable)objObject).ExportModule(moduleId)); if (!string.IsNullOrEmpty(content)) { ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, userID); } } } } else { moduleCtrl.AddModule(newModule); } if (remote) { //Ensure the Portal Admin has View rights var permissionController = new PermissionController(); ArrayList arrSystemModuleViewPermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); AddModulePermission(newModule, (PermissionInfo)arrSystemModuleViewPermissions[0], PortalSettings.Current.AdministratorRoleId, Null.NullInteger, true); //Set PortalID correctly newModule.OwnerPortalID = newModule.PortalID; newModule.PortalID = PortalSettings.Current.PortalId; ModulePermissionController.SaveModulePermissions(newModule); } //Add Event Log var objEventLog = new EventLogController(); objEventLog.AddLog(newModule, PortalSettings.Current, userID, "", EventLogController.EventLogType.MODULE_CREATED); return(newModule.ModuleID); } return(-1); }
private static void DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align) { var objModules = new ModuleController(); try { DesktopModuleInfo desktopModule; if (!DesktopModuleController.GetDesktopModules(PortalSettings.Current.PortalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.Current.ActiveTab.PortalID); objModule.PortalID = PortalSettings.Current.ActiveTab.PortalID; objModule.TabID = PortalSettings.Current.ActiveTab.TabID; objModule.ModuleOrder = position; objModule.ModuleTitle = string.IsNullOrEmpty(title) ? objModuleDefinition.FriendlyName : title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; if (objModuleDefinition.DefaultCacheTime > 0) { objModule.CacheTime = objModuleDefinition.DefaultCacheTime; if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger) { ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if ((defaultModule != null)) { objModule.CacheTime = defaultModule.CacheTime; } } } objModules.InitialModulePermission(objModule, objModule.TabID, permissionType); if (PortalSettings.Current.ContentLocalizationEnabled) { Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId); //check whether original tab is exists, if true then set culture code to default language, //otherwise set culture code to current. if (new TabController().GetTabByCulture(objModule.TabID, PortalSettings.Current.PortalId, defaultLocale) != null) { objModule.CultureCode = defaultLocale.Code; } else { objModule.CultureCode = PortalSettings.Current.CultureCode; } } else { objModule.CultureCode = Null.NullString; } objModule.AllTabs = false; objModule.Alignment = align; objModules.AddModule(objModule); } }
private void CloneOrDeleteTabModules(List <int> tabslist, ModuleController objmodules, TabController objTabs, int ftabId, int fmoduleId, StringBuilder actionBuilder) { foreach (RadTreeNode n in ctlPages.GetAllNodes()) { // if this is the root node, don't make action int nval = Convert.ToInt32(n.Value); if (nval > 0) { //Check if checked has changed int ttabId = Convert.ToInt32(n.Value); string pname = n.Text; //The value in DB bool dbcheck = getbchk(tabslist, ttabId); //The value in the Tree bool nodecheck = n.Checked; //if changed Add or Delete the clone if (dbcheck != nodecheck) { //Add case if (!dbcheck && nodecheck) { #region OLD CODE COMMENTED V1 //We have a new localiezd version GUID when use the CopyModule(as Display On All Pages) V1 //(bug with new localized GUID instead of copy original one like Add existing Module (clone) from new dashboard // BUG ? in DNN Platform\Library\Entities\Modules\ModuleController.cs l // l1022 destinationModule.LocalizedVersionGuid = Guid.NewGuid(); //Add V1 (use CopyModule) //ModuleInfo fmi = objmodules.GetModule(fmoduleId, ftabId); //ModuleInfo tmi = objmodules.GetModule(fmoduleId, ttabId); //TabInfo tti = objTabs.GetTab(ttabId, PortalId, true); ////Does detination module exist ? ////NO //if (tmi == null) //{ // objmodules.CopyModule(fmi, tti, "", Convert.ToBoolean(rbSettings.SelectedValue)); // Action += "Clone Module " + fmoduleId + " on the page : " + pname + "(" + ttabId + ") <br />"; //} //else //{ // if (tmi.IsDeleted) // { // objmodules.RestoreModule(tmi); // Action += "Restore Module " + fmoduleId + " on the page : " + pname + "(" + ttabId + ") <br />"; // } //} //end V1 #endregion //V2 (inspired from ControlBarController.cs DoAddExistingModule line 589) ModuleInfo fmi = objmodules.GetModule(fmoduleId, ftabId); ModuleInfo newModule = fmi.Clone(); newModule.UniqueId = Guid.NewGuid(); // Cloned Module requires a different uniqueID newModule.TabID = ttabId; objmodules.AddModule(newModule); actionBuilder.AppendFormat("<div class=\"logLine addModule\">Clone or restore Module {0} ({1}) on the page : {2} ({3}) </div>", newModule.ModuleTitle, fmoduleId, pname, ttabId); //Add Event Log //var objEventLog = new EventLogController(); //objEventLog.AddLog(newModule, PortalSettings.Current, userID, "", EventLogController.EventLogType.MODULE_CREATED); } //Delete case if (dbcheck && !nodecheck) { //Delete bool softDelete = Convert.ToBoolean(rbDelete.SelectedValue); TabInfo ti = objTabs.GetTab(ttabId, PortalId, true); ModuleInfo mi = objmodules.GetModule(fmoduleId, ttabId); objmodules.DeleteTabModule(ttabId, fmoduleId, softDelete); actionBuilder.AppendFormat("<div class=\"logLine delModule\">{0} Module {1} ({2}) of the page : {3} ({4}) </div>", (softDelete ? "Send to recycle bin":"Delete"), mi.ModuleTitle, fmoduleId, pname, ttabId); } } } } // Response.Redirect(Request.RawUrl); actionBuilder.Append("</div>"); }
private static void GenerateAdminTab(int PortalId) { var tabID = TabController.GetTabByTabPath(PortalId, @"//Admin//OpenUrlRewriter", Null.NullString); if (tabID == Null.NullInteger) { var adminTabID = TabController.GetTabByTabPath(PortalId, @"//Admin", Null.NullString); /* dont work on dnn 7 - generate new section "SEO Features" in admin menu * * var tabName = "SEO Features"; * var tabPath = Globals.GenerateTabPath(adminTabID, tabName); * tabID = TabController.GetTabByTabPath(PortalId, tabPath, Null.NullString); * if (tabID == Null.NullInteger) * { * //Create a new page * var newParentTab = new TabInfo(); * newParentTab.TabName = tabName; * newParentTab.ParentId = adminTabID; * newParentTab.PortalID = PortalId; * newParentTab.IsVisible = true; * newParentTab.DisableLink = true; * newParentTab.TabID = new TabController().AddTab(newParentTab); * tabID = newParentTab.TabID; * } */ // create new page "Url Rules Cache" int parentTabID = adminTabID; var tabName = "Open Url Rewriter"; var tabPath = Globals.GenerateTabPath(parentTabID, tabName); tabID = TabController.GetTabByTabPath(PortalId, tabPath, Null.NullString); if (tabID == Null.NullInteger) { //Create a new page var newTab = new TabInfo(); newTab.TabName = tabName; newTab.ParentId = parentTabID; newTab.PortalID = PortalId; newTab.IsVisible = true; #if DNN71 newTab.IconFile = "~/Icons/Sigma/AdvancedUrlMngmt_16x16.png"; newTab.IconFileLarge = "~/Icons/Sigma/AdvancedUrlMngmt_32x32.png"; #else newTab.IconFile = "~/Images/icon_search_16px.gif"; newTab.IconFileLarge = "~/Images/icon_search_32px.gif"; #endif newTab.TabID = new TabController().AddTab(newTab, false); tabID = newTab.TabID; } } // create new module "OpenUrlRewriter" var moduleCtl = new ModuleController(); if (moduleCtl.GetTabModules(tabID).Count == 0) { //var dmc = new DesktopModuleController(); //var dm = dmc.GetDesktopModuleByModuleName("OpenUrlRewriter"); var dm = DesktopModuleController.GetDesktopModuleByModuleName("OpenUrlRewriter", PortalId); //var mdc = new ModuleDefinitionController(); //var md = mdc.GetModuleDefinitionByName(dm.DesktopModuleID, "OpenUrlRewriter"); var md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("OpenUrlRewriter"); var objModule = new ModuleInfo(); //objModule.Initialize(PortalId); objModule.PortalID = PortalId; objModule.TabID = tabID; objModule.ModuleOrder = Null.NullInteger; objModule.ModuleTitle = "Open Url Rewriter"; objModule.PaneName = Globals.glbDefaultPane; objModule.ModuleDefID = md.ModuleDefID; objModule.InheritViewPermissions = true; objModule.AllTabs = false; #if DNN71 objModule.IconFile = "~/Icons/Sigma/AdvancedUrlMngmt_16x16.png"; #else objModule.IconFile = "~/Images/icon_search_32px.gif"; #endif moduleCtl.AddModule(objModule); } }