<?xml version="1.0"?>
<configure xmlns="http://schooltool.org/securitypolicy"
           xmlns:zope="http://namespaces.zope.org/zope">

  <setting
      key="everyone_can_view_person_list"
      text="The list of people with accounts in the system is visible to the general public."
      alt_text="The list of people with accounts in the system is visible only to school administration."
      default="False" />

  <setting
      key="persons_can_set_their_preferences"
      text="Users can make their own calendars public."
      alt_text="Users cannot make their own calendars public."
      default="True" />

  <setting
      key="persons_can_change_their_passwords"
      text="Users can change their own passwords."
      alt_text="Only site managers and clerks can change passwords."
      default="True" />

  <crowd
      name="person_list_viewers"
      factory=".person.PersonListViewersCrowd" />

  <crowd
      name="person_prefs_editors"
      factory=".preference.PersonPreferencesEditorsCrowd" />

  <crowd
      name="person_password_writers"
      factory=".person.PasswordWriterCrowd" />

  <allow
      interface="schooltool.person.interfaces.IPersonContainer"
      crowds="administrators managers clerks person_list_viewers"
      permission="schooltool.view" />
  <allow
      interface="schooltool.person.interfaces.IPersonContainer"
      crowds="managers clerks"
      permission="schooltool.edit" />

  <allow
      interface="schooltool.person.interfaces.IPerson"
      crowds="administrators managers clerks owner"
      permission="schooltool.view" />
  <allow
      interface="schooltool.person.interfaces.IPerson"
      crowds="managers clerks"
      permission="schooltool.edit" />
  <allow
      interface="schooltool.person.interfaces.IPerson"
      crowds="owner"
      permission="schooltool.editCalendarOverlays" />

  <allow
      interface="schooltool.person.interfaces.IPersonPreferences"
      crowds="managers clerks owner"
      permission="schooltool.view" /> <!-- XXX -->
  <allow
      interface="schooltool.person.interfaces.IPersonPreferences"
      crowds="managers person_prefs_editors"
      permission="schooltool.edit" />

  <allow
      interface="schooltool.person.interfaces.IPasswordWriter"
      crowds="person_password_writers"
      permission="schooltool.edit" />

  <describe_group name="schooltool.person" title="Users" />

  <describe_action
     group="schooltool.person" name="list" title="List/Search"
     order="10"
     interface="schooltool.person.interfaces.IPersonContainer"
     permission="schooltool.view"
  />

  <describe_action
     group="schooltool.person" name="create_delete" title="Create/Delete"
     order="20"
     interface="schooltool.person.interfaces.IPersonContainer"
     permission="schooltool.edit"
  />

  <describe_action
     group="schooltool.person" name="view" title="View"
     order="30"
     interface="schooltool.person.interfaces.IPerson"
     permission="schooltool.view"
  />

  <describe_action
     group="schooltool.person" name="modify" title="Modify"
     order="40"
     interface="schooltool.person.interfaces.IPerson"
     permission="schooltool.edit"
  />

  <describe_action
     group="schooltool.person" name="change_password" title="Change password"
     order="41"
     interface="schooltool.person.interfaces.IPasswordWriter"
     permission="schooltool.edit"
  />

  <describe_action
     group="schooltool.person" name="view_prefs" title="View preferences"
     order="50"
     interface="schooltool.person.interfaces.IPersonPreferences"
     permission="schooltool.view"
  />

  <describe_action
     group="schooltool.person" name="edit_prefs" title="Change preferences"
     order="51"
     interface="schooltool.person.interfaces.IPersonPreferences"
     permission="schooltool.edit"
  />

  <describe_action
     group="schooltool.person" name="view_calendar"
     title="View calendar"
     order="60"
     interface="schooltool.app.interfaces.ISchoolToolCalendar"
     permission="schooltool.view"
  />

  <describe_action
     group="schooltool.person" name="change_calendar"
     title="Change calendar"
     order="70"
     interface="schooltool.app.interfaces.ISchoolToolCalendar"
     permission="schooltool.edit"
  />

  <describe_action
     group="schooltool.person" name="edit_overlays"
     title="Manage visible calendars"
     description="Change the list of calendars overlayed on the user's calendar"
     order="80"
     interface="schooltool.person.interfaces.IPerson"
     permission="schooltool.editCalendarOverlays"
  />

  <describe_crowd
      group="schooltool.person"
      crowd="owner"
      title="User"
      description="The user himself."
      />

  <!-- Parent crowds -->

  <zope:adapter
      factory=".person.PersonCalendarCrowd"
      provides="schooltool.app.interfaces.ICalendarParentCrowd"
      name="schooltool.view" />

  <switch_description
     group="schooltool.person"
     crowd_factory="schooltool.app.security.CalendarViewersCrowd"
     use_crowd_factory=".person.PersonCalendarCrowd"
  />

  <describe_crowd
      group="schooltool.person"
      crowd_factory=".person.PublicCalendarCrowd"
      title="Calendar is public"
      description="Everybody, if the calendar is made public in user preferences."
      />

</configure>
