/// <summary> /// Permits all users to access Formulate if configured in the web.config. /// </summary> private void PermitAccess() { // Variables. var key = SettingConstants.EnsureUsersCanAccess; var ensure = ConfigurationManager.AppSettings[key]; // Should all users be given access to Formulate? if (string.IsNullOrWhiteSpace(ensure)) { return; } // Variables. var doc = new XmlDocument(); var actionXml = Resources.GrantAllUsersPermissionToSection; doc.LoadXml(actionXml); // Grant access permission. PackageAction.RunPackageAction("Formulate", "Formulate.GrantPermissionToSection", doc.FirstChild); }
/// <summary> /// Adds the Formulate section to Umbraco. /// </summary> /// <param name="applicationContext"> /// The current application context. /// </param> private void AddSection(ApplicationContext applicationContext) { // Queue section change. QueueInstallAction(() => { var service = applicationContext.Services.SectionService; var existingSection = service.GetByAlias("formulate"); if (existingSection == null) { // Logging. LogHelper.Info <ApplicationStartedHandler>("Installing Formulate section in applications.config."); // Variables. var doc = new XmlDocument(); var actionXml = Resources.TransformApplications; doc.LoadXml(actionXml); // Add to applications. PackageAction.RunPackageAction("Formulate", "Formulate.TransformXmlFile", doc.FirstChild); // Logging. LogHelper.Info <ApplicationStartedHandler>("Done installing Formulate section in applications.config."); } }); }
/// <summary> /// Adds the Formulate dashboard to the Formulate section. /// </summary> private void AddDashboard() { // Queue dashboard transformation. QueueInstallAction(() => { var exists = DashboardExists(); if (!exists) { // Logging. LogHelper.Info <ApplicationStartedHandler>("Installing Formulate dashboard."); // Variables. var doc = new XmlDocument(); var actionXml = Resources.TransformDashboard; doc.LoadXml(actionXml); // Add dashboard. PackageAction.RunPackageAction("Formulate", "Formulate.TransformXmlFile", doc.FirstChild); // Logging. LogHelper.Info <ApplicationStartedHandler>("Done installing Formulate dashboard."); } }); }
public object PermitAccessToFormulate() { try { // Variables. var doc = new XmlDocument(); var actionXml = Resources.GrantPermissionToSection; doc.LoadXml(actionXml); // Grant access permission. PackageAction.RunPackageAction("Formulate", "Formulate.GrantPermissionToSection", doc.FirstChild); // Indicate success. return(new { Success = true }); } catch (Exception ex) { // Error (log and indicate failure). var message = "An error occurred while attempting to set permissions."; LogHelper.Error <SetupController>(message, ex); return(new { Success = false, Reason = message }); } }
/// <summary> /// Transforms the web.config to add the Formulate /// configuration group. /// </summary> private void AddConfigurationGroup() { // Queue web.config change to add Formulate configuration. QueueInstallAction(() => { // Does the section group already exist? var config = WebConfigurationManager.OpenWebConfiguration("~"); var groupName = "formulateConfiguration"; var group = config.GetSectionGroup(groupName); var exists = group != null; // Only add the group if it doesn't exist. if (!exists) { // Logging. LogHelper.Info <ApplicationStartedHandler>("Adding Formulate config to the web.config."); // Variables. var doc = new XmlDocument(); var actionXml = Resources.TransformWebConfig; doc.LoadXml(actionXml); // Add configuration group. PackageAction.RunPackageAction("Formulate", "Formulate.TransformXmlFile", doc.FirstChild); // Logging. LogHelper.Info <ApplicationStartedHandler>("Done adding Formulate config to the web.config."); } }); }
private void _addLanguageKey() { var xd = new XmlDocument(); xd.LoadXml(@"<Action runat='install' undo='true' alias='AddLanguageFileKey' language='en' position='beginning' area='sections' key='UmbracoBookshelf' value='Umbraco Bookshelf' />"); LogHelper.Info <PackageActions>("Running Bookshelf language action."); PackageAction.RunPackageAction("UmbracoBookshelf", "AddLanguageFileKey", xd.FirstChild); }
protected void btnActivate_Click(object sender, EventArgs e) { var failures = new List <string>(); var successes = new List <string>(); var settings = new Dictionary <string, string>(); var xml = new XmlDocument(); // adds the appSettings keys for doctypes, templates, pageIds settings.Add(Settings.AppKey_DocTypes, GetStringFromCheckboxList(this.cblDocTypes)); settings.Add(Settings.AppKey_Templates, GetStringFromCheckboxList(this.cblTemplates)); settings.Add(Settings.AppKey_PageIds, this.txtPageIds.Text.Trim()); settings.Add(Settings.AppKey_Properties, this.txtProperties.Text.Trim()); settings.Add(Settings.AppKey_StripPort, this.chkStripPort.Checked.ToString()); settings.Add(Settings.AppKey_UseTemporaryRedirects, this.chkUseTemporaryRedirects.Checked.ToString()); settings.Add(Settings.AppKey_XForwardedProto, this.chkXForwardedProto.Checked.ToString()); foreach (var setting in settings) { var title = Settings.AppKeys[setting.Key]; xml.LoadXml(string.Format("<Action runat=\"install\" undo=\"true\" alias=\"HttpsRedirect_AddAppConfigKey\" key=\"{0}\" value=\"{1}\" />", setting.Key, setting.Value)); PackageAction.RunPackageAction(title, "HttpsRedirect_AddAppConfigKey", xml.FirstChild); successes.Add(title); } if (this.cbDashboardControl.Checked) { var title = "Dashboard control"; xml.LoadXml("<Action runat=\"install\" undo=\"true\" alias=\"addDashboardSection\" dashboardAlias=\"HttpsRedirectInstaller\"><section><areas><area>developer</area></areas><tab caption=\"HttpsRedirect: Settings\"><control>/umbraco/plugins/HttpsRedirect/HttpsRedirectInstaller.ascx</control></tab></section></Action>"); PackageAction.RunPackageAction(title, "addDashboardSection", xml.FirstChild); successes.Add(title); } // set the feedback controls to hidden this.Failure.Visible = this.Success.Visible = false; // display failure messages if (failures.Count > 0) { this.Failure.type = Feedback.feedbacktype.error; this.Failure.Text = "There were errors with the following settings:<br />" + string.Join("<br />", failures.ToArray()); this.Failure.Visible = true; } // display success messages if (successes.Count > 0) { this.Success.type = Feedback.feedbacktype.success; this.Success.Text = "Successfully installed the following settings: " + string.Join(", ", successes.ToArray()); this.Success.Visible = true; } }
/// <summary> /// Transforms the web.config to add the Formulate configuration group. /// </summary> private void AddConfigurationGroup() { // Queue web.config change to add Formulate configuration. QueueInstallAction(() => { // Does the section group already exist and contain all the expected sections? var config = WebConfigurationManager.OpenWebConfiguration("~"); var groupName = "formulateConfiguration"; var group = config.GetSectionGroup(groupName); var exists = group != null; var sectionKeys = (group?.Sections?.Keys?.Cast <string>()?.ToArray()).MakeSafe(); var sectionsSet = new HashSet <string>(sectionKeys); var expectedSections = new[] { "buttons", "emailWhitelist", "email", "fieldCategories", "persistence", "submissions", "templates" }; var containsAllSections = expectedSections.All(x => sectionsSet.Contains(x)); // Only add the group if it doesn't exist or doesn't contain all the expected sections. if (!exists || !containsAllSections) { // Logging. LogHelper.Info <ApplicationStartedHandler>("Adding Formulate config to the web.config."); // Variables. var doc = new XmlDocument(); var actionXml = Resources.TransformWebConfig; doc.LoadXml(actionXml); // Add configuration group. PackageAction.RunPackageAction("Formulate", "Formulate.TransformXmlFile", doc.FirstChild); // Logging. LogHelper.Info <ApplicationStartedHandler>("Done adding Formulate config to the web.config."); } }); }
/// <summary> /// Installs the action. /// </summary> /// <param name="packageAlias">The package alias.</param> /// <param name="node">The node.</param> /// <param name="result">The result.</param> private static void InstallAction(string packageAlias, XmlNode node, List <PackageActionResult> result) { try { PackageAction.RunPackageAction("Packageactiontester", packageAlias, node); result.Add(new PackageActionResult { Alias = packageAlias, Result = "Installed" }); } catch (Exception ex) { result.Add(new PackageActionResult { Alias = packageAlias, Result = string.Format("Error installing: {0}", ex) }); } }
private void _addDashboard() { var xd = new XmlDocument(); xd.LoadXml(@"<Action runat='install' alias='addDashboardSection' dashboardAlias='UmbracoBookshelfSection'> <section alias='UmbracoBookshelfSection'> <areas> <area>UmbracoBookshelf</area> </areas> <tab caption='Library'> <control>/app_plugins/umbracobookshelf/backoffice/dashboards/library.html</control> </tab> </section> </Action>" ); LogHelper.Info <PackageActions>("Running Bookshelf dashboard action."); PackageAction.RunPackageAction("UmbracoBookshelf", "addDashboardSection", xd.FirstChild); }