kopano-search-upgrade-findroots.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. from MAPI.Util import *
  3. import kopano
  4. """
  5. as of Kopano-Core 8.2, PR_STORE_SUPPORT_MASK has STORE_SEARCH_OK enabled
  6. for every store. this means that this script needs to run at upgrade time,
  7. to create the findroots and ACLS so that cross-store searches will actually
  8. work.
  9. """
  10. FINDROOT_RIGHTS = ['folder_visible', 'read_items', 'create_subfolders', 'edit_own', 'delete_own']
  11. def main():
  12. for store in kopano.stores():
  13. findroot = store.root.get_folder('FINDER_ROOT')
  14. if not findroot:
  15. print 'creating FINDER_ROOT for store %s' % store.guid
  16. # create findroot
  17. findroot = store.root.folder('FINDER_ROOT', create=True)
  18. # set PR_FINDER_ENTRYID # XXX pyko: store.findroot = ..
  19. entryid = HrGetOneProp(findroot.mapiobj, PR_ENTRYID)
  20. store.mapiobj.SetProps([SPropValue(PR_FINDER_ENTRYID, entryid.Value)])
  21. store.mapiobj.SaveChanges(0)
  22. # add findroot ACL
  23. findroot.permission(kopano.Group('Everyone'), create=True).rights = FINDROOT_RIGHTS
  24. # we don't need to update PR_STORE_SUPPORT_MASK as it is hardcoded
  25. # whether it includes STORE_SEARCH_OK..
  26. if __name__ == '__main__':
  27. main()