<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:browser="http://namespaces.zope.org/browser"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:plone="http://namespaces.plone.org/plone"
    i18n_domain="ploneintranet">

  <include package="." file="implements.zcml" />

  <include package="Products.CMFCore" file="permissions.zcml" />
  <include package="Products.CMFPlacefulWorkflow" />
  <include package="collective.workspace" />
  <include package="ploneintranet.invitations" />
  <include package="ploneintranet.theme" />
  <include package="ploneintranet.activitystream" />
  <include package="ploneintranet.microblog" />


  <!-- does NOT include Owner, in contrast with collective.workspace: Manage roster -->
  <permission
      id="ploneintranet.workspace.ManageWorkspace"
      title="ploneintranet.workspace: Manage workspace">
    <role name="Manager" />
    <role name="Site Administrator" />
    <role name="TeamManager" />
  </permission>

  <include package=".basecontent" />
  <include package=".behaviors" />
  <include package=".browser" />

  <include file="upgrades.zcml" />
  <include file="indexers.zcml" />

  <subscriber
     for="ploneintranet.workspace.workspacefolder.IWorkspaceFolder
          zope.lifecycleevent.interfaces.IObjectAddedEvent"
     handler=".subscribers.workspace_added"
     />

  <subscriber
     for="ploneintranet.workspace.workspacefolder.IWorkspaceFolder
          Products.DCWorkflow.interfaces.IAfterTransitionEvent"
     handler=".subscribers.workspace_state_changed"
     />

  <!-- Subscribe to accepted token event which is fired
       when user clicks on the link in received email-->
  <subscriber
    for="ploneintranet.invitations.events.ITokenAccepted"
    handler=".subscribers.invitation_accepted"
    />

  <!-- Subscribe to user removed event, and delete him
       from all workspaces where he is a member -->
  <subscriber
    for="Products.PluggableAuthService.interfaces.events.IPrincipalDeletedEvent"
    handler=".subscribers.user_deleted_from_site_event"
    />

  <subscriber
      for="ploneintranet.todo.content.todo.ITodo
           zope.lifecycleevent.interfaces.IObjectAddedEvent"
      handler=".subscribers.update_todo_state"
      />

  <subscriber
      for="ploneintranet.todo.content.todo.ITodo
           zope.lifecycleevent.interfaces.IObjectCreatedEvent"
      handler=".subscribers.update_todo_state"
      />

  <subscriber
      for="ploneintranet.todo.content.todo.ITodo
          zope.lifecycleevent.interfaces.IObjectModifiedEvent"
      handler=".subscribers.update_todo_state"
      />

  <subscriber
      for=".case.ICase
           Products.DCWorkflow.interfaces.IAfterTransitionEvent"
      handler=".subscribers.handle_case_workflow_state_changed"
      />

  <adapter
     for="ploneintranet.workspace.workspacefolder.IWorkspaceFolder"
     provides="collective.workspace.interfaces.IWorkspace"
     factory=".adapters.PloneIntranetWorkspace"
     />

  <adapter
      for="ploneintranet.workspace.workspacefolder.IWorkspaceFolder"
      provides="ploneintranet.userprofile.interfaces.IMemberGroup"
      factory=".adapters.PloneIntranetWorkspace"
      />

  <adapter
     factory="ploneintranet.workspace.adapters.WorkspaceLocalRoleAdapter"
     />

  <adapter
     for=".case.ICase"
     provides=".interfaces.IMetroMap"
     factory=".adapters.MetroMap"
     />

  <adapter
     for="ploneintranet.workspace.workspacecontainer.IWorkspaceContainer"
     provides=".interfaces.IMetroMap"
     factory=".adapters.MetroMap"
     />

  <!-- grouping storage -->
  <adapter
   for="ploneintranet.workspace.interfaces.IGroupingStoragable"
   provides="ploneintranet.workspace.interfaces.IGroupingStorage"
   factory=".adapters.GroupingStorage"
   />

  <subscriber
     for=" plone.app.contenttypes.interfaces.IFolder
          zope.lifecycleevent.interfaces.IObjectAddedEvent"
     handler=".subscribers.folder_added_to_workspace"
     />

  <subscriber
     for=" plone.dexterity.interfaces.IDexterityContent
          zope.lifecycleevent.interfaces.IObjectAddedEvent"
     handler=".subscribers.content_object_added_to_workspace"
     />

  <subscriber
     for=" plone.dexterity.interfaces.IDexterityContent
          zope.lifecycleevent.interfaces.IObjectModifiedEvent"
     handler=".subscribers.content_object_edited_in_workspace"
     />

  <subscriber
     for=" plone.dexterity.interfaces.IDexterityContent
          zope.lifecycleevent.interfaces.IObjectRemovedEvent"
     handler=".subscribers.content_object_removed_from_workspace"
     />

  <subscriber
     for=" plone.dexterity.interfaces.IDexterityContent
          zope.lifecycleevent.interfaces.IObjectMovedEvent"
     handler=".subscribers.content_object_moved"
     />

  <subscriber
      for=" plone.dexterity.interfaces.IDexterityFTI
      zope.lifecycleevent.IObjectModifiedEvent"
    handler=".subscribers.workspace_groupbehavior_toggled" />

  <utility
    component=".vocabularies.DivisionsVocabularyFactory"
    name="ploneintranet.workspace.vocabularies.Divisions"
    />

  <genericsetup:registerProfile
      name="default"
      title="Plone Intranet: -- [Workspace]"
      directory="profiles/default"
      description="Workspace for PloneIntranet"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      post_handler="ploneintranet.workspace.setuphandlers.post_install"
      />

  <genericsetup:registerProfile
      name="uninstall"
      title="Plone Intranet: -- [Workspace uninstall]"
      directory="profiles/uninstall"
      description="Workspace for PloneIntranet"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      post_handler="ploneintranet.workspace.uninstall.uninstall"
      />

</configure>
