<?xml version="1.0"?>
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:security="http://schooltool.org/securitypolicy"
    xmlns:browser="http://namespaces.zope.org/browser"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    i18n_domain="schooltool.commendation">

  <!-- Declare commendation-capable components -->

  <class class="schooltool.person.person.Person">
    <implements interface=".interfaces.IHaveCommendations" />
  </class>

  <class class="schooltool.group.group.Group">
    <implements interface=".interfaces.IHaveCommendations" />
  </class>

  <class class="schooltool.course.section.Section">
    <implements interface=".interfaces.IHaveCommendations" />
  </class>

  <!-- Security -->

  <class class=".commendation.Commendations">
    <allow interface="zope.app.container.interfaces.IReadContainer" />
    <require permission="schooltool.edit"
             interface="zope.app.container.interfaces.IWriteContainer" />
  </class>

  <class class=".commendation.Commendation">
    <allow interface=".interfaces.ICommendation" />
    <require permission="schooltool.edit"
             set_schema=".interfaces.ICommendation" />
  </class>

  <security:allow
      interface="schooltool.commendation.interfaces.ICommendations"
      crowds="administration"
      permission="schooltool.view" />

  <security:allow
      interface="schooltool.commendation.interfaces.ICommendations"
      crowds="administration"
      permission="schooltool.edit" />

  <!-- Commendation Adapter -->

  <adapter
      for=".interfaces.IHaveCommendations"
      provides=".interfaces.ICommendations"
      factory=".commendation.getCommendations"
      trusted="true"
      />

  <!-- Commendation Event Subscribers -->

  <subscriber
      for=".interfaces.ICommendation
           zope.lifecycleevent.interfaces.IObjectCreatedEvent"
      handler=".commendation.cacheCommendation"
      />

  <!-- Browser UI -->

  <adapterTraverserPlugin
      for=".interfaces.IHaveCommendations"
      layer="zope.publisher.interfaces.http.IHTTPRequest"
      name="commendations"
      adapter="schooltool.commendation.interfaces.ICommendations"
      permission="zope.Public"
      />

  <browser:page
      name="details"
      for=".interfaces.ICommendation"
      class=".browser.CommendationDetails"
      template="commendation.pt"
      permission="zope.Public"
      />

  <browser:page
      name="index.html"
      for=".interfaces.ICommendations"
      class=".browser.CommendationsView"
      template="commendations.pt"
      permission="zope.Public"
      menu="schooltool_actions"
      title="View Commendations"
      />

  <browser:menuItem
      for=".interfaces.IHaveCommendations"
      menu="schooltool_actions"
      title="View Commendations"
      action="commendations"
      permission="zope.View"
      />

  <browser:page
      name="addCommendation.html"
      for=".interfaces.ICommendations"
      template="commendation_add.pt"
      class=".browser.CommendationAddView"
      permission="schooltool.edit"
      menu="schooltool_actions"
      title="Add Commendation"
      />

  <browser:menuItem
      for=".interfaces.IHaveCommendations"
      menu="schooltool_actions"
      title="Add Commendation"
      action="commendations/@@addCommendation.html"
      permission="schooltool.edit"
      />

  <browser:page
      name="commendations.html"
      for="schooltool.app.interfaces.ISchoolToolApplication"
      class=".browser.CommendationsOverview"
      template="commendations_overview.pt"
      permission="zope.Public"
      />

  <configure package="schooltool.skin">

    <browser:navigationViewlet
      name="commendations"
      for="*"
      manager="schooltool.app.browser.interfaces.IManageMenuViewletManager"
      template="templates/navigationViewlet.pt"
      class="schooltool.skin.NavigationViewlet"
      permission="schooltool.edit"
      link="@@commendations.html"
      title="All Commendations"
      order="100"
      />

  </configure>

  <!-- Translations -->
  <i18n:registerTranslations directory="locales" />

</configure>
