/// <summary> /// cmdUpdate_Click runs when the Update Button is clicked /// </summary> /// <history> /// [cnurse] 9/28/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void cmdUpdate_Click(object sender, EventArgs e) { try { if (Page.IsValid) { DesktopModuleInfo objDesktopModule = new DesktopModuleInfo(); objDesktopModule.DesktopModuleID = DesktopModuleId; objDesktopModule.ModuleName = txtModuleName.Text; objDesktopModule.FolderName = txtFolderName.Text; objDesktopModule.FriendlyName = txtFriendlyName.Text; if (objDesktopModule.FolderName == "") { objDesktopModule.FolderName = objDesktopModule.ModuleName; } objDesktopModule.Description = txtDescription.Text; objDesktopModule.IsPremium = chkPremium.Checked; objDesktopModule.IsAdmin = false; if (!String.IsNullOrEmpty(txtVersion.Text)) { objDesktopModule.Version = txtVersion.Text; } else { objDesktopModule.Version = Null.NullString; } if (!String.IsNullOrEmpty(txtBusinessClass.Text)) { objDesktopModule.BusinessControllerClass = txtBusinessClass.Text; } else { objDesktopModule.BusinessControllerClass = Null.NullString; } if (!String.IsNullOrEmpty(txtCompatibleVersions.Text)) { objDesktopModule.CompatibleVersions = txtCompatibleVersions.Text; } else { objDesktopModule.CompatibleVersions = Null.NullString; } DesktopModuleController objDesktopModules = new DesktopModuleController(); if (Null.IsNull(DesktopModuleId)) { try { objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule); } catch { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AddModule.ErrorMessage", this.LocalResourceFile), ModuleMessageType.RedError); return; } } else { objDesktopModules.UpdateDesktopModule(objDesktopModule); } // delete old portal module assignments objDesktopModules.DeletePortalDesktopModules(Null.NullInteger, objDesktopModule.DesktopModuleID); // add new portal module assignments if (objDesktopModule.IsPremium) { foreach (ListItem objListItem in ctlPortals.Assigned) { objDesktopModules.AddPortalDesktopModule(int.Parse(objListItem.Value), objDesktopModule.DesktopModuleID); } } // update interfaces UpdateModuleInterfaces(objDesktopModule.BusinessControllerClass); Response.Redirect(EditUrl("desktopmoduleid", objDesktopModule.DesktopModuleID.ToString()), true); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private int DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align) { 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 = ModuleController.Instance.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if (defaultModule != null) { objModule.CacheTime = defaultModule.CacheTime; } } } ModuleController.Instance.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 = TabController.Instance.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; ModuleController.Instance.AddModule(objModule); if (tabModuleId == Null.NullInteger) { tabModuleId = objModule.ModuleID; } // update the position to let later modules with add after previous one. position = ModuleController.Instance.GetTabModule(objModule.TabModuleID).ModuleOrder + 1; } return(tabModuleId); }
public static int AddPackage(PackageInfo package, bool includeDetail) { int packageID = provider.AddPackage(package.PortalID, package.Name, package.FriendlyName, package.Description, package.PackageType, package.Version.ToString(3), package.License, package.Manifest, package.Owner, package.Organization, package.Url, package.Email, package.ReleaseNotes, package.IsSystemPackage, UserController.GetCurrentUserInfo().UserID, package.FolderName, package.IconFile); var objEventLog = new EventLogController(); objEventLog.AddLog(package, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PACKAGE_CREATED); if (includeDetail) { Locale locale; LanguagePackInfo languagePack; switch (package.PackageType) { case "Auth_System": //Create a new Auth System var authSystem = new AuthenticationInfo(); authSystem.AuthenticationType = package.Name; authSystem.IsEnabled = Null.NullBoolean; authSystem.PackageID = packageID; AuthenticationController.AddAuthentication(authSystem); break; case "Container": case "Skin": var skinPackage = new SkinPackageInfo(); skinPackage.SkinName = package.Name; skinPackage.PackageID = packageID; skinPackage.SkinType = package.PackageType; SkinController.AddSkinPackage(skinPackage); break; case "CoreLanguagePack": locale = LocaleController.Instance.GetLocale(PortalController.GetCurrentPortalSettings().DefaultLanguage); languagePack = new LanguagePackInfo(); languagePack.PackageID = packageID; languagePack.LanguageID = locale.LanguageId; languagePack.DependentPackageID = -2; LanguagePackController.SaveLanguagePack(languagePack); break; case "ExtensionLanguagePack": locale = LocaleController.Instance.GetLocale(PortalController.GetCurrentPortalSettings().DefaultLanguage); languagePack = new LanguagePackInfo(); languagePack.PackageID = packageID; languagePack.LanguageID = locale.LanguageId; languagePack.DependentPackageID = Null.NullInteger; LanguagePackController.SaveLanguagePack(languagePack); break; case "Module": //Create a new DesktopModule var desktopModule = new DesktopModuleInfo(); desktopModule.PackageID = packageID; desktopModule.ModuleName = package.Name; desktopModule.FriendlyName = package.FriendlyName; desktopModule.FolderName = package.Name; desktopModule.Description = package.Description; desktopModule.Version = package.Version.ToString(3); desktopModule.SupportedFeatures = 0; int desktopModuleId = DesktopModuleController.SaveDesktopModule(desktopModule, false, true); if (desktopModuleId > Null.NullInteger) { DesktopModuleController.AddDesktopModuleToPortals(desktopModuleId); } break; case "SkinObject": var skinControl = new SkinControlInfo(); skinControl.PackageID = packageID; skinControl.ControlKey = package.Name; SkinControlController.SaveSkinControl(skinControl); break; } } DataCache.ClearPackagesCache(package.PortalID); return(packageID); }
protected virtual void RegisterModules(PaFolder Folder, ArrayList Modules, ArrayList Controls) { InstallerInfo.Log.StartJob(REGISTER_Module); DesktopModuleController objDesktopModules = new DesktopModuleController(); // check if desktop module exists DesktopModuleInfo objDesktopModule = GetDesktopModule(Folder); if (objDesktopModule == null) { objDesktopModule = new DesktopModuleInfo(); objDesktopModule.DesktopModuleID = Null.NullInteger; } objDesktopModule = GetDesktopModuleSettings(objDesktopModule, Folder); if (Null.IsNull(objDesktopModule.DesktopModuleID)) { // new desktop module objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule); } else { // existing desktop module objDesktopModules.UpdateDesktopModule(objDesktopModule); } InstallerInfo.Log.AddInfo(REGISTER_Definition); ModuleDefinitionController objModuleDefinitons = new ModuleDefinitionController(); foreach (ModuleDefinitionInfo objModuleDefinition in Modules) { // check if definition exists ModuleDefinitionInfo objModuleDefinition2 = objModuleDefinitons.GetModuleDefinitionByName(objDesktopModule.DesktopModuleID, objModuleDefinition.FriendlyName); if (objModuleDefinition2 == null) { // add new definition objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID; objModuleDefinition.ModuleDefID = objModuleDefinitons.AddModuleDefinition(objModuleDefinition); } else { // update existing definition objModuleDefinition.ModuleDefID = objModuleDefinition2.ModuleDefID; objModuleDefinitons.UpdateModuleDefinition(objModuleDefinition); } } InstallerInfo.Log.AddInfo(REGISTER_Controls); ModuleControlController objModuleControls = new ModuleControlController(); foreach (ModuleControlInfo objModuleControl in Controls) { // get the real ModuleDefID from the associated Module objModuleControl.ModuleDefID = GetModDefID(objModuleControl.ModuleDefID, Modules); // check if control exists ModuleControlInfo objModuleControl2 = objModuleControls.GetModuleControlByKeyAndSrc(objModuleControl.ModuleDefID, objModuleControl.ControlKey, objModuleControl.ControlSrc); if (objModuleControl2 == null) { // add new control objModuleControls.AddModuleControl(objModuleControl); } else { // update existing control objModuleControl.ModuleControlID = objModuleControl2.ModuleControlID; objModuleControls.UpdateModuleControl(objModuleControl); } } InstallerInfo.Log.EndJob(REGISTER_End); UpgradeModule(objDesktopModule); }
private void UpdatePermissions(DesktopModuleInfo desktopModule, PackageSettingsDto packageSettings) { if (!packageSettings.EditorActions.ContainsKey("permissions") || string.IsNullOrEmpty(packageSettings.EditorActions["permissions"])) { return; } var portalModule = DesktopModuleController.GetPortalDesktopModule(packageSettings.PortalId, desktopModule.DesktopModuleID); if (portalModule == null) { return; } var portalSettings = new PortalSettings(packageSettings.PortalId); var permissions = JsonConvert.DeserializeObject <PermissionsDto>(packageSettings.EditorActions["permissions"]); var hasAdmin = permissions.RolePermissions == null ? false : permissions.RolePermissions.Any(permission => permission.RoleId == portalSettings.AdministratorRoleId); var desktopModulePermissions = new DesktopModulePermissionCollection(); //add default permissions for administrators if (!hasAdmin || (permissions.RolePermissions.Count == 0 && permissions.UserPermissions.Count == 0)) { //add default permissions var permissionController = new PermissionController(); var permissionsList = permissionController.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY"); foreach (PermissionInfo permissionInfo in permissionsList) { var permission = new DesktopModulePermissionInfo(permissionInfo) { RoleID = portalSettings.AdministratorRoleId, UserID = Null.NullInteger, PortalDesktopModuleID = portalModule.PortalDesktopModuleID, AllowAccess = true, RoleName = portalSettings.AdministratorRoleName }; desktopModulePermissions.Add(permission); } } //add role permissions if (permissions.RolePermissions != null) { foreach (var rolePermission in permissions.RolePermissions) { foreach (var permission in rolePermission.Permissions) { desktopModulePermissions.Add(new DesktopModulePermissionInfo() { PermissionID = permission.PermissionId, RoleID = rolePermission.RoleId, UserID = Null.NullInteger, PortalDesktopModuleID = portalModule.PortalDesktopModuleID, AllowAccess = permission.AllowAccess }); } } } //add user permissions if (permissions.UserPermissions != null) { foreach (var userPermission in permissions.UserPermissions) { foreach (var permission in userPermission.Permissions) { int roleId; int.TryParse(Globals.glbRoleNothing, out roleId); desktopModulePermissions.Add(new DesktopModulePermissionInfo() { PermissionID = permission.PermissionId, RoleID = roleId, UserID = userPermission.UserId, PortalDesktopModuleID = portalModule.PortalDesktopModuleID, AllowAccess = permission.AllowAccess }); } } } //Update DesktopModule Permissions var currentPermissions = DesktopModulePermissionController.GetDesktopModulePermissions(portalModule.PortalDesktopModuleID); if (!currentPermissions.CompareTo(desktopModulePermissions)) { DesktopModulePermissionController.DeleteDesktopModulePermissionsByPortalDesktopModuleID(portalModule.PortalDesktopModuleID); foreach (DesktopModulePermissionInfo objPermission in desktopModulePermissions) { DesktopModulePermissionController.AddDesktopModulePermission(objPermission); } } DataCache.RemoveCache(string.Format(DataCache.PortalDesktopModuleCacheKey, portalSettings.PortalId)); }
private void ReadLegacyManifest(XPathNavigator manifestNav) { string fileName = Null.NullString; string filePath = Null.NullString; string sourceFileName = Null.NullString; string resourcetype = Null.NullString; string moduleName = Null.NullString; foreach (XPathNavigator fileNav in manifestNav.Select("Files/File")) { fileName = Util.ReadAttribute(fileNav, "FileName").ToLowerInvariant(); resourcetype = Util.ReadAttribute(fileNav, "FileType"); moduleName = Util.ReadAttribute(fileNav, "ModuleName").ToLowerInvariant(); sourceFileName = Path.Combine(resourcetype, Path.Combine(moduleName, fileName)); string extendedExtension = "." + Language.Code.ToLowerInvariant() + ".resx"; switch (resourcetype) { case "GlobalResource": filePath = "App_GlobalResources"; _IsCore = true; break; case "ControlResource": filePath = "Controls\\App_LocalResources"; break; case "AdminResource": _IsCore = true; switch (moduleName) { case "authentication": filePath = "DesktopModules\\Admin\\Authentication\\App_LocalResources"; break; case "controlpanel": filePath = "Admin\\ControlPanel\\App_LocalResources"; break; case "files": filePath = "DesktopModules\\Admin\\FileManager\\App_LocalResources"; break; case "host": switch (fileName.Replace(extendedExtension, "")) { case "authentication.ascx": filePath = ""; break; case "friendlyurls.ascx": filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources"; break; case "hostsettings.ascx": filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources"; break; case "requestfilters.ascx": filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources"; break; } break; case "lists": filePath = "DesktopModules\\Admin\\Lists\\App_LocalResources"; break; case "localization": switch (fileName.Replace(extendedExtension, "")) { case "languageeditor.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "languageeditorext.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "timezoneeditor.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "resourceverifier.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; default: filePath = ""; break; } break; case "logging": filePath = "DesktopModules\\Admin\\LogViewer\\App_LocalResources"; break; case "moduledefinitions": switch (fileName.Replace(extendedExtension, "")) { case "editmodulecontrol.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "importmoduledefinition.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "timezoneeditor.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; default: filePath = ""; break; } break; case "modules": filePath = "Admin\\Modules\\App_LocalResources"; break; case "packages": filePath = "DesktopModules\\Admin\\Extensions\\App_LocalResources"; break; case "portal": switch (fileName.Replace(extendedExtension, "")) { case "editportalalias.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "portalalias.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "portals.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "privacy.ascx": filePath = "Admin\\Portal\\App_LocalResources"; break; case "signup.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "sitesettings.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "sitewizard.ascx": filePath = "DesktopModules\\Admin\\SiteWizard\\App_LocalResources"; break; case "sql.ascx": filePath = "DesktopModules\\Admin\\SQL\\App_LocalResources"; break; case "systemmessages.ascx": filePath = ""; break; case "template.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "terms.ascx": filePath = "Admin\\Portal\\App_LocalResources"; break; } break; case "scheduling": filePath = "DesktopModules\\Admin\\Scheduler\\App_LocalResources"; break; case "search": switch (fileName.Replace(extendedExtension, "")) { case "inputsettings.ascx": filePath = "DesktopModules\\Admin\\SearchInput\\App_LocalResources"; break; case "resultssettings.ascx": filePath = "DesktopModules\\Admin\\SearchResults\\App_LocalResources"; break; case "searchadmin.ascx": filePath = "DesktopModules\\Admin\\SearchAdmin\\App_LocalResources"; break; case "searchinput.ascx": filePath = "DesktopModules\\Admin\\SearchInput\\App_LocalResources"; break; case "searchresults.ascx": filePath = "DesktopModules\\Admin\\SearchResults\\App_LocalResources"; break; } break; case "security": switch (fileName.Replace(extendedExtension, "")) { case "accessdenied.ascx": filePath = "Admin\\Security\\App_LocalResources"; break; case "authenticationsettings.ascx": filePath = ""; break; case "editgroups.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "editroles.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "register.ascx": filePath = ""; break; case "roles.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "securityroles.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "sendpassword.ascx": filePath = "Admin\\Security\\App_LocalResources"; break; case "signin.ascx": filePath = ""; break; } break; case "skins": filePath = "Admin\\Skins\\App_LocalResources"; break; case "syndication": filePath = "DesktopModules\\Admin\\FeedExplorer\\App_LocalResources"; break; case "tabs": switch (fileName.Replace(extendedExtension, "")) { case "export.ascx": filePath = "Admin\\Tabs\\App_LocalResources"; break; case "import.ascx": filePath = "Admin\\Tabs\\App_LocalResources"; break; case "managetabs.ascx": filePath = "DesktopModules\\Admin\\Tabs\\App_LocalResources"; break; case "recyclebin.ascx": filePath = "DesktopModules\\Admin\\RecycleBin\\App_LocalResources"; break; case "tabs.ascx": filePath = "DesktopModules\\Admin\\Tabs\\App_LocalResources"; break; } break; case "users": switch (fileName.Replace(extendedExtension, "")) { case "bulkemail.ascx": filePath = "DesktopModules\\Admin\\Newsletters\\App_LocalResources"; fileName = "Newsletter.ascx" + extendedExtension; break; case "editprofiledefinition.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "manageusers.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "memberservices.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "membership.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "password.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "profile.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "profiledefinitions.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "user.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "users.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "usersettings.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "viewprofile.ascx": filePath = "Admin\\Users\\App_LocalResources"; break; } break; case "vendors": switch (fileName.Replace(extendedExtension, "")) { case "adsense.ascx": filePath = ""; break; case "editadsense.ascx": filePath = ""; break; case "affiliates.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "banneroptions.ascx": filePath = "DesktopModules\\Admin\\Banners\\App_LocalResources"; break; case "banners.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "displaybanners.ascx": filePath = "DesktopModules\\Admin\\Banners\\App_LocalResources"; break; case "editaffiliate.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "editbanner.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "editvendors.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "vendors.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; } break; } break; case "LocalResource": filePath = Path.Combine("DesktopModules", Path.Combine(moduleName, "App_LocalResources")); //Two assumptions are made here //1. Core files appear in the package before extension files //2. Module packages only include one module if (!_IsCore && _LanguagePack == null) { //Check if language is installed Locale locale = LocaleController.Instance.GetLocale(_Language.Code); if (locale == null) { LegacyError = "CoreLanguageError"; } else { //Attempt to figure out the Extension foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(Null.NullInteger)) { if (kvp.Value.FolderName.ToLowerInvariant() == moduleName) { //Found Module - Get Package var dependentPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == kvp.Value.PackageID); Package.Name += "_" + dependentPackage.Name; Package.FriendlyName += " " + dependentPackage.FriendlyName; _LanguagePack = new LanguagePackInfo(); _LanguagePack.DependentPackageID = dependentPackage.PackageID; _LanguagePack.LanguageID = locale.LanguageId; break; } } if (_LanguagePack == null) { LegacyError = "DependencyError"; } } } break; case "ProviderResource": filePath = Path.Combine("Providers", Path.Combine(moduleName, "App_LocalResources")); break; case "InstallResource": filePath = "Install\\App_LocalResources"; break; } if (!string.IsNullOrEmpty(filePath)) { AddFile(Path.Combine(filePath, fileName), sourceFileName); } } }
/// ----------------------------------------------------------------------------- /// <summary> /// The DeleteModule method deletes the Module from the data Store. /// </summary> /// ----------------------------------------------------------------------------- private void DeleteModule() { try { //Attempt to get the Desktop Module DesktopModuleInfo tempDesktopModule = DesktopModuleController.GetDesktopModuleByPackageID(Package.PackageID); if (tempDesktopModule != null) { var modules = ModuleController.Instance.GetModulesByDesktopModuleId(tempDesktopModule.DesktopModuleID); //Remove CodeSubDirectory if ((_desktopModule != null) && (!string.IsNullOrEmpty(_desktopModule.CodeSubDirectory))) { Config.RemoveCodeSubDirectory(_desktopModule.CodeSubDirectory); } var controller = new DesktopModuleController(); Log.AddInfo(string.Format(Util.MODULE_UnRegistered, tempDesktopModule.ModuleName)); //remove admin/host pages if (!String.IsNullOrEmpty(tempDesktopModule.AdminPage)) { string tabPath = "//Admin//" + tempDesktopModule.AdminPage; var portals = PortalController.Instance.GetPortals(); foreach (PortalInfo portal in portals) { var tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath, Null.NullString); TabInfo temp = TabController.Instance.GetTab(tabID, portal.PortalID); if ((temp != null)) { var mods = TabModulesController.Instance.GetTabModules((temp)); bool noOtherTabModule = true; foreach (ModuleInfo mod in mods) { if (mod.DesktopModuleID != tempDesktopModule.DesktopModuleID) { noOtherTabModule = false; } } if (noOtherTabModule) { Log.AddInfo(string.Format(Util.MODULE_AdminPageRemoved, tempDesktopModule.AdminPage, portal.PortalID)); TabController.Instance.DeleteTab(tabID, portal.PortalID); } Log.AddInfo(string.Format(Util.MODULE_AdminPagemoduleRemoved, tempDesktopModule.AdminPage, portal.PortalID)); } } } if (!String.IsNullOrEmpty(tempDesktopModule.HostPage)) { Upgrade.Upgrade.RemoveHostPage(tempDesktopModule.HostPage); Log.AddInfo(string.Format(Util.MODULE_HostPageRemoved, tempDesktopModule.HostPage)); Log.AddInfo(string.Format(Util.MODULE_HostPagemoduleRemoved, tempDesktopModule.HostPage)); } controller.DeleteDesktopModule(tempDesktopModule); //Remove all the tab versions related with the module. foreach (var module in modules) { var moduleInfo = module as ModuleInfo; if (moduleInfo != null) { TabVersionController.Instance.DeleteTabVersionDetailByModule(moduleInfo.ModuleID); } } } } catch (Exception ex) { Log.AddFailure(ex); } }
/// <summary> /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> private bool CreateModuleDefinition() { try { if (PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == GetClassName()) == null) { var controlName = Null.NullString; //Create module folder CreateModuleFolder(); //Create module control controlName = CreateModuleControl(); if (controlName != "") { //Create package var objPackage = new PackageInfo(); objPackage.Name = GetClassName(); objPackage.FriendlyName = txtModule.Text; objPackage.Description = txtDescription.Text; objPackage.Version = new Version(1, 0, 0); objPackage.PackageType = "Module"; objPackage.License = ""; objPackage.Owner = txtOwner.Text; objPackage.Organization = txtOwner.Text; objPackage.FolderName = "DesktopModules/" + GetFolderName(); objPackage.License = "The license for this package is not currently included within the installation file, please check with the vendor for full license details."; objPackage.ReleaseNotes = "This package has no Release Notes."; PackageController.Instance.SaveExtensionPackage(objPackage); //Create desktopmodule var objDesktopModules = new DesktopModuleController(); var objDesktopModule = new DesktopModuleInfo(); objDesktopModule.DesktopModuleID = Null.NullInteger; objDesktopModule.ModuleName = GetClassName(); objDesktopModule.FolderName = GetFolderName(); objDesktopModule.FriendlyName = txtModule.Text; objDesktopModule.Description = txtDescription.Text; objDesktopModule.IsPremium = false; objDesktopModule.IsAdmin = false; objDesktopModule.Version = "01.00.00"; objDesktopModule.BusinessControllerClass = ""; objDesktopModule.CompatibleVersions = ""; objDesktopModule.Dependencies = ""; objDesktopModule.Permissions = ""; objDesktopModule.PackageID = objPackage.PackageID; objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule); objDesktopModule = objDesktopModules.GetDesktopModule(objDesktopModule.DesktopModuleID); //Add OwnerName to the DesktopModule taxonomy and associate it with this module var vocabularyId = -1; var termId = -1; var objTermController = DotNetNuke.Entities.Content.Common.Util.GetTermController(); var objTerms = objTermController.GetTermsByVocabulary("Module_Categories"); foreach (Term term in objTerms) { vocabularyId = term.VocabularyId; if (term.Name == txtOwner.Text) { termId = term.TermId; } } if (termId == -1) { termId = objTermController.AddTerm(new Term(vocabularyId) { Name = txtOwner.Text }); } var objTerm = objTermController.GetTerm(termId); var objContentController = DotNetNuke.Entities.Content.Common.Util.GetContentController(); var objContent = objContentController.GetContentItem(objDesktopModule.ContentItemId); objTermController.AddTermToContent(objTerm, objContent); //Add desktopmodule to all portals DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID); //Create module definition var objModuleDefinition = new ModuleDefinitionInfo(); objModuleDefinition.ModuleDefID = Null.NullInteger; objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID; // need core enhancement to have a unique DefinitionName objModuleDefinition.FriendlyName = GetClassName(); //objModuleDefinition.FriendlyName = txtModule.Text; //objModuleDefinition.DefinitionName = GetClassName(); objModuleDefinition.DefaultCacheTime = 0; objModuleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(objModuleDefinition, false, true); //Create modulecontrol var objModuleControl = new ModuleControlInfo(); objModuleControl.ModuleControlID = Null.NullInteger; objModuleControl.ModuleDefID = objModuleDefinition.ModuleDefID; objModuleControl.ControlKey = ""; objModuleControl.ControlSrc = "DesktopModules/" + GetFolderName() + "/" + controlName; objModuleControl.ControlTitle = ""; objModuleControl.ControlType = SecurityAccessLevel.View; objModuleControl.HelpURL = ""; objModuleControl.IconFile = ""; objModuleControl.ViewOrder = 0; objModuleControl.SupportsPartialRendering = false; objModuleControl.SupportsPopUps = false; ModuleControlController.AddModuleControl(objModuleControl); //Update current module to reference new moduledefinition var objModules = new ModuleController(); var objModule = objModules.GetModule(ModuleId, TabId, false); objModule.ModuleDefID = objModuleDefinition.ModuleDefID; objModule.ModuleTitle = txtModule.Text; //HACK - need core enhancement to be able to update ModuleDefID DotNetNuke.Data.DataProvider.Instance().ExecuteSQL("Update dbo.Modules set ModuleDefID = " + objModule.ModuleDefID.ToString() + " where ModuleID = " + ModuleId.ToString()); objModules.UpdateModule(objModule); return(true); } else { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TemplateProblem.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); return(false); } } else { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AlreadyExists.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning); return(false); } } catch (Exception exc) { Exceptions.LogException(exc); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.ToString(), ModuleMessage.ModuleMessageType.RedError); return(false); } }
/// <summary> /// Page_Load runs when the control is loaded. /// </summary> /// <returns></returns> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/28/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void Page_Load(Object sender, EventArgs e) { try { if ((Request.QueryString["desktopmoduleid"] != null)) { DesktopModuleId = int.Parse(Request.QueryString["desktopmoduleid"]); if (DesktopModuleId == -2) { DesktopModuleId = Null.NullInteger; } } else { DesktopModuleId = Null.NullInteger; } if ((Request.QueryString["moduledefid"] != null)) { ModuleDefId = int.Parse(Request.QueryString["moduledefid"]); } else { ModuleDefId = Null.NullInteger; } if ((Request.QueryString["modulecontrolid"] != null)) { ModuleControlId = int.Parse(Request.QueryString["modulecontrolid"]); } else { ModuleControlId = Null.NullInteger; } if (Page.IsPostBack == false) { DesktopModuleController objDesktopModules = new DesktopModuleController(); DesktopModuleInfo objDesktopModule; objDesktopModule = objDesktopModules.GetDesktopModule(DesktopModuleId); if (objDesktopModule != null) { txtModule.Text = objDesktopModule.FriendlyName; } else { txtModule.Text = Localization.GetString("SkinObjects"); txtTitle.Enabled = false; cboType.Enabled = false; txtViewOrder.Enabled = false; cboIcon.Enabled = false; } ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController(); ModuleDefinitionInfo objModuleDefinition; objModuleDefinition = objModuleDefinitions.GetModuleDefinition(ModuleDefId); if (objModuleDefinition != null) { txtDefinition.Text = objModuleDefinition.FriendlyName; } ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem")); ModuleControlController objModuleControls = new ModuleControlController(); ModuleControlInfo objModuleControl; objModuleControl = objModuleControls.GetModuleControl(ModuleControlId); // Added to populate cboSource with desktop module or skin controls // Issue #586 BindControlList("DesktopModules", true); BindControlList("Admin/Skins", false); if (objDesktopModule == null) // Add Container Controls { BindControlList("Admin/Containers", false); } if (!Null.IsNull(ModuleControlId)) { if (objModuleControl != null) { txtKey.Text = objModuleControl.ControlKey; txtTitle.Text = objModuleControl.ControlTitle; if (cboSource.Items.FindByValue(objModuleControl.ControlSrc.ToString().ToLower()) != null) { cboSource.Items.FindByValue(objModuleControl.ControlSrc.ToString().ToLower()).Selected = true; LoadIcons(); } if (cboType.Items.FindByValue(Convert.ToInt32(objModuleControl.ControlType).ToString()) != null) { cboType.Items.FindByValue(Convert.ToInt32(objModuleControl.ControlType).ToString()).Selected = true; } if (!Null.IsNull(objModuleControl.ViewOrder)) { txtViewOrder.Text = objModuleControl.ViewOrder.ToString(); } if (cboIcon.Items.FindByValue(objModuleControl.IconFile.ToLower()) != null) { cboIcon.Items.FindByValue(objModuleControl.IconFile.ToLower()).Selected = true; } if (!Null.IsNull(objModuleControl.HelpURL)) { txtHelpURL.Text = objModuleControl.HelpURL; } } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private void BindFiles(string controlSrc) { string[] fileList; this.cboFile.Items.Clear(); var objModuleControl = ModuleControlController.GetModuleControl(this.ModuleControlId); var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID); var objDesktopModule = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, this.PortalId); var relativePath = $"DesktopModules/{(objModuleControl.ControlSrc.EndsWith(".mvc") ? "MVC/" : string.Empty)}{objDesktopModule.FolderName}/"; var modulePath = this.Server.MapPath(relativePath); if (Directory.Exists(modulePath)) { // iterate through files in desktopmodules folder fileList = Directory.GetFiles(modulePath, "*", SearchOption.AllDirectories); foreach (string filePath in fileList) { switch (Path.GetExtension(filePath).ToLowerInvariant()) { case ".ascx": this.cboFile.Items.Add(new ListItem(filePath.Substring(modulePath.Length), filePath)); var resxPath = filePath.Replace(Path.GetFileName(filePath), "App_LocalResources\\" + Path.GetFileName(filePath)) + ".resx"; if (File.Exists(resxPath)) { this.cboFile.Items.Add(new ListItem(filePath.Substring(modulePath.Length), resxPath)); } break; case ".vb": case ".cs": case ".vbhtml": case ".cshtml": case ".css": case ".js": case ".txt": case ".html": case ".xml": case ".xslt": case ".sql": case ".sqldataprovider": this.cboFile.Items.Add(new ListItem(filePath.Substring(modulePath.Length), filePath)); break; } } } else { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FolderNameInvalid", this.LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } // iterate through files in app_code folder modulePath = Globals.ApplicationMapPath + "\\App_Code\\" + objDesktopModule.FolderName.Replace("/", "\\") + "\\"; if (Directory.Exists(modulePath)) { fileList = Directory.GetFiles(modulePath); foreach (string filePath in fileList) { switch (Path.GetExtension(filePath).ToLowerInvariant()) { case ".vb": this.cboFile.Items.Add(new ListItem(Path.GetFileName(filePath), filePath)); break; case ".cs": this.cboFile.Items.Add(new ListItem(Path.GetFileName(filePath), filePath)); break; } } } // select file if (this.cboFile.Items.FindByValue(Globals.ApplicationMapPath + "\\" + controlSrc.Replace("/", "\\")) != null) { this.cboFile.Items.FindByValue(Globals.ApplicationMapPath + "\\" + controlSrc.Replace("/", "\\")).Selected = true; } }
private string CreateModuleControl() { var objModuleControl = ModuleControlController.GetModuleControl(this.ModuleControlId); var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID); var objDesktopModule = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, this.PortalId); var objPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == objDesktopModule.PackageID); var moduleTemplatePath = this.Server.MapPath(this.ControlPath) + "Templates\\" + this.optLanguage.SelectedValue + "\\" + this.cboTemplate.SelectedValue + "\\"; EventLogController.Instance.AddLog("Processing Template Folder", moduleTemplatePath, this.PortalSettings, -1, EventLogController.EventLogType.HOST_ALERT); var controlName = Null.NullString; var fileName = Null.NullString; var modulePath = Null.NullString; var sourceCode = Null.NullString; // iterate through files in template folder string[] fileList = Directory.GetFiles(moduleTemplatePath); foreach (string filePath in fileList) { modulePath = this.Server.MapPath("DesktopModules/" + objDesktopModule.FolderName + "/"); // open file using (TextReader tr = new StreamReader(filePath)) { sourceCode = tr.ReadToEnd(); tr.Close(); } // replace tokens var owner = objPackage.Owner.Replace(" ", string.Empty); if (string.IsNullOrEmpty(owner)) { owner = "DNN"; } sourceCode = sourceCode.Replace("_OWNER_", owner); sourceCode = sourceCode.Replace("_MODULE_", objDesktopModule.FriendlyName.Replace(" ", string.Empty)); sourceCode = sourceCode.Replace("_CONTROL_", this.GetControl()); sourceCode = sourceCode.Replace("_YEAR_", DateTime.Now.Year.ToString()); // get filename fileName = Path.GetFileName(filePath); fileName = fileName.Replace("template", this.GetControl()); fileName = fileName.Replace("_OWNER_", objPackage.Owner.Replace(" ", string.Empty)); fileName = fileName.Replace("_MODULE_", objDesktopModule.FriendlyName.Replace(" ", string.Empty)); fileName = fileName.Replace("_CONTROL_", this.GetControl()); switch (Path.GetExtension(filePath).ToLowerInvariant()) { case ".ascx": controlName = fileName; break; case ".vbhtml": controlName = fileName; break; case ".cshtml": controlName = fileName; break; case ".resx": modulePath = modulePath + "\\App_LocalResources\\"; break; case ".vb": if (filePath.ToLowerInvariant().IndexOf(".ascx") == -1) { modulePath = modulePath.Replace("DesktopModules", "App_Code"); } break; case ".cs": if (filePath.ToLowerInvariant().IndexOf(".ascx") == -1) { modulePath = modulePath.Replace("DesktopModules", "App_Code"); } break; case ".js": modulePath = modulePath + "\\js\\"; break; } // check if folder exists if (!Directory.Exists(modulePath)) { Directory.CreateDirectory(modulePath); } // check if file already exists if (!File.Exists(modulePath + fileName)) { // create file using (TextWriter tw = new StreamWriter(modulePath + fileName)) { tw.WriteLine(sourceCode); tw.Close(); } EventLogController.Instance.AddLog("Created File", modulePath + fileName, this.PortalSettings, -1, EventLogController.EventLogType.HOST_ALERT); } } // Create module control if (controlName != Null.NullString) { try { objModuleControl = new ModuleControlInfo(); objModuleControl.ModuleControlID = Null.NullInteger; objModuleControl.ModuleDefID = objModuleDefinition.ModuleDefID; objModuleControl.ControlKey = this.GetControl(); objModuleControl.ControlSrc = "DesktopModules/" + objDesktopModule.FolderName + "/" + controlName; objModuleControl.ControlTitle = this.txtControl.Text; objModuleControl.ControlType = (SecurityAccessLevel)Enum.Parse(typeof(SecurityAccessLevel), this.cboType.SelectedItem.Value); objModuleControl.HelpURL = string.Empty; objModuleControl.IconFile = string.Empty; objModuleControl.ViewOrder = 0; objModuleControl.SupportsPartialRendering = true; objModuleControl.SupportsPopUps = true; ModuleControlController.AddModuleControl(objModuleControl); controlName = objModuleControl.ControlSrc; } catch { // Suppress error } } DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ControlCreated", this.LocalResourceFile), ModuleMessage.ModuleMessageType.GreenSuccess); return(controlName); }
private int CreateModuleFromControl(CreateModuleDto createModuleDto, out string newPageUrl, out string errorMessage) { newPageUrl = string.Empty; errorMessage = string.Empty; if (string.IsNullOrEmpty(createModuleDto.FileName)) { errorMessage = "NoControl"; return(Null.NullInteger); } try { var folder = PathUtils.Instance.RemoveTrailingSlash(this.GetSourceFolder(createModuleDto)); var friendlyName = createModuleDto.ModuleName; var name = createModuleDto.ModuleName; var moduleControl = "DesktopModules/" + folder + "/" + createModuleDto.FileName; var packageInfo = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name.Equals(createModuleDto.ModuleName, StringComparison.OrdinalIgnoreCase) || p.FriendlyName.Equals(createModuleDto.ModuleName, StringComparison.OrdinalIgnoreCase)); if (packageInfo != null) { errorMessage = "NonuniqueName"; return(Null.NullInteger); } var package = new PackageInfo { Name = name, FriendlyName = friendlyName, Description = createModuleDto.Description, Version = new Version(1, 0, 0), PackageType = "Module", License = Util.PACKAGE_NoLicense }; //Save Package PackageController.Instance.SaveExtensionPackage(package); var objDesktopModule = new DesktopModuleInfo { DesktopModuleID = Null.NullInteger, ModuleName = name, FolderName = folder, FriendlyName = friendlyName, Description = createModuleDto.Description, IsPremium = false, IsAdmin = false, Version = "01.00.00", BusinessControllerClass = "", CompatibleVersions = "", Dependencies = "", Permissions = "", PackageID = package.PackageID }; objDesktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(objDesktopModule, false, true); //Add module to all portals DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID); //Save module definition var moduleDefinition = new ModuleDefinitionInfo(); moduleDefinition.ModuleDefID = Null.NullInteger; moduleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID; moduleDefinition.FriendlyName = friendlyName; moduleDefinition.DefaultCacheTime = 0; moduleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(moduleDefinition, false, true); //Save module control var objModuleControl = new ModuleControlInfo(); objModuleControl.ModuleControlID = Null.NullInteger; objModuleControl.ModuleDefID = moduleDefinition.ModuleDefID; objModuleControl.ControlKey = ""; objModuleControl.ControlSrc = moduleControl; objModuleControl.ControlTitle = ""; objModuleControl.ControlType = SecurityAccessLevel.View; objModuleControl.HelpURL = ""; objModuleControl.IconFile = ""; objModuleControl.ViewOrder = 0; objModuleControl.SupportsPartialRendering = false; ModuleControlController.AddModuleControl(objModuleControl); if (createModuleDto.AddPage) { newPageUrl = this.CreateNewPage(moduleDefinition); } return(package.PackageID); } catch (Exception ex) { Exceptions.LogException(ex); errorMessage = "CreateModuleFailed"; return(Null.NullInteger); } }
/// <summary> /// Fills the module list. /// </summary> private void FillModuleList() { PortalSettings portalSettings = PortalController.Instance.GetCurrentPortalSettings(); List <TabInfo> objTabs = TabController.GetPortalTabs(portalSettings.PortalId, -1, true, true); var objTabController = new TabController(); var objDesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName( "DnnForge - NewsArticles", portalSettings.PortalId); if (objDesktopModuleInfo == null) { return; } foreach (var objTab in objTabs.Where(tab => !tab.IsDeleted)) { var objModules = new ModuleController(); foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID)) { ModuleInfo objModule = pair.Value; if (objModule.IsDeleted) { continue; } if (objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID) { continue; } string strPath = objTab.TabName; TabInfo objTabSelected = objTab; while (objTabSelected.ParentId != Null.NullInteger) { objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false); if (objTabSelected == null) { break; } strPath = string.Format("{0} -> {1}", objTabSelected.TabName, strPath); } var objListItem = new ListItem { Value = string.Format( "{0}-{1}", objModule.TabID, objModule.ModuleID), Text = string.Format( "{2}: {0} -> {3}: {1}", strPath, objModule.ModuleTitle, Localization.GetString( "Page.Text", this.ResXFile, this.LangCode), Localization.GetString( "ModuleInstance.Text", this.ResXFile, this.LangCode)) }; ModuleListDropDown.Items.Add(objListItem); } } }
/// <summary> /// Process legacy module version 3 .dnn install file. /// </summary> /// <param name="desktopModule"></param> public static void ProcessLegacyModule(DesktopModuleInfo desktopModule) { // Get the Module folder string moduleFolder = Path.Combine(Globals.ApplicationMapPath, Path.Combine("DesktopModules", desktopModule.FolderName)); // Find legacy manifest XPathNavigator rootNav = null; try { string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions"; string[] files = Directory.GetFiles(moduleFolder, "*.dnn.config"); if (files.Length > 0) { // Create an XPathDocument from the Xml var doc = new XPathDocument(new FileStream(files[0], FileMode.Open, FileAccess.Read)); rootNav = doc.CreateNavigator().SelectSingleNode("dotnetnuke"); } // Module is not affiliated with a Package var package = new PackageInfo(new InstallerInfo()); package.Name = desktopModule.ModuleName; package.FriendlyName = desktopModule.FriendlyName; package.Description = desktopModule.Description; package.Version = new Version(1, 0, 0); if (!string.IsNullOrEmpty(desktopModule.Version)) { package.Version = new Version(desktopModule.Version); } if (hostModules.Contains(desktopModule.ModuleName)) { // Host Module so make this a system package package.IsSystemPackage = true; desktopModule.IsAdmin = true; } else { desktopModule.IsAdmin = false; } package.PackageType = "Module"; // See if the Module is using a "Namespace" for its name ParsePackageName(package); if (files.Length > 0) { var modulewriter = new ModulePackageWriter(desktopModule, rootNav, package); package.Manifest = modulewriter.WriteManifest(true); } else { package.Manifest = string.Empty; // module has no manifest } // Save Package PackageController.Instance.SaveExtensionPackage(package); // Update Desktop Module with new PackageID desktopModule.PackageID = package.PackageID; // Save DesktopModule DesktopModuleController.SaveDesktopModule(desktopModule, false, false); } catch (Exception exc) { Logger.Error(exc); } }
/// <summary>Called when a module is upgraded.</summary> /// <param name="version">The version.</param> /// <returns>Success if all goes well, otherwise, Failed.</returns> public string UpgradeModule(string version) { try { switch (version) { case "07.04.00": const string ResourceFile = ModuleFolder + "/App_LocalResources/ProviderConfiguration.ascx.resx"; string pageName = Localization.GetString("HTMLEditorPageName", ResourceFile); string pageDescription = Localization.GetString("HTMLEditorPageDescription", ResourceFile); // Create HTML Editor Config Page (or get existing one) TabInfo editorPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/HtmlEditorManager_Standard_16x16.png", ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", false); // Find the RadEditor control and remove it Upgrade.RemoveModule("RadEditor Manager", editorPage.TabName, editorPage.ParentId, false); // Add Module To Page int moduleDefId = this.GetModuleDefinitionID("DotNetNuke.HtmlEditorManager", "Html Editor Management"); Upgrade.AddModuleToPage(editorPage, moduleDefId, pageName, ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", true); foreach (var item in DesktopModuleController.GetDesktopModules(Null.NullInteger)) { DesktopModuleInfo moduleInfo = item.Value; if (moduleInfo.ModuleName == "DotNetNuke.HtmlEditorManager") { moduleInfo.Category = "Host"; DesktopModuleController.SaveDesktopModule(moduleInfo, false, false); } } break; case "09.01.01": if (this.RadEditorProviderInstalled()) { UpdateRadCfgFiles(); } if (this.TelerikAssemblyExists()) { UpdateWebConfigFile(); } break; case "09.02.00": if (this.TelerikAssemblyExists()) { UpdateTelerikEncryptionKey("Telerik.Web.UI.DialogParametersEncryptionKey"); } break; case "09.02.01": if (this.TelerikAssemblyExists()) { UpdateTelerikEncryptionKey("Telerik.Upload.ConfigurationHashKey"); } break; } } catch (Exception ex) { var xlc = new ExceptionLogController(); xlc.AddLog(ex); return("Failed"); } return("Success"); }
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); } }
/// <summary> /// Serializes all portal Tabs /// </summary> /// <param name="xmlTemplate">Reference to XmlDocument context</param> /// <param name="nodeTabs">Node to add the serialized objects</param> /// <param name="objportal">Portal to serialize</param> /// <param name="hRoles">A hastable with all serialized roles</param> /// <remarks> /// Only portal tabs will be exported to the template, Admin tabs are not exported. /// On each tab, all modules will also be exported. /// </remarks> /// <history> /// [VMasanas] 23/09/2004 Created /// </history> public void SerializeTabs(XmlDocument xmlTemplate, XmlNode nodeTabs, PortalInfo objportal, Hashtable hRoles) { TabController objtabs = new TabController(); //supporting object to build the tab hierarchy Hashtable hTabs = new Hashtable(); XmlSerializer xserTabs = new XmlSerializer(typeof(TabInfo)); foreach (TabInfo objtab in objtabs.GetTabs(objportal.PortalID)) { //if not an admin tab & not deleted if (objtab.TabOrder < 10000 && !objtab.IsDeleted) { StringWriter sw = new StringWriter(); xserTabs.Serialize(sw, objtab); XmlDocument xmlTab = new XmlDocument(); xmlTab.LoadXml(sw.GetStringBuilder().ToString()); XmlNode nodeTab = xmlTab.SelectSingleNode("tab"); nodeTab.Attributes.Remove(nodeTab.Attributes["xmlns:xsd"]); nodeTab.Attributes.Remove(nodeTab.Attributes["xmlns:xsi"]); XmlNode newnode; if (objtab.TabID == objportal.SplashTabId) { newnode = xmlTab.CreateElement("tabtype"); newnode.InnerXml = "splashtab"; nodeTab.AppendChild(newnode); } else if (objtab.TabID == objportal.HomeTabId) { newnode = xmlTab.CreateElement("tabtype"); newnode.InnerXml = "hometab"; nodeTab.AppendChild(newnode); } else if (objtab.TabID == objportal.UserTabId) { newnode = xmlTab.CreateElement("tabtype"); newnode.InnerXml = "usertab"; nodeTab.AppendChild(newnode); } else if (objtab.TabID == objportal.LoginTabId) { newnode = xmlTab.CreateElement("tabtype"); newnode.InnerXml = "logintab"; nodeTab.AppendChild(newnode); } if (!Null.IsNull(objtab.ParentId)) { newnode = xmlTab.CreateElement("parent"); newnode.InnerXml = Server.HtmlEncode(hTabs[objtab.ParentId].ToString()); nodeTab.AppendChild(newnode); // save tab as: ParentTabName/CurrentTabName hTabs.Add(objtab.TabID, hTabs[objtab.ParentId] + "/" + objtab.TabName); } else { // save tab as: CurrentTabName hTabs.Add(objtab.TabID, objtab.TabName); } // Serialize modules XmlNode nodePanes; nodePanes = nodeTab.AppendChild(xmlTab.CreateElement("panes")); ModuleController objmodules = new ModuleController(); DesktopModuleController objDesktopModules = new DesktopModuleController(); ModuleDefinitionController objModuleDefController = new ModuleDefinitionController(); XmlSerializer xserModules = new XmlSerializer(typeof(ModuleInfo)); Dictionary <int, ModuleInfo> dict = objmodules.GetTabModules(objtab.TabID); foreach (KeyValuePair <int, ModuleInfo> pair in dict) { ModuleInfo objmodule = pair.Value; if (!objmodule.IsDeleted) { sw = new StringWriter(); xserModules.Serialize(sw, objmodule); XmlDocument xmlModule = new XmlDocument(); xmlModule.LoadXml(sw.GetStringBuilder().ToString()); XmlNode nodeModule = xmlModule.SelectSingleNode("module"); nodeModule.Attributes.Remove(nodeModule.Attributes["xmlns:xsd"]); nodeModule.Attributes.Remove(nodeModule.Attributes["xmlns:xsi"]); if (nodePanes.SelectSingleNode("descendant::pane[name='" + objmodule.PaneName + "']") == null) { // new pane found XmlNode nodePane = xmlModule.CreateElement("pane"); XmlNode nodeName = nodePane.AppendChild(xmlModule.CreateElement("name")); nodeName.InnerText = objmodule.PaneName; nodePane.AppendChild(xmlModule.CreateElement("modules")); nodePanes.AppendChild(xmlTab.ImportNode(nodePane, true)); } XmlNode nodeModules = nodePanes.SelectSingleNode("descendant::pane[name='" + objmodule.PaneName + "']/modules"); newnode = xmlModule.CreateElement("definition"); ModuleDefinitionInfo objModuleDef = objModuleDefController.GetModuleDefinition(objmodule.ModuleDefID); newnode.InnerText = objDesktopModules.GetDesktopModule(objModuleDef.DesktopModuleID).ModuleName; nodeModule.AppendChild(newnode); //Add Module Definition Info XmlNode nodeDefinition = xmlModule.CreateElement("moduledefinition"); nodeDefinition.InnerText = objModuleDef.FriendlyName; nodeModule.AppendChild(nodeDefinition); if (chkContent.Checked) { AddContent(nodeModule, objmodule); } nodeModules.AppendChild(xmlTab.ImportNode(nodeModule, true)); } } nodeTabs.AppendChild(xmlTemplate.ImportNode(nodeTab, true)); } } }
/// <summary> /// </summary> /// <remarks> /// Loads the cboSource control list with locations of controls. /// </remarks> /// <history> /// </history> private ModuleDefinitionInfo ImportControl(string controlSrc) { ModuleDefinitionInfo moduleDefinition = null; try { string folder = PathUtils.Instance.RemoveTrailingSlash(GetSourceFolder()); string friendlyName = txtName.Text; string name = GetClassName(); string moduleControl = "DesktopModules/" + folder + "/" + controlSrc; if (PackageController.GetPackages().Any(p => p.Name == name || p.FriendlyName == friendlyName)) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("NonuniqueName", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } else { var package = new PackageInfo(); package.Name = name; package.FriendlyName = friendlyName; package.Description = txtDescription.Text; package.Version = new Version(1, 0, 0); package.PackageType = "Module"; package.License = Util.PACKAGE_NoLicense; //Save Package PackageController.SavePackage(package); var objDesktopModules = new DesktopModuleController(); var objDesktopModule = new DesktopModuleInfo(); objDesktopModule.DesktopModuleID = Null.NullInteger; objDesktopModule.ModuleName = name; objDesktopModule.FolderName = folder; objDesktopModule.FriendlyName = friendlyName; objDesktopModule.Description = txtDescription.Text; objDesktopModule.IsPremium = false; objDesktopModule.IsAdmin = false; objDesktopModule.Version = "01.00.00"; objDesktopModule.BusinessControllerClass = ""; objDesktopModule.CompatibleVersions = ""; objDesktopModule.Dependencies = ""; objDesktopModule.Permissions = ""; objDesktopModule.PackageID = package.PackageID; #pragma warning disable 612,618 objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule); #pragma warning restore 612,618 //Add module to all portals DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID); //Save module definition moduleDefinition = new ModuleDefinitionInfo(); moduleDefinition.ModuleDefID = Null.NullInteger; moduleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID; moduleDefinition.FriendlyName = friendlyName; moduleDefinition.DefaultCacheTime = 0; moduleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(moduleDefinition, false, true); //Save module control var objModuleControl = new ModuleControlInfo(); objModuleControl.ModuleControlID = Null.NullInteger; objModuleControl.ModuleDefID = moduleDefinition.ModuleDefID; objModuleControl.ControlKey = ""; objModuleControl.ControlSrc = moduleControl; objModuleControl.ControlTitle = ""; objModuleControl.ControlType = SecurityAccessLevel.View; objModuleControl.HelpURL = ""; objModuleControl.IconFile = ""; objModuleControl.ViewOrder = 0; objModuleControl.SupportsPartialRendering = false; ModuleControlController.AddModuleControl(objModuleControl); } } catch (Exception exc) { Exceptions.LogException(exc); UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ImportControl.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } return(moduleDefinition); }
/// ----------------------------------------------------------------------------- /// <summary> /// The Commit method finalises the Install and commits any pending changes. /// </summary> /// <remarks>In the case of Modules this is not neccessary</remarks> /// ----------------------------------------------------------------------------- public override void Commit() { //Add CodeSubDirectory if (!string.IsNullOrEmpty(_desktopModule.CodeSubDirectory)) { Config.AddCodeSubDirectory(_desktopModule.CodeSubDirectory); } if (_desktopModule.SupportedFeatures == Null.NullInteger) { //Set an Event Message so the features are loaded by reflection on restart var oAppStartMessage = new EventMessage { Priority = MessagePriority.High, ExpirationDate = DateTime.Now.AddYears(-1), SentDate = DateTime.Now, Body = "", ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke", ProcessorCommand = "UpdateSupportedFeatures" }; //Add custom Attributes for this message oAppStartMessage.Attributes.Add("BusinessControllerClass", _desktopModule.BusinessControllerClass); oAppStartMessage.Attributes.Add("desktopModuleID", _desktopModule.DesktopModuleID.ToString()); //send it to occur on next App_Start Event EventQueueController.SendMessage(oAppStartMessage, "Application_Start_FirstRequest"); } //Add Event Message if (_eventMessage != null) { if (!String.IsNullOrEmpty(_eventMessage.Attributes["UpgradeVersionsList"])) { _eventMessage.Attributes.Set("desktopModuleID", _desktopModule.DesktopModuleID.ToString()); EventQueueController.SendMessage(_eventMessage, "Application_Start"); } } //Add DesktopModule to all portals if (!_desktopModule.IsPremium) { DesktopModuleController.AddDesktopModuleToPortals(_desktopModule.DesktopModuleID); } //Add DesktopModule to all portals if (!String.IsNullOrEmpty(_desktopModule.AdminPage)) { foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { bool createdNewPage = false, addedNewModule = false; DesktopModuleController.AddDesktopModulePageToPortal(_desktopModule, _desktopModule.AdminPage, portal.PortalID, ref createdNewPage, ref addedNewModule); if (createdNewPage) { Log.AddInfo(string.Format(Util.MODULE_AdminPageAdded, _desktopModule.AdminPage, portal.PortalID)); } if (addedNewModule) { Log.AddInfo(string.Format(Util.MODULE_AdminPagemoduleAdded, _desktopModule.AdminPage, portal.PortalID)); } } } //Add host items if (_desktopModule.Page != null && !String.IsNullOrEmpty(_desktopModule.HostPage)) { bool createdNewPage = false, addedNewModule = false; DesktopModuleController.AddDesktopModulePageToPortal(_desktopModule, _desktopModule.HostPage, Null.NullInteger, ref createdNewPage, ref addedNewModule); if (createdNewPage) { Log.AddInfo(string.Format(Util.MODULE_HostPageAdded, _desktopModule.HostPage)); } if (addedNewModule) { Log.AddInfo(string.Format(Util.MODULE_HostPagemoduleAdded, _desktopModule.HostPage)); } } }
private string CleanupExpired() { var returnStr = "Event Cleanup completed."; var noDeletedEvents = 0; Status = "Performing Event Cleanup"; var objDesktopModule = default(DesktopModuleInfo); objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", 0); if (ReferenceEquals(objDesktopModule, null)) { return("Module Definition 'DNN_Events' not found. Cleanup cannot be performed."); } Status = "Performing Event Cleanup: Dummy"; Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName; var objPortals = new PortalController(); var objPortal = default(PortalInfo); var objModules = new ModuleController(); var objModule = default(ModuleInfo); var lstportals = objPortals.GetPortals(); foreach (PortalInfo tempLoopVar_objPortal in lstportals) { objPortal = tempLoopVar_objPortal; Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID: Dummy"; Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" + objPortal.PortalID; var lstModules = objModules.GetModulesByDefinition(objPortal.PortalID, objDesktopModule.FriendlyName); foreach (ModuleInfo tempLoopVar_objModule in lstModules) { objModule = tempLoopVar_objModule; // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition if (ReferenceEquals(objModule, null)) { continue; } Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" + objPortal.PortalID + " ModuleID: Dummy"; Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" + objPortal.PortalID + " ModuleID:" + objModule.ModuleID; var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null); if (settings.Expireevents != "") { Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" + objPortal.PortalID + " ModuleID:" + objModule.ModuleID + " IN PROGRESS"; var objEventCtl = new EventController(); var expireDate = DateAndTime.DateAdd(DateInterval.Day, -Convert.ToInt32(settings.Expireevents), DateTime.UtcNow); var startdate = expireDate.AddYears(-10); var endDate = expireDate.AddDays(1); var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, settings); var categoryIDs = new ArrayList(); categoryIDs.Add("-1"); var locationIDs = new ArrayList(); locationIDs.Add("-1"); var lstEvents = objEventInfoHelper.GetEvents(startdate, endDate, false, categoryIDs, locationIDs, -1, -1); var objEventTimeZoneUtilities = new EventTimeZoneUtilities(); foreach (EventInfo objEvent in lstEvents) { var eventTime = objEventTimeZoneUtilities.ConvertToUTCTimeZone( objEvent.EventTimeEnd, objEvent.EventTimeZoneId); if (eventTime < expireDate) { objEvent.Cancelled = true; objEventCtl.EventsSave(objEvent, true, 0, true); noDeletedEvents++; returnStr = "Event Cleanup completed. " + noDeletedEvents + " Events deleted."; } } objEventCtl.EventsCleanupExpired(objModule.PortalID, objModule.ModuleID); } } } Status = "Cleanup complete"; return(returnStr); }
/// ----------------------------------------------------------------------------- /// <summary> /// Exports the selected portal /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Template will be saved in Portals\_default folder. /// An extension of .template will be added to filename if not entered /// </remarks> /// <history> /// [VMasanas] 23/09/2004 Created /// [cnurse] 11/08/2004 Addition of files to template /// [aprasad] 1/17/2011 New setting AutoAddPortalAlias /// </history> /// ----------------------------------------------------------------------------- private void cmdExport_Click(Object sender, EventArgs e) { try { // Validations bool isValid = true; // Verify all ancestor pages are selected foreach (RadTreeNode page in ctlPages.CheckedNodes) { if (page.ParentNode != null && page.ParentNode.Value != "-1" && !page.ParentNode.Checked) { isValid = false; } } if (!isValid) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, LocalizeString("ErrorAncestorPages"), ModuleMessage.ModuleMessageType.RedError); } if (ctlPages.CheckedNodes.Count == 0) { isValid = false; DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, LocalizeString("ErrorPages"), ModuleMessage.ModuleMessageType.RedError); } if (!Page.IsValid || !isValid) { return; } ZipOutputStream resourcesFile; var sb = new StringBuilder(); var settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.OmitXmlDeclaration = true; settings.Indent = true; string filename; filename = Globals.HostMapPath + txtTemplateName.Text; if (!filename.EndsWith(".template")) { filename += ".template"; } XmlWriter writer = XmlWriter.Create(filename, settings); writer.WriteStartElement("portal"); writer.WriteAttributeString("version", "5.0"); //Add template description writer.WriteElementString("description", Server.HtmlEncode(txtDescription.Text)); //Serialize portal settings var portal = PortalController.Instance.GetPortal(Convert.ToInt32(cboPortals.SelectedValue)); this.SerializePortalSettings(writer, portal); this.SerializeEnabledLocales(writer, portal); SerializeExtensionUrlProviders(writer, portal.PortalID); if (chkProfile.Checked) { //Serialize Profile Definitions SerializeProfileDefinitions(writer, portal); } if (chkModules.Checked) { //Serialize Portal Desktop Modules DesktopModuleController.SerializePortalDesktopModules(writer, portal.PortalID); } if (chkRoles.Checked) { //Serialize Roles RoleController.SerializeRoleGroups(writer, portal.PortalID); } //Serialize tabs SerializeTabs(writer, portal); if (chkFiles.Checked) { //Create Zip File to hold files resourcesFile = new ZipOutputStream(File.Create(filename + ".resources")); resourcesFile.SetLevel(6); //Serialize folders (while adding files to zip file) SerializeFolders(writer, portal, ref resourcesFile); //Finish and Close Zip file resourcesFile.Finish(); resourcesFile.Close(); } writer.WriteEndElement(); writer.Close(); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", string.Format(Localization.GetString("ExportedMessage", LocalResourceFile), filename), ModuleMessage.ModuleMessageType.GreenSuccess); } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private string SendEventNotifications() { var objEvents = new EventController(); var objEvent = default(EventInfo); var objEventNotifications = new EventNotificationController(); var notifyEvents = default(ArrayList); var returnStr = "Event Notification completed."; Status = "Sending Event Notifications"; //*** All Event Notifications are stored in UTC internally. notifyEvents = objEventNotifications.EventsNotificationsToSend(DateTime.UtcNow); foreach (EventNotificationInfo objNotification in notifyEvents) { //Get the Associated Event objEvent = objEvents.EventsGet(objNotification.EventID, objNotification.ModuleID); if (!ReferenceEquals(objEvent, null)) { // Setup PortalSettings var portalSettings = CreatePortalSettings(objNotification.PortalAliasID, objNotification.TabID); var folderName = DesktopModuleController .GetDesktopModuleByModuleName("DNN_Events", objEvent.PortalID).FolderName; if (!ReferenceEquals(portalSettings, null)) { // Make up the LocalResourceFile value var templateSourceDirectory = Globals.ApplicationPath; var localResourceFile = templateSourceDirectory + "/DesktopModules/" + folderName + "/" + Localization.LocalResourceDirectory + "/EventNotification.ascx.resx"; // Send the email var objEventEmailInfo = new EventEmailInfo(); var objEventEmail = new EventEmails(portalSettings.PortalId, objNotification.ModuleID, localResourceFile, objNotification.NotifyLanguage); objEventEmailInfo.TxtEmailSubject = objEvent.Notify; objEventEmailInfo.TxtEmailBody = objEvent.Reminder; objEventEmailInfo.TxtEmailFrom = objEvent.ReminderFrom; objEventEmailInfo.UserEmails.Add(objNotification.UserEmail); objEventEmailInfo.UserLocales.Add(objNotification.NotifyLanguage); objEventEmailInfo.UserTimeZoneIds.Add(objEvent.EventTimeZoneId); var domainurl = portalSettings.PortalAlias.HTTPAlias; if (domainurl.IndexOf("/", StringComparison.Ordinal) > 0) { domainurl = domainurl.Substring(0, domainurl.IndexOf("/", StringComparison.Ordinal)); } objEventEmail.SendEmails(objEventEmailInfo, objEvent, domainurl); } //*** Update Notification (so we don't send again) objNotification.NotificationSent = true; objEventNotifications.EventsNotificationSave(objNotification); returnStr = "Event Notification completed. " + notifyEvents.Count + " Notification(s) sent!"; } } //**** Delete Expired EventNotifications (older than 30 days) var endDate = DateTime.UtcNow.AddDays(-30); objEventNotifications.EventsNotificationDelete(endDate); Status = "Event Notifications Sent Successfully"; ScheduleHistoryItem.Succeeded = true; return(returnStr); }
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); } }
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); }
public bool SavePackageSettings(PackageSettingsDto packageSettings, out string errorMessage) { errorMessage = string.Empty; try { var desktopModule = DesktopModuleController.GetDesktopModuleByPackageID(packageSettings.PackageId); var isHostUser = UserController.Instance.GetCurrentUserInfo().IsSuperUser; UpdatePermissions(desktopModule, packageSettings); if (isHostUser) { foreach (var settingName in packageSettings.EditorActions.Keys) { var settingValue = packageSettings.EditorActions[settingName]; switch (settingName.ToLowerInvariant()) { case "foldername": desktopModule.FolderName = settingValue; break; case "category": desktopModule.Category = settingValue; break; case "businesscontroller": desktopModule.BusinessControllerClass = settingValue; break; case "dependencies": desktopModule.Dependencies = settingValue; break; case "hostpermissions": desktopModule.Permissions = settingValue; break; case "premiummodule": desktopModule.IsPremium = Convert.ToBoolean(settingValue); break; case "shareable": desktopModule.Shareable = (ModuleSharing)Convert.ToInt32(settingValue); break; case "assignportal": AssignPortals(desktopModule, JsonConvert.DeserializeObject <IList <ListItemDto> >(settingValue)); break; case "unassignportal": UnassignPortals(desktopModule, JsonConvert.DeserializeObject <IList <ListItemDto> >(settingValue)); break; case "savedefinition": var definition = JsonConvert.DeserializeObject <ModuleDefinitionDto>(settingValue); SaveModuleDefinition(definition); break; case "deletedefinition": DeleteModuleDefinition(Convert.ToInt32(settingValue)); break; case "savemodulecontrol": var moduleControl = JsonConvert.DeserializeObject <ModuleControlDto>(settingValue); SaveModuleControl(moduleControl); break; case "deletemodulecontrol": DeleteModuleControl(Convert.ToInt32(settingValue)); break; } } DesktopModuleController.SaveDesktopModule(desktopModule, false, true); } return(true); } catch (Exception ex) { Logger.Error(ex); errorMessage = ex.Message; return(false); } }
private void BindData() { switch (optModuleType.SelectedItem.Value) { case "0": //new module cboTabs.Visible = false; cboModules.Visible = false; cboDesktopModules.Visible = true; txtTitle.Visible = true; lblModule.Text = Localization.GetString("Module", LocalResourceFile); lblTitle.Text = Localization.GetString("Title", LocalResourceFile); cboPermission.Enabled = true; //get list of modules cboDesktopModules.DataSource = DesktopModuleController.GetPortalDesktopModules(PortalSettings.PortalId).Values; cboDesktopModules.DataBind(); cboDesktopModules.Items.Insert(0, new ListItem("<" + Localization.GetString("SelectModule", LocalResourceFile) + ">", "-1")); //select default module int intDesktopModuleID = -1; if (!String.IsNullOrEmpty(Localization.GetString("DefaultModule", LocalResourceFile))) { DesktopModuleInfo objDesktopModule; objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(Localization.GetString("DefaultModule", LocalResourceFile, PortalSettings, null, true), PortalSettings.PortalId); if (objDesktopModule != null) { intDesktopModuleID = objDesktopModule.DesktopModuleID; } } if (intDesktopModuleID != -1 && (cboDesktopModules.Items.FindByValue(intDesktopModuleID.ToString()) != null)) { cboDesktopModules.Items.FindByValue(intDesktopModuleID.ToString()).Selected = true; } else { cboDesktopModules.SelectedIndex = 0; } break; case "1": //existing module cboTabs.Visible = true; cboModules.Visible = true; cboDesktopModules.Visible = false; txtTitle.Visible = false; lblModule.Text = Localization.GetString("Tab", LocalResourceFile); lblTitle.Text = Localization.GetString("Module", LocalResourceFile); cboPermission.Enabled = false; cboTabs.DataSource = TabController.GetPortalTabs(PortalSettings.PortalId, PortalSettings.ActiveTab.TabID, true, "<" + Localization.GetString("SelectPage", LocalResourceFile) + ">", true, false, false, false, true); cboTabs.DataBind(); break; } }
private void BindData() { if (Module != null) { var desktopModule = DesktopModuleController.GetDesktopModule(Module.DesktopModuleID, PortalId); dgPermissions.ResourceFile = Globals.ApplicationPath + "/DesktopModules/" + desktopModule.FolderName + "/" + Localization.LocalResourceDirectory + "/" + Localization.LocalSharedResourceFile; if (!Module.IsShared) { chkInheritPermissions.Checked = Module.InheritViewPermissions; dgPermissions.InheritViewPermissionsFromTab = Module.InheritViewPermissions; } txtFriendlyName.Text = Module.DesktopModule.FriendlyName; txtTitle.Text = Module.ModuleTitle; ctlIcon.Url = Module.IconFile; if (cboTab.FindItemByValue(Module.TabID.ToString()) != null) { cboTab.FindItemByValue(Module.TabID.ToString()).Selected = true; } rowTab.Visible = cboTab.Items.Count != 1; chkAllTabs.Checked = Module.AllTabs; trnewPages.Visible = chkAllTabs.Checked; allowIndexRow.Visible = desktopModule.IsSearchable; chkAllowIndex.Checked = Settings["AllowIndex"] == null || Settings["AllowIndex"] != null && bool.Parse(Settings["AllowIndex"].ToString()); txtMoniker.Text = (string)Settings["Moniker"] ?? ""; cboVisibility.SelectedIndex = (int)Module.Visibility; chkAdminBorder.Checked = Settings["hideadminborder"] != null && bool.Parse(Settings["hideadminborder"].ToString()); var objModuleDef = ModuleDefinitionController.GetModuleDefinitionByID(Module.ModuleDefID); if (objModuleDef.DefaultCacheTime == Null.NullInteger) { cacheWarningRow.Visible = true; txtCacheDuration.Text = Module.CacheTime.ToString(); } else { cacheWarningRow.Visible = false; txtCacheDuration.Text = Module.CacheTime.ToString(); } BindModuleCacheProviderList(); ShowCacheRows(); cboAlign.Items.FindByValue(Module.Alignment).Selected = true; txtColor.Text = Module.Color; txtBorder.Text = Module.Border; txtHeader.Text = Module.Header; txtFooter.Text = Module.Footer; if (!Null.IsNull(Module.StartDate)) { startDatePicker.SelectedDate = Module.StartDate; } if (!Null.IsNull(Module.EndDate) && Module.EndDate <= endDatePicker.MaxDate) { endDatePicker.SelectedDate = Module.EndDate; } BindContainers(); chkDisplayTitle.Checked = Module.DisplayTitle; chkDisplayPrint.Checked = Module.DisplayPrint; chkDisplaySyndicate.Checked = Module.DisplaySyndicate; chkWebSlice.Checked = Module.IsWebSlice; webSliceTitle.Visible = Module.IsWebSlice; webSliceExpiry.Visible = Module.IsWebSlice; webSliceTTL.Visible = Module.IsWebSlice; txtWebSliceTitle.Text = Module.WebSliceTitle; if (!Null.IsNull(Module.WebSliceExpiryDate)) { diWebSliceExpiry.SelectedDate = Module.WebSliceExpiryDate; } if (!Null.IsNull(Module.WebSliceTTL)) { txtWebSliceTTL.Text = Module.WebSliceTTL.ToString(); } if (Module.ModuleID == PortalSettings.Current.DefaultModuleId && Module.TabID == PortalSettings.Current.DefaultTabId) { chkDefault.Checked = true; } if (!Module.IsShared && Module.DesktopModule.Shareable != ModuleSharing.Unsupported) { isShareableCheckBox.Checked = Module.IsShareable; isShareableViewOnlyCheckBox.Checked = Module.IsShareableViewOnly; isShareableRow.Visible = true; chkInheritPermissions.Visible = true; } } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded. /// </summary> /// <remarks> /// </remarks> protected override void OnLoad(EventArgs e) { base.OnLoad(e); cmdCancel.Click += cmdCancel_Click; int moduleControlId = Null.NullInteger; if (Request.QueryString["ctlid"] != null) { moduleControlId = Int32.Parse(Request.QueryString["ctlid"]); } else if (Host.EnableModuleOnLineHelp) { helpFrame.Text = string.Format("<iframe src='{0}' id='helpFrame' width='100%' height='500'></iframe>", Host.HelpURL); } ModuleControlInfo objModuleControl = ModuleControlController.GetModuleControl(moduleControlId); if (objModuleControl != null) { if (!string.IsNullOrEmpty(objModuleControl.HelpURL) && Host.EnableModuleOnLineHelp) { helpFrame.Text = string.Format("<iframe src='{0}' id='helpFrame' width='100%' height='500'></iframe>", objModuleControl.HelpURL);; } else { string fileName = Path.GetFileName(objModuleControl.ControlSrc); string localResourceFile = objModuleControl.ControlSrc.Replace(fileName, Localization.LocalResourceDirectory + "/" + fileName); if (!String.IsNullOrEmpty(Localization.GetString(ModuleActionType.HelpText, localResourceFile))) { lblHelp.Text = Localization.GetString(ModuleActionType.HelpText, localResourceFile); } else { lblHelp.Text = Localization.GetString("lblHelp.Text", Localization.GetResourceFile(this, MyFileName)); } } _key = objModuleControl.ControlKey; //display module info to Host users if (UserInfo.IsSuperUser) { string strInfo = Localization.GetString("lblInfo.Text", Localization.GetResourceFile(this, MyFileName)); strInfo = strInfo.Replace("[CONTROL]", objModuleControl.ControlKey); strInfo = strInfo.Replace("[SRC]", objModuleControl.ControlSrc); ModuleDefinitionInfo objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID); if (objModuleDefinition != null) { strInfo = strInfo.Replace("[DEFINITION]", objModuleDefinition.FriendlyName); DesktopModuleInfo objDesktopModule = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId); if (objDesktopModule != null) { PackageInfo objPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == objDesktopModule.PackageID); if (objPackage != null) { strInfo = strInfo.Replace("[ORGANIZATION]", objPackage.Organization); strInfo = strInfo.Replace("[OWNER]", objPackage.Owner); strInfo = strInfo.Replace("[EMAIL]", objPackage.Email); strInfo = strInfo.Replace("[URL]", objPackage.Url); strInfo = strInfo.Replace("[MODULE]", objPackage.Name); strInfo = strInfo.Replace("[VERSION]", objPackage.Version.ToString()); } } } lblInfo.Text = Server.HtmlDecode(strInfo); } cmdHelp.Visible = !string.IsNullOrEmpty(objModuleControl.HelpURL); } if (Page.IsPostBack == false) { if (Request.UrlReferrer != null) { ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer); } else { ViewState["UrlReferrer"] = ""; } } }
/// <summary> /// /// </summary> /// <param name="Version"></param> /// <returns></returns> /// <remarks>This is not localizing Page Name or description.</remarks> public string UpgradeModule(string Version) { try { var pageName = Localization.GetString("HTMLEditorPageName", ResourceFile); var pageDescription = Localization.GetString("HTMLEditorPageDescription", ResourceFile); switch (Version) { case "06.00.00": //Create Rad Editor Config Page (or get existing one) TabInfo newPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/radeditor_config_small.png", ModuleFolder + "/images/radeditor_config_large.png", true); //Add Module To Page int moduleDefId = GetModuleDefinitionID(); Upgrade.AddModuleToPage(newPage, moduleDefId, pageName, ModuleFolder + "/images/radeditor_config_large.png", true); foreach (var item in DesktopModuleController.GetDesktopModules(Null.NullInteger)) { DesktopModuleInfo moduleInfo = item.Value; if (moduleInfo.ModuleName == "DotNetNuke.RadEditorProvider") { moduleInfo.Category = "Host"; DesktopModuleController.SaveDesktopModule(moduleInfo, false, false); } } break; case "07.00.06": UpdateConfigOfLinksType(); break; case "07.03.00": UpdateConfigFilesName(); UpdateToolsFilesName(); break; case "07.04.00": // Find the RadEditor page. It should already exist and this will return it's reference. var editorPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/HtmlEditorManager_Standard_16x16.png", ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", true); // If the Html Editor Manager is installed, then remove the old RadEditor Manager var htmlEditorManager = DesktopModuleController.GetDesktopModuleByModuleName("DotNetNuke.HtmlEditorManager", Null.NullInteger); if (htmlEditorManager != null) { Upgrade.RemoveModule("RadEditor Manager", editorPage.TabName, editorPage.ParentId, false); } break; } } catch (Exception ex) { ExceptionLogController xlc = new ExceptionLogController(); xlc.AddLog(ex); return("Failed"); } return("Success"); }
/// <summary> /// cmdDelete_Click runs when the Delete Button is clicked /// </summary> /// <history> /// [cnurse] 9/28/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void cmdDelete_Click(object sender, EventArgs e) { try { if (!Null.IsNull(DesktopModuleId)) { string strRoot = Request.MapPath("~/DesktopModules/" + txtFolderName.Text) + "\\"; // process uninstall script string strProviderType = "data"; ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(strProviderType); string strUninstallScript = "Uninstall." + objProviderConfiguration.DefaultProvider; if (File.Exists(strRoot + strUninstallScript)) { // read uninstall script StreamReader objStreamReader; objStreamReader = File.OpenText(strRoot + strUninstallScript); string strScript = objStreamReader.ReadToEnd(); objStreamReader.Close(); // execute uninstall script PortalSettings.ExecuteScript(strScript); } if (Directory.Exists(strRoot)) { if (chkDelete.Checked) { //runtime so remove files/folders // find dnn manifest file string[] arrFiles = Directory.GetFiles(strRoot, "*.dnn.config"); if (arrFiles.Length == 0) { arrFiles = Directory.GetFiles(strRoot, "*.dnn"); // legacy versions stored the *.dnn files unprotected } if (arrFiles.Length != 0) { if (File.Exists(strRoot + Path.GetFileName(arrFiles[0]))) { XmlDocument xmlDoc = new XmlDocument(); // load the manifest file xmlDoc.Load(strRoot + Path.GetFileName(arrFiles[0])); // check version XmlNode myNodeModule = null; switch (xmlDoc.DocumentElement.LocalName.ToLower()) { case "module": myNodeModule = xmlDoc.SelectSingleNode("//module"); break; case "dotnetnuke": string version = xmlDoc.DocumentElement.Attributes["version"].InnerText; switch (version) { case "2.0": // V2 allows for multiple folders in a single DNN definition - we need to identify the correct node foreach (XmlNode nodeModule in xmlDoc.SelectNodes("//dotnetnuke/folders/folder")) { if (nodeModule.SelectSingleNode("name").InnerText.Trim() == txtFriendlyName.Text) { myNodeModule = nodeModule; break; } } break; case "3.0": // V3 also allows for multiple folders in a single DNN definition - but uses module name foreach (XmlNode nodeModule in xmlDoc.SelectNodes("//dotnetnuke/folders/folder")) { if (nodeModule.SelectSingleNode("name").InnerText.Trim() == txtModuleName.Text) { myNodeModule = nodeModule; break; } } break; } break; } // loop through file nodes foreach (XmlNode nodeFile in myNodeModule.SelectNodes("files/file")) { string strFileName = nodeFile.SelectSingleNode("name").InnerText.Trim(); string strFileExtension = Path.GetExtension(strFileName).Replace(".", ""); if (strFileExtension == "dll") { // remove DLL from /bin strFileName = Request.MapPath("~/bin/") + strFileName; } if (File.Exists(strFileName)) { File.SetAttributes(strFileName, FileAttributes.Normal); File.Delete(strFileName); } } //Recursively Delete any sub Folders DeleteSubFolders(strRoot, true); //Recursively delete AppCode folders string appCode = strRoot.Replace("DesktopModules", "App_Code"); DeleteSubFolders(appCode, true); //Delete the <codeSubDirectory> node in web.config Config.RemoveCodeSubDirectory(txtFolderName.Text); } } } } // delete the desktopmodule database record DesktopModuleController objDesktopModules = new DesktopModuleController(); objDesktopModules.DeleteDesktopModule(DesktopModuleId); } Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }