Modules/SharePointDsc.WebApplication/SPWebApplication.Workflow.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function Get-SPDSCWebApplicationWorkflowConfig
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param(
        [Parameter(Mandatory = $true)]
        $WebApplication
    )
    return @{
        ExternalWorkflowParticipantsEnabled = `
            $WebApplication.ExternalWorkflowParticipantsEnabled
        UserDefinedWorkflowsEnabled = `
            $WebApplication.UserDefinedWorkflowsEnabled
        EmailToNoPermissionWorkflowParticipantsEnable = `
            $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled
    }
}

function Set-SPDSCWebApplicationWorkflowConfig
{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        $WebApplication,

        [Parameter(Mandatory = $true)]
        $Settings
    )
    if ($Settings.ContainsKey("UserDefinedWorkflowsEnabled") -eq $true)
    {
        $WebApplication.UserDefinedWorkflowsEnabled = `
            $Settings.UserDefinedWorkflowsEnabled;
    }
    if ($Settings.ContainsKey("EmailToNoPermissionWorkflowParticipantsEnable") -eq $true)
    {
        $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled = `
            $Settings.EmailToNoPermissionWorkflowParticipantsEnable;
    }
    if ($Settings.ContainsKey("ExternalWorkflowParticipantsEnabled") -eq $true)
    {
        $WebApplication.ExternalWorkflowParticipantsEnabled = `
            $Settings.ExternalWorkflowParticipantsEnabled;
    }
    $WebApplication.UpdateWorkflowConfigurationSettings();
}

function Test-SPDSCWebApplicationWorkflowConfig {
    [CmdletBinding()]
    [OutputType([System.Boolean])]
    param(
        [Parameter(Mandatory = $true)]
        $CurrentSettings,

        [Parameter(Mandatory = $true)]
        $DesiredSettings
    )

    $relPath = "..\..\Modules\SharePointDsc.Util\SharePointDsc.Util.psm1"
    Import-Module (Join-Path $PSScriptRoot $relPath -Resolve)
    $valuesTocheck = @("UserDefinedWorkflowsEnabled",
                       "EmailToNoPermissionWorkflowParticipantsEnable",
                       "ExternalWorkflowParticipantsEnabled")
    $testReturn = Test-SPDscParameterState -CurrentValues $CurrentSettings `
                                           -DesiredValues $DesiredSettings `
                                           -ValuesToCheck $valuesTocheck
    return $testReturn
}