Commit | Line | Data |
---|---|---|
11cbb815 PD |
1 | # The software in this package is distributed under the GNU General |
2 | # Public License version 2 (with a special exception described below). | |
3 | # | |
4 | # A copy of GNU General Public License (GPL) is included in this distribution, | |
5 | # in the file COPYING.GPL. | |
6 | # | |
7 | # As a special exception, if other files instantiate templates or use macros | |
8 | # or inline functions from this file, or you compile this file and link it | |
9 | # with other works to produce a work based on this file, this file | |
10 | # does not by itself cause the resulting work to be covered | |
11 | # by the GNU General Public License. | |
12 | # | |
13 | # However the source code for this file must still be made available | |
14 | # in accordance with section (3) of the GNU General Public License. | |
15 | # | |
16 | # This exception does not invalidate any other reasons why a work based | |
17 | # on this file might be covered by the GNU General Public License. | |
18 | # | |
19 | # Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com> | |
20 | ||
b7e04a3e CH |
21 | """ |
22 | .. note:: DEPRECATED! Please do not extend this or add new uses of this module, | |
23 | use :py:mod:`pyi2ncommon.arnied_api` or :py:mod:`pyi2ncommon.cnfvar` | |
24 | instead! | |
25 | """ | |
26 | ||
f49f6323 PD |
27 | from .build_cnfvar import BuildCnfVar |
28 | """Class to create user cnfvar objects on the fly""" | |
29 | ||
30 | ||
31 | class BuildUser(BuildCnfVar): | |
32 | ||
33 | def __init__(self, data='', instance=0, line_no=1): | |
34 | BuildCnfVar.__init__(self, 'USER', instance, data, line_no) | |
35 | ||
36 | # the bare defaults the UI adds upon | |
37 | # creation of new groups | |
38 | defaults = { | |
39 | 'USER_DISABLED': '0', | |
40 | 'USER_FULLNAME': '', | |
41 | 'USER_GROUPWARE_FOLDER_CALENDAR': 'INBOX/Calendar', | |
42 | 'USER_GROUPWARE_FOLDER_CONTACTS': 'INBOX/Contacts', | |
43 | 'USER_GROUPWARE_FOLDER_DRAFTS': 'INBOX/Drafts', | |
44 | 'USER_GROUPWARE_FOLDER_NOTES': 'INBOX/Notes', | |
45 | 'USER_GROUPWARE_FOLDER_OUTBOX': 'INBOX/Sent Items', | |
46 | 'USER_GROUPWARE_FOLDER_TASKS': 'INBOX/Tasks', | |
47 | 'USER_GROUPWARE_FOLDER_TRASH': 'INBOX/Deleted Items', | |
48 | # always a member of the 'Alle' group | |
49 | 'USER_GROUP_MEMBER_REF': '2', | |
50 | 'USER_LOCALE': '', | |
51 | 'USER_PASSWORD': 'test1234', | |
52 | 'USER_TRASH_DELETEDAYS': '30', | |
53 | 'USER_WEBMAIL_MESSAGES_PER_PAGE': '25', | |
54 | 'USER_WEBMAIL_SIGNATURE': '', | |
55 | } | |
56 | ||
57 | self.add_defaults(defaults) | |
58 | ||
59 | def disabled(self, disabled='1'): | |
60 | self.update_cnf('USER_DISABLED', 0, disabled) | |
61 | return self | |
62 | ||
63 | def fullname(self, fullname): | |
64 | self.update_cnf('USER_FULLNAME', 0, fullname) | |
65 | return self | |
66 | ||
67 | def password(self, password): | |
68 | self.update_cnf('USER_PASSWORD', 0, password) | |
69 | return self | |
70 | ||
71 | def normal_email(self): | |
72 | self.update_cnf('USER_EMAIL_FORWARD_ENABLE', 0, 'NONE') | |
73 | return self | |
74 | ||
75 | def forward_email(self, email): | |
76 | self.update_cnf('USER_EMAIL_FORWARD_ENABLE', 0, 'FORWARD') | |
77 | ||
78 | addr = self.update_cnf('USER_EMAIL_FORWARD_ADDRESS', 0, '') | |
79 | self.update_cnf('USER_EMAIL_FORWARD_ADDRESS_ADDR', 0, email, addr) | |
80 | return self | |
81 | ||
82 | def copy_email(self, email): | |
83 | self.update_cnf('USER_EMAIL_FORWARD_ENABLE', 0, 'COPY') | |
84 | ||
85 | addr = self.update_cnf('USER_EMAIL_FORWARD_ADDRESS', 0, '') | |
86 | self.update_cnf('USER_EMAIL_FORWARD_ADDRESS_ADDR', 0, email, addr) | |
87 | return self | |
88 | ||
89 | def add_group_member_ref(self, group_ref): | |
90 | self.add_cnf('USER_GROUP_MEMBER_REF', -1, group_ref) | |
91 | return self |