<?xml version="1.0"?>
<dc-workflow workflow_id="userprofile_workflow"
             title="Dexterity Membrane Workflow"
             state_variable="review_state"
             initial_state="pending">

  <permission>View</permission>
  <permission>Access contents information</permission>
  <permission>Modify portal content</permission>
  <permission>Change portal events</permission>


  <state state_id="pending" title="Pending">
   <exit-transition transition_id="approve" />
   <exit-transition transition_id="decline" />
   <permission-map name="View" acquired="False">
    <permission-role>Reader</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Access contents information" acquired="False">
    <permission-role>Reader</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Modify portal content" acquired="False">
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Change portal events" acquired="False">
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
  </state>

  <state state_id="enabled" title="Enabled">
   <exit-transition transition_id="disable" />
   <permission-map name="View" acquired="False">
    <permission-role>Authenticated</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Access contents information" acquired="False">
    <permission-role>Authenticated</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Modify portal content" acquired="False">
    <permission-role>Owner</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Change portal events" acquired="False">
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
  </state>

  <state state_id="disabled" title="Disabled">
   <exit-transition transition_id="enable" />
   <permission-map name="View" acquired="False">
    <permission-role>Reader</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Access contents information" acquired="False">
    <permission-role>Reader</permission-role>
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Modify portal content" acquired="False">
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
   <permission-map name="Change portal events" acquired="False">
    <permission-role>Manager</permission-role>
    <permission-role>Site Administrator</permission-role>
   </permission-map>
  </state>


  <transition transition_id="approve" new_state="enabled"
               title="Approve this member"
               trigger="USER"
               before_script="" after_script="">
   <action url="%(content_url)s/content_status_modify?workflow_action=approve"
           category="workflow">Approve This Member</action>
   <guard>
    <guard-permission>Add portal member</guard-permission>
   </guard>
  </transition>

  <transition transition_id="decline" new_state="disabled"
               title="Decline this member"
               trigger="USER"
               before_script="" after_script="">
   <action url="%(content_url)s/content_status_modify?workflow_action=decline"
           category="workflow">Decline This Member</action>
   <guard>
    <guard-permission>Add portal member</guard-permission>
   </guard>
  </transition>

  <transition transition_id="disable" new_state="disabled"
              title="Disable this member"
              trigger="USER"
              before_script="" after_script="">
   <action url="%(content_url)s/content_status_modify?workflow_action=disable"
           category="workflow">Disable This Member</action>
   <guard>
    <guard-permission>Add portal member</guard-permission>
   </guard>
  </transition>

  <transition transition_id="enable" new_state="enabled"
              title="Enable this member"
              trigger="USER"
              before_script="" after_script="">
   <action url="%(content_url)s/content_status_modify?workflow_action=enable"
           category="workflow">Enable This Member</action>
   <guard>
    <guard-permission>Add portal member</guard-permission>
   </guard>
  </transition>


  <variable variable_id="action" for_catalog="False"
            for_status="True" update_always="True">
   <default>
    <expression>transition/getId|nothing</expression>
   </default>
   <guard>
   </guard>
  </variable>

  <variable variable_id="actor" for_catalog="False"
           for_status="True" update_always="True">
   <default>
    <expression>user/getId</expression>
   </default>
   <guard>
   </guard>
  </variable>

  <variable variable_id="comments" for_catalog="False"
            for_status="True" update_always="True">
   <default>
    <expression>python:state_change.kwargs.get('comment', '')</expression>
   </default>
   <guard>
   </guard>
  </variable>

  <variable variable_id="review_history" for_catalog="False"
            for_status="False" update_always="False">
   <default>
    <expression>state_change/getHistory</expression>
   </default>
   <guard>
    <guard-permission>Request review</guard-permission>
    <guard-permission>Add portal member</guard-permission>
   </guard>
  </variable>

  <variable variable_id="time" for_catalog="False"
            for_status="True" update_always="True">
   <default>
    <expression>state_change/getDateTime</expression>
   </default>
   <guard>
   </guard>
  </variable>

</dc-workflow>
