add webappsetting and renamed remove_recipients

This commit is contained in:
Robin van Genderen 2016-07-28 15:01:35 +02:00
parent 7aaed68ad6
commit 976fbac1dd
3 changed files with 71 additions and 6 deletions

View File

@ -1,4 +1,4 @@
remove-recipients.py
remove_recipients.py
====================
Remove recipients in webapp
@ -8,19 +8,19 @@ Remove recipients in webapp
###### List recipients
```python
python remove-recipients.py --user <user> --list
python remove_recipients.py --user <user> --list
```
###### Remove recipient
Remove options is searching in display_name, smtp_address or email_address.
```python
python remove-recipients.py --user <user> --remove <recipient name>
python remove_recipients.py --user <user> --remove <recipient name>
```
###### Clear history
```python
python remove-recipients.py --user <user> --remove-all
python remove_recipients.py --user <user> --remove-all
```
#### Example
@ -28,5 +28,25 @@ python remove-recipients.py --user <user> --remove-all
Remove all recipients that have example.com in there display_name, smtp_address or email_address
```python
python remove-recipients.py --user user --remove example.com
python remove_recipients.py --user user --remove example.com
```
webapp_settings.py
==================
#### Usage:
###### Backup
```python
python webapp_settings.py --user user --backup
```
###### Restore
```python
python webapp_settings.py --user user --restore
```

45
webapp_settings.py Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env python
# encoding: utf-8
from MAPI import *
from MAPI.Util import *
import sys
import 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")
return parser.parse_args()
def main():
options, args = opt_args()
if not options.user or (not options.backup and not options.restore):
print 'Please use:\n %s --user <username> (--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.prop(PR_EC_WEBACCESS_SETTINGS_JSON).set_value(json.dumps(data))
if __name__ == "__main__":
main()