<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright 2018 Anyware Services

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
<!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.8//EN" "http://www.opensymphony.com/osworkflow/workflow_2_8.dtd">
<workflow>
	<initial-actions>
		<action id="0" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_ACTION_CREATE">
			<results>
				<unconditional-result old-status=" " status=" " step="3" />
			</results>
		</action>
		<!-- Création -->
		<action id="1" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_ACTION_CREATE">
            <pre-functions>
                <function type="avalon">
                    <arg name="role">org.ametys.web.workflow.CreateContentFunction</arg>
                </function>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.EditContentFunction</arg>
                </function>
            </pre-functions>
            <results>
                <unconditional-result old-status=" " status=" " step="1" />
            </results>
            <post-functions>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.extensions.ExtensibleFunction</arg>
                    <arg name="extension-point">org.ametys.cms.workflow.extensions.PostContentEditionFunctionsExtensionPoint</arg>
                </function>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.SetCurrentStepIdAndNotifyFunction</arg>
                </function>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.CreateVersionFunction</arg>
                </function>
                <function type="avalon">
                    <arg name="role">org.ametys.plugins.joboffer.workflow.SendMailToPersonInChargeFunction</arg>
                    <arg name="subjectKey">plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_MAIL_SUBJECT_NEW_JOB_APPLICATION</arg>
                </function>
            </post-functions>
        </action>
	</initial-actions>
    
    <common-actions>
        <action id="2" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_ACTION_EDIT">
            <restrict-to>
                <conditions type="AND">
                    <condition type="avalon">
                        <arg name="role">org.ametys.cms.workflow.ContentCheckRightsCondition</arg>
                        <arg name="right">Workflow_Right_Application_Edit</arg>
                    </condition>
                    <condition type="avalon">
                        <arg name="role">org.ametys.cms.workflow.LockCondition</arg>
                    </condition>
                </conditions>
            </restrict-to>
            <pre-functions>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.EditContentFunction</arg>
                </function>
            </pre-functions>
            <results>
                <unconditional-result old-status=" " status=" " step="1"/>
            </results>
        </action>
    </common-actions>
	
	<steps>
		<step id="1" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_STATE_RECEIVED">
			<actions>
				<action id="3" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_ACTION_SHORTLIST">
                    <restrict-to>
                        <conditions type="AND">
                            <condition type="avalon">
                                <arg name="role">org.ametys.cms.workflow.ContentCheckRightsCondition</arg>
                                <arg name="right">Workflow_Right_Application_Shortlist</arg>
                            </condition>
                            <condition type="avalon">
                                <arg name="role">org.ametys.cms.workflow.LockCondition</arg>
                            </condition>
                        </conditions>
                    </restrict-to>
                    <results>
                        <unconditional-result old-status=" " status=" " step="2" />
                    </results>
                    <post-functions>
                        <function type="avalon">
                            <arg name="role">org.ametys.cms.workflow.SetCurrentStepIdAndNotifyFunction</arg>
                        </function>
                    </post-functions>
                </action>
                <action id="4" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_ACTION_DISAPPROVE">
                    <restrict-to>
                        <conditions type="AND">
                            <condition type="avalon">
                                <arg name="role">org.ametys.cms.workflow.ContentCheckRightsCondition</arg>
                                <arg name="right">Workflow_Right_Application_Disapprove</arg>
                            </condition>
                            <condition type="avalon">
                                <arg name="role">org.ametys.cms.workflow.LockCondition</arg>
                            </condition>
                        </conditions>
                    </restrict-to>
                    <results>
                        <unconditional-result old-status=" " status=" " step="3" />
                    </results>
                    <post-functions>
                        <function type="avalon">
                            <arg name="role">org.ametys.cms.workflow.SetCurrentStepIdAndNotifyFunction</arg>
                        </function>
                    </post-functions>
                </action>
			</actions>
            <post-functions>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.CommentStepFunction</arg>
                </function>
            </post-functions>
		</step>
		<step id="2" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_STATE_SHORTLISTED">
            <actions>
                <common-action id="2" />
            </actions>
            <post-functions>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.CommentStepFunction</arg>
                </function>
            </post-functions>
		</step>
		<step id="3" name="plugin.job-offer:PLUGINS_JOB_OFFER_WORKFLOW_STATE_DISAPPROVED">
            <actions>
                <common-action id="2" />
            </actions>
            <post-functions>
                <function type="avalon">
                    <arg name="role">org.ametys.cms.workflow.CommentStepFunction</arg>
                </function>
            </post-functions>
		</step>
	</steps>
</workflow>
