<?xml version="1.0" encoding="utf-8"?>
<dc-workflow xmlns:i18n="http://xml.zope.org/namespaces/i18n"
             description="Events are published by default"
             initial_state="published"
             manager_bypass="True"
             state_variable="review_state"
             title="Event in workspace workflow"
             workflow_id="event_workflow"
             i18n:attributes="title; description"
             i18n:domain="ploneintranet"
>

  <permission>Access contents information</permission>
  <permission>Modify portal content</permission>
  <permission>Delete objects</permission>
  <permission>View</permission>

  <state state_id="published"
         title="Published"
         i18n:attributes="title"
  >
    <description i18n:translate="">Shared with my team.</description>
    <exit-transition transition_id="submit" />
    <!-- keep permission settings in sync with published state
    of ploneintranet_workflow -->
    <permission-map acquired="False"
                    name="Access contents information"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>TeamMember</permission-role>
      <permission-role>Reader</permission-role>
      <permission-role>Guest</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="Modify portal content"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>Editor</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="Delete objects"
    >
      <permission-role>Manager</permission-role>
      <!-- NOT owner! -->
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>Editor</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="View"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>TeamMember</permission-role>
      <permission-role>Reader</permission-role>
      <permission-role>Guest</permission-role>
    </permission-map>
  </state>

  <state state_id="pending"
         title="Pending review"
         i18n:attributes="title"
  >
    <description i18n:translate="">Waiting to be reviewed by central calendar maintainer</description>
    <exit-transition transition_id="accept" />
    <exit-transition transition_id="auto_accept" />
    <exit-transition transition_id="reject" />
    <exit-transition transition_id="retract" />
    <permission-map acquired="False"
                    name="Access contents information"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>TeamMember</permission-role>
      <permission-role>Reader</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="Modify portal content"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>Editor</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="Delete objects"
    >
      <permission-role>Manager</permission-role>
      <!-- NOT owner! -->
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>Editor</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="View"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>TeamMember</permission-role>
      <permission-role>Reader</permission-role>
    </permission-map>
  </state>

  <state state_id="central_calendar"
         title="Shared to a central calendar"
         i18n:attributes="title"
  >
    <description i18n:translate="">Visible in a central calendar</description>
    <exit-transition transition_id="retract" />
    <permission-map acquired="False"
                    name="Access contents information"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>TeamMember</permission-role>
      <permission-role>Reader</permission-role>
      <permission-role>Guest</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="Modify portal content"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>Editor</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="Delete objects"
    >
      <permission-role>Manager</permission-role>
      <!-- NOT owner! -->
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>Editor</permission-role>
    </permission-map>
    <permission-map acquired="False"
                    name="View"
    >
      <permission-role>Manager</permission-role>
      <permission-role>Owner</permission-role>
      <permission-role>Site Administrator</permission-role>
      <permission-role>TeamManager</permission-role>
      <permission-role>TeamMember</permission-role>
      <permission-role>Reader</permission-role>
      <permission-role>Guest</permission-role>
    </permission-map>
  </state>

  <transition after_script=""
              before_script=""
              new_state="pending"
              title="Submit to shared calendar"
              transition_id="submit"
              trigger="USER"
              i18n:attributes="title"
  >
    <description i18n:translate="">Puts your item in a review queue for acceptance to a shared calendar.</description>
    <action category="workflow"
            icon=""
            url="%(content_url)s/content_status_modify?workflow_action=submit"
            i18n:translate=""
    >Submit to shared calendar</action>
    <guard>
      <guard-permission>Request review</guard-permission>
    </guard>
  </transition>

  <transition after_script=""
              before_script=""
              new_state="central_calendar"
              title="Reviewer makes content available in central calendar"
              transition_id="accept"
              trigger="USER"
              i18n:attributes="title"
  >
    <description i18n:translate="">Accepting the item makes it visible in the central calendar.</description>
    <action category="workflow"
            icon=""
            url="%(content_url)s/content_status_modify?workflow_action=accept"
            i18n:translate=""
    >Accept to central calendar</action>
    <guard>
      <guard-expression>here/@@can-add-in-shared-calendar</guard-expression>
    </guard>
  </transition>

  <transition after_script=""
              before_script=""
              new_state="central_calendar"
              title="Content becomes automatically available if central calendar is configured this way"
              transition_id="auto_accept"
              trigger="AUTOMATIC"
              i18n:attributes="title"
  >
    <description i18n:translate="">The item automatically becomes visible in the central calendar.</description>
    <guard>
      <guard-expression>here/@@shared-calendar-auto-accepts</guard-expression>
    </guard>
  </transition>

  <transition after_script=""
              before_script=""
              new_state="published"
              title="Send back"
              transition_id="reject"
              trigger="USER"
              i18n:attributes="title"
  >
    <description i18n:translate="">Sending the item back will return the item to the original author instead of accepting it. You should preferably include a reason for why it was not accepted.</description>
    <action category="workflow"
            icon=""
            url="%(content_url)s/content_status_modify?workflow_action=reject"
            i18n:translate=""
    >Send back</action>
    <guard>
      <guard-expression>here/@@can-add-in-shared-calendar</guard-expression>
    </guard>
  </transition>

  <transition after_script=""
              before_script=""
              new_state="published"
              title="Member retracts submission"
              transition_id="retract"
              trigger="USER"
              i18n:attributes="title"
  >
    <description i18n:translate="">If you submitted the item by mistake or want to perform additional edits, this will take it back.</description>
    <action category="workflow"
            icon=""
            url="%(content_url)s/content_status_modify?workflow_action=retract"
            i18n:translate=""
    >Retract</action>
    <guard>
      <guard-permission>Request review</guard-permission>
    </guard>
  </transition>

  <variable for_catalog="False"
            for_status="True"
            update_always="True"
            variable_id="actor"
  >
    <description i18n:translate="">The ID of the user who performed the previous transition</description>
    <default>
      <expression>user/getId</expression>
    </default>
    <guard>
</guard>
  </variable>

</dc-workflow>
