示例#1
0
    /// <summary>
    /// Creates versioned css stylesheet. Called when the "Create versioned object" button is pressed.
    /// </summary>
    private bool CreateVersionedObject()
    {
        // Create new css stylesheet object
        CssStylesheetInfo newStylesheet = new CssStylesheetInfo();

        // Check if object versioning of stylesheet objects is allowed on current site
        if (ObjectVersionManager.AllowObjectVersioning(newStylesheet, CMSContext.CurrentSiteName))
        {
            // Set the properties
            newStylesheet.StylesheetDisplayName = "My new versioned stylesheet";
            newStylesheet.StylesheetName        = "MyNewVersionedStylesheet";
            newStylesheet.StylesheetText        = "Some versioned CSS code";

            // Save the css stylesheet
            CssStylesheetInfoProvider.SetCssStylesheetInfo(newStylesheet);

            // Add css stylesheet to site
            int stylesheetId = newStylesheet.StylesheetID;
            int siteId       = CMSContext.CurrentSiteID;

            CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(stylesheetId, siteId);

            return(true);
        }

        return(false);
    }
示例#2
0
    /// <summary>
    /// Creates new version of the object. Called when the "Ensure version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool EnsureVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Check if object versioning of stylesheet objects is allowed on current site
            if (ObjectVersionManager.AllowObjectVersioning(stylesheet, CMSContext.CurrentSiteName))
            {
                // Ensure version
                ObjectVersionManager.EnsureVersion(stylesheet, false);

                return(true);
            }
        }

        return(false);
    }
示例#3
0
    /// <summary>
    /// Creates new version of the object. Called when the "Create version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool CreateVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo newStylesheetVersion = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (newStylesheetVersion != null)
        {
            // Check if object versioning of stylesheet objects is allowed on current site
            if (ObjectVersionManager.AllowObjectVersioning(newStylesheetVersion, CMSContext.CurrentSiteName))
            {
                // Update the properties
                newStylesheetVersion.StylesheetDisplayName = newStylesheetVersion.StylesheetDisplayName.ToLower();

                // Create new version
                ObjectVersionManager.CreateVersion(newStylesheetVersion, true);

                return(true);
            }
        }

        return(false);
    }
示例#4
0
    protected void EditForm_OnBeforeRedirect(object sender, EventArgs e)
    {
        if (editForm.IsInsertMode)
        {
            WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(CurrentWorkflow);

            // To prevent from creating multiple versions - turn versioning back on
            CurrentWorkflow.Generalized.SupportsVersioning = true;
            // Create one version manually
            if (LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.ObjectVersioning) && ObjectVersionManager.AllowObjectVersioning(CurrentWorkflow))
            {
                ObjectVersionManager.CreateVersion(CurrentWorkflow, CMSActionContext.CurrentUser.UserID);
            }
        }
    }