diff --git a/dump_webapp_signatures/dump_webapp_signatures.py b/dump_webapp_signatures/dump_webapp_signatures.py deleted file mode 100644 index 85d6a77..0000000 --- a/dump_webapp_signatures/dump_webapp_signatures.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -import kopano -from MAPI.Util import * - -try: - import json -except ImportError: - import simplejson as json - - -def opt_args(): - parser = kopano.parser('skpcf') - parser.add_option("--user", dest="user", action="store", help="Dump signatures for user") - return parser.parse_args() - - -def main(): - options, args = opt_args() - if not options.user: - print 'Please use:\n %s --user ' % (sys.argv[0]) - else: - user = kopano.Server(options=options).user(options.user) - try: - settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value) - except Exception as e: - print 'Could not load WebApp settings for user %s (Error: %s)' % (user.name, repr(e)) - else: - if len(settings['settings']['zarafa']['v1']['contexts']['mail']): - if 'signatures' in settings['settings']['zarafa']['v1']['contexts']['mail']: - for item in settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all']: - name = settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][item]['name'] - filename = '%s-%s-%s.html' % (user.name, name.replace(' ', '-'), item) - with open(filename, 'w') as outfile: - print 'Dumping: \'%s\' to \'%s\' ' % (name, filename) - outfile.write(settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][item]['content'].encode('utf-8')) - -if __name__ == '__main__': - main() diff --git a/dump_webapp_signatures/readme.md b/dump_webapp_signatures/readme.md deleted file mode 100644 index 41606f2..0000000 --- a/dump_webapp_signatures/readme.md +++ /dev/null @@ -1,12 +0,0 @@ - - -dump_webapp_signatures.py -========================= -Dumps all the signatures in a users Webapp to seperate files, meant as companion to the script setdefaultsignature.py as delivered with Webapp (see /usr/share/doc/kopano-webapp/scripts/signatures/ on your Webapp server.) -The files will be written in the current directory. - -#### Usage: -``` -python dump_webapp_signatures.py --user user -``` - diff --git a/set_webapp_default_signature/readme.md b/set_webapp_default_signature/readme.md deleted file mode 100644 index c58636f..0000000 --- a/set_webapp_default_signature/readme.md +++ /dev/null @@ -1,25 +0,0 @@ - - -# set_webapp_default_signature.py - -Add and set a Default signature in Webapp for user(s), will overwrite any other default. -Please use a signature as dumped with dump_webapp_signatures.py - -## Examples - -### Set signature of a local user on the local server -``` -./set_webapp_default_signature.py -u user1 -f user2-signature.sig -``` - -### Set signature multiple local users on the local server -``` -./set_webapp_default_signature.py -u user1 -u user3 -f user2-signature.sig -``` - -### Set signature for all local users on the local server -``` -./set_webapp_default_signature.py -a -f user2-signature.sig -``` - - diff --git a/set_webapp_default_signature/set_webapp_default_signature.py b/set_webapp_default_signature/set_webapp_default_signature.py deleted file mode 100644 index 6278219..0000000 --- a/set_webapp_default_signature/set_webapp_default_signature.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 -""" -Set A Default WebApp Signature. -""" -import json -import kopano -from MAPI.Tags import * - - -def read_settings(user): - try: - mapisettings = user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value - settings = json.loads(mapisettings) - except Exception as e: - print '%s: Has no or no valid WebApp settings creating empty config tree' % user.name - settings = json.loads( - '{"settings": {"zarafa": {"v1": {"contexts": {"mail": {}}}}}}') - return settings - - -def write_settings(user, webappsettings): - try: - user.store.create_prop(PR_EC_WEBACCESS_SETTINGS_JSON, webappsettings) - except Exception as e: - print '%s: Error Writing WebApp settings for user: %s' % (e, user.name) - - -def main(options): - with open(options.file, 'r') as sigfile: - signaturehtml = sigfile.read() - signatureid = '1' - signaturename = options.file.replace('template', 'default').replace('-', ' ').replace('.html', '').title().split('/')[-1].replace(' Nl', ' NL').replace( - ' De', ' DE') - signaturecontent = dict( - {u'name': signaturename, u'content': signaturehtml, u'isHTML': True}) - runusers = [] - if options.allusers: - for ruser in server.users(remote=False): - runusers.append(ruser.name) - else: - runusers = options.users - - for username in runusers: - try: - user = server.user(username) - webappsettings = read_settings(user) - except Exception as e: - print e - continue - - if not len(webappsettings['settings']['zarafa']['v1']['contexts']['mail']): - print "%s: Adding config tree." % user.name - webappsettings['settings']['zarafa'][ - 'v1']['contexts']['mail'] = dict({}) - if 'signatures' not in list(webappsettings['settings']['zarafa']['v1']['contexts']['mail']): - print "%s: Adding Signature settings to config tree." % user.name - webappsettings['settings']['zarafa']['v1'][ - 'contexts']['mail']['signatures'] = dict({}) - if 'all' not in list(webappsettings['settings']['zarafa']['v1']['contexts']['mail']['signatures']): - print "%s: Empty Signature settings detected." % user.name - webappsettings['settings']['zarafa']['v1']['contexts'][ - 'mail']['signatures'] = dict({'all': dict({})}) - print '%s: Adding/Replacing Default Signature with %s' % (user.name, signaturename) - webappsettings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][ - signatureid] = signaturecontent - webappsettings['settings']['zarafa']['v1']['contexts'][ - 'mail']['signatures']['new_message'] = signatureid - webappsettings['settings']['zarafa']['v1']['contexts']['mail']['signatures'][ - 'replyforward_message'] = signatureid - write_settings(user, json.dumps(webappsettings)) - - -if __name__ == '__main__': - parser = kopano.parser('uUPckpsC') # select common cmd-line options - parser.add_option('-a', dest='allusers', action='store_true', - default=None, help='run program for all local users') - parser.add_option('-f', dest='file', action='store', - default=None, help='signature filename') - options, args = parser.parse_args() - server = kopano.Server(options=options) - if (options.users or options.allusers) and options.file: - main(options) diff --git a/webapp_settings/readme.md b/webapp_settings/readme.md deleted file mode 100644 index 71e4bd1..0000000 --- a/webapp_settings/readme.md +++ /dev/null @@ -1,19 +0,0 @@ - -webapp_settings.py -================== - -#### Usage: - - -###### Backup - -```python -python webapp_settings.py --user user --backup -``` - - -###### Restore - -```python -python webapp_settings.py --user user --restore -``` diff --git a/webapp_settings/webapp_settings.py b/webapp_settings/webapp_settings.py deleted file mode 100644 index 079ee44..0000000 --- a/webapp_settings/webapp_settings.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -#encoding: utf-8 - -from MAPI import * -from MAPI.Util import * -import sys -try: - import kopano -except ImportError: - import zarafa as kopano -try: - import json -except ImportError: - import simplejson as json - -def opt_args(): - parser = kopano.parser('skpcfm') - parser.add_option("--user", dest="user", action="store", help="Run script for user") - parser.add_option("--backup", dest="backup", action="store_true", help="Backup webapp setting ") - parser.add_option("--restore", dest="restore", action="store_true", help="Restore webapp settings") - parser.add_option("--remove", dest="remove", action="store_true", help="Remove webapp settings") - - return parser.parse_args() - - -def main(): - options, args = opt_args() - - if not options.user or (not options.backup and not options.restore and not options.remove): - print 'Please use:\n %s --user (--backup or --restore) ' % (sys.argv[0]) - sys.exit() - - user = kopano.Server(options).user(options.user) - if options.backup: - webapp = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value) - f = open('%s.json' % user.name,'w') - - f.write(json.dumps(webapp, sort_keys=True, - indent=4, separators=(',', ': '))) - f.close() - if options.restore: - with open('%s.json' % user.name) as data_file: - data = json.load(data_file) - - print data - user.store.create_prop(PR_EC_WEBACCESS_SETTINGS_JSON, json.dumps(data)) - - if options.remove: - user.store.delete(user.store.prop('PR_EC_WEBACCESS_SETTINGS_JSON')) - -if __name__ == "__main__": - main() diff --git a/webapp_switch_locale/readme.md b/webapp_switch_locale/readme.md deleted file mode 100644 index 6bba6f0..0000000 --- a/webapp_switch_locale/readme.md +++ /dev/null @@ -1,17 +0,0 @@ - -webapp_switch_locale.py -========================= -List or change the locale currently set in the user's WebApp settings. - -#### Usage: -###### List locale -``` -python switchlocale.py --user user1 -Original locale: nl_NL.UTF-8 -``` -###### Change locale -``` -python switchlocale.py --user user1 --locale de_DE.UTF-8 -Original locale: nl_NL.UTF-8 -Setting locale to: de_DE.UTF-8 -``` diff --git a/webapp_switch_locale/webapp_switch_locale.py b/webapp_switch_locale/webapp_switch_locale.py deleted file mode 100644 index d3ad1ba..0000000 --- a/webapp_switch_locale/webapp_switch_locale.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -import json -import kopano -from MAPI.Util import * -import sys - - -def opt_args(): - parser = kopano.parser('skpcfm') - parser.add_option("--user", dest="user", action="store", help="Run script for user") - parser.add_option("--locale", dest="locale", action="store", help="Set new locale") - return parser.parse_args() - - -def main(): - options, args = opt_args() - - if not options.user: - print 'Please use:\n %s --user [--locale]' % (sys.argv[0]) - sys.exit() - - user = kopano.Server(options).user(options.user) - settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value) - current = settings['settings']['zarafa']['v1']['main']['language'] - print 'Original locale: %s' % current - - if options.locale: - print 'Setting locale to: %s' % options.locale - settings['settings']['zarafa']['v1']['main']['language'] = options.locale - user.store.create_prop(PR_EC_WEBACCESS_SETTINGS_JSON, json.dumps(settings)) - - -if __name__ == "__main__": - main()