1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * eGroupWare * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * http://www.linux-at-work.de * |
---|
6 | * Written by : Lars Kneschke [lkneschke@linux-at-work.de] * |
---|
7 | * ------------------------------------------------- * |
---|
8 | * This program is free software; you can redistribute it and/or modify it * |
---|
9 | * under the terms of the GNU General Public License as published by the * |
---|
10 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
11 | * option) any later version. * |
---|
12 | \***************************************************************************/ |
---|
13 | |
---|
14 | class uiuserdata |
---|
15 | { |
---|
16 | |
---|
17 | var $public_functions = array |
---|
18 | ( |
---|
19 | 'editUserData' => True, |
---|
20 | 'saveUserData' => True |
---|
21 | ); |
---|
22 | |
---|
23 | function uiuserdata() |
---|
24 | { |
---|
25 | $this->t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
26 | $this->boemailadmin = CreateObject('emailadmin.bo'); |
---|
27 | } |
---|
28 | |
---|
29 | function display_app_header() |
---|
30 | { |
---|
31 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
32 | echo parse_navbar(); |
---|
33 | |
---|
34 | } |
---|
35 | |
---|
36 | function editUserData($_useCache='0') |
---|
37 | { |
---|
38 | global $phpgw, $phpgw_info, $HTTP_GET_VARS; |
---|
39 | |
---|
40 | $accountID = $HTTP_GET_VARS['account_id']; |
---|
41 | $GLOBALS['account_id'] = $accountID; |
---|
42 | |
---|
43 | $this->display_app_header(); |
---|
44 | |
---|
45 | $this->translate(); |
---|
46 | |
---|
47 | $this->t->set_file(array("editUserData" => "edituserdata.tpl")); |
---|
48 | $this->t->set_block('editUserData','form','form'); |
---|
49 | $this->t->set_block('editUserData','link_row','link_row'); |
---|
50 | $this->t->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); |
---|
51 | $this->t->set_var("tr_color1",$phpgw_info["theme"]["row_on"]); |
---|
52 | $this->t->set_var("tr_color2",$phpgw_info["theme"]["row_off"]); |
---|
53 | |
---|
54 | $this->t->set_var("lang_email_config",lang("edit email settings")); |
---|
55 | $this->t->set_var("lang_emailAddress",lang("email address")); |
---|
56 | $this->t->set_var("lang_emailaccount_active",lang("email account active")); |
---|
57 | $this->t->set_var("lang_mailAlternateAddress",lang("alternate email address")); |
---|
58 | $this->t->set_var("lang_mailRoutingAddress",lang("forward email's to")); |
---|
59 | $this->t->set_var("lang_forward_also_to",lang("forward also to")); |
---|
60 | $this->t->set_var("lang_button",lang("save")); |
---|
61 | $this->t->set_var("lang_deliver_extern",lang("deliver extern")); |
---|
62 | $this->t->set_var("lang_deliver_extern",lang("deliver extern")); |
---|
63 | $this->t->set_var("lang_edit_email_settings",lang("edit email settings")); |
---|
64 | $this->t->set_var("lang_ready",lang("Done")); |
---|
65 | $this->t->set_var("link_back",$phpgw->link('/admin/accounts.php')); |
---|
66 | |
---|
67 | $linkData = array |
---|
68 | ( |
---|
69 | 'menuaction' => 'emailadmin.uiuserdata.saveUserData', |
---|
70 | 'account_id' => $accountID |
---|
71 | ); |
---|
72 | $this->t->set_var("form_action", $phpgw->link('/index.php',$linkData)); |
---|
73 | |
---|
74 | // only when we show a existing user |
---|
75 | if($userData = $this->boemailadmin->getUserData($accountID, $_useCache)) |
---|
76 | { |
---|
77 | if ($userData['mailAlternateAddress'] != '') |
---|
78 | { |
---|
79 | $options_mailAlternateAddress = "<select size=\"6\" name=\"mailAlternateAddress\">\n"; |
---|
80 | $userData_count = count($userData['mailAlternateAddress']); |
---|
81 | for ($i=0;$i < $userData_count; ++$i) |
---|
82 | { |
---|
83 | $options_mailAlternateAddress .= "<option value=\"$i\">". |
---|
84 | $userData['mailAlternateAddress'][$i]. |
---|
85 | "</option>\n"; |
---|
86 | } |
---|
87 | $options_mailAlternateAddress .= "</select>\n"; |
---|
88 | } |
---|
89 | else |
---|
90 | { |
---|
91 | $options_mailAlternateAddress = lang('no alternate email address'); |
---|
92 | } |
---|
93 | |
---|
94 | if ($userData['mailRoutingAddress'] != '') |
---|
95 | { |
---|
96 | $options_mailRoutingAddress = "<select size=\"6\" name=\"mailRoutingAddress\">\n"; |
---|
97 | $userData_count = count($userData['mailRoutingAddress']); |
---|
98 | for ($i=0;$i < $userData_count; ++$i) |
---|
99 | { |
---|
100 | $options_mailRoutingAddress .= "<option value=\"$i\">". |
---|
101 | $userData['mailRoutingAddress'][$i]. |
---|
102 | "</option>\n"; |
---|
103 | } |
---|
104 | $options_mailRoutingAddress .= "</select>\n"; |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | $options_mailRoutingAddress = lang('no forwarding email address'); |
---|
109 | } |
---|
110 | |
---|
111 | $this->t->set_var("quotaLimit",$userData["quotaLimit"]); |
---|
112 | |
---|
113 | $this->t->set_var("mailLocalAddress",$userData["mailLocalAddress"]); |
---|
114 | $this->t->set_var("mailAlternateAddress",''); |
---|
115 | $this->t->set_var("mailRoutingAddress",''); |
---|
116 | $this->t->set_var("options_mailAlternateAddress",$options_mailAlternateAddress); |
---|
117 | $this->t->set_var("options_mailRoutingAddress",$options_mailRoutingAddress); |
---|
118 | $this->t->set_var("selected_".$userData["qmailDotMode"],'selected'); |
---|
119 | $this->t->set_var("deliveryProgramPath",$userData["deliveryProgramPath"]); |
---|
120 | |
---|
121 | $this->t->set_var("uid",rawurlencode($_accountData["dn"])); |
---|
122 | if ($userData["accountStatus"] == "active") |
---|
123 | $this->t->set_var("account_checked","checked"); |
---|
124 | if ($userData["deliveryMode"] == "forwardOnly") |
---|
125 | $this->t->set_var("forwardOnly_checked","checked"); |
---|
126 | if ($_accountData["deliverExtern"] == "active") |
---|
127 | $this->t->set_var("deliver_checked","checked"); |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | $this->t->set_var("mailLocalAddress",''); |
---|
132 | $this->t->set_var("mailAlternateAddress",''); |
---|
133 | $this->t->set_var("mailRoutingAddress",''); |
---|
134 | $this->t->set_var("options_mailAlternateAddress",lang('no alternate email address')); |
---|
135 | $this->t->set_var("options_mailRoutingAddress",lang('no forwarding email address')); |
---|
136 | $this->t->set_var("account_checked",''); |
---|
137 | $this->t->set_var("forwardOnly_checked",''); |
---|
138 | } |
---|
139 | |
---|
140 | // create the menu on the left, if needed |
---|
141 | $menuClass = CreateObject('admin.uimenuclass'); |
---|
142 | $this->t->set_var('rows',$menuClass->createHTMLCode('edit_user')); |
---|
143 | |
---|
144 | $this->t->pparse("out","form"); |
---|
145 | |
---|
146 | } |
---|
147 | |
---|
148 | function saveUserData() |
---|
149 | { |
---|
150 | global $HTTP_POST_VARS, $HTTP_GET_VARS; |
---|
151 | |
---|
152 | if($HTTP_POST_VARS["accountStatus"] == "on") |
---|
153 | { |
---|
154 | $accountStatus = "active"; |
---|
155 | } |
---|
156 | if($HTTP_POST_VARS["forwardOnly"] == "on") |
---|
157 | { |
---|
158 | $deliveryMode = "forwardOnly"; |
---|
159 | } |
---|
160 | |
---|
161 | $formData = array |
---|
162 | ( |
---|
163 | 'mailLocalAddress' => $HTTP_POST_VARS["mailLocalAddress"], |
---|
164 | 'mailRoutingAddress' => $HTTP_POST_VARS["mailRoutingAddress"], |
---|
165 | 'add_mailAlternateAddress' => $HTTP_POST_VARS["mailAlternateAddressInput"], |
---|
166 | 'remove_mailAlternateAddress' => $HTTP_POST_VARS["mailAlternateAddress"], |
---|
167 | 'quotaLimit' => $HTTP_POST_VARS["quotaLimit"], |
---|
168 | 'add_mailRoutingAddress' => $HTTP_POST_VARS["mailRoutingAddressInput"], |
---|
169 | 'remove_mailRoutingAddress' => $HTTP_POST_VARS["mailRoutingAddress"], |
---|
170 | |
---|
171 | 'qmailDotMode' => $HTTP_POST_VARS["qmailDotMode"], |
---|
172 | 'deliveryProgramPath' => $HTTP_POST_VARS["deliveryProgramPath"], |
---|
173 | 'accountStatus' => $accountStatus, |
---|
174 | 'deliveryMode' => $deliveryMode |
---|
175 | ); |
---|
176 | |
---|
177 | if($HTTP_POST_VARS["add_mailAlternateAddress"]) $bo_action='add_mailAlternateAddress'; |
---|
178 | if($HTTP_POST_VARS["remove_mailAlternateAddress"]) $bo_action='remove_mailAlternateAddress'; |
---|
179 | if($HTTP_POST_VARS["add_mailRoutingAddress"]) $bo_action='add_mailRoutingAddress'; |
---|
180 | if($HTTP_POST_VARS["remove_mailRoutingAddress"]) $bo_action='remove_mailRoutingAddress'; |
---|
181 | if($HTTP_POST_VARS["save"]) $bo_action='save'; |
---|
182 | |
---|
183 | $this->boemailadmin->saveUserData($_GET['account_id'], $formData, $bo_action); |
---|
184 | |
---|
185 | if ($bo_action == 'save') |
---|
186 | { |
---|
187 | // read date fresh from ldap storage |
---|
188 | $this->editUserData(); |
---|
189 | } |
---|
190 | else |
---|
191 | { |
---|
192 | // use cached data |
---|
193 | $this->editUserData('1'); |
---|
194 | } |
---|
195 | } |
---|
196 | |
---|
197 | function translate() |
---|
198 | { |
---|
199 | global $phpgw_info; |
---|
200 | |
---|
201 | $this->t->set_var('th_bg',$phpgw_info['theme']['th_bg']); |
---|
202 | |
---|
203 | $this->t->set_var('lang_add',lang('add')); |
---|
204 | $this->t->set_var('lang_done',lang('Done')); |
---|
205 | $this->t->set_var('lang_remove',lang('remove')); |
---|
206 | $this->t->set_var('lang_remove',lang('remove')); |
---|
207 | $this->t->set_var('lang_advanced_options',lang('advanced options')); |
---|
208 | $this->t->set_var('lang_qmaildotmode',lang('qmaildotmode')); |
---|
209 | $this->t->set_var('lang_default',lang('default')); |
---|
210 | $this->t->set_var('lang_quota_settings',lang('quota settings')); |
---|
211 | $this->t->set_var('lang_qoutainmbyte',lang('qouta size in MByte')); |
---|
212 | $this->t->set_var('lang_inmbyte',lang('in MByte')); |
---|
213 | $this->t->set_var('lang_0forunlimited',lang('leave empty for no quota')); |
---|
214 | $this->t->set_var('lang_forward_only',lang('forward only')); |
---|
215 | } |
---|
216 | } |
---|
217 | ?> |
---|