1 | <?php |
---|
2 | /***********************************************************************************\ |
---|
3 | * Expresso Administração * |
---|
4 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
5 | * ----------------------------------------------------------------------------------* |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \***********************************************************************************/ |
---|
11 | |
---|
12 | class uiaccounts |
---|
13 | { |
---|
14 | var $public_functions = array |
---|
15 | ( |
---|
16 | 'list_users' => True, |
---|
17 | 'add_users' => True, |
---|
18 | 'edit_user' => True, |
---|
19 | 'view_user' => True, |
---|
20 | 'show_photo' => True, |
---|
21 | 'show_access_log' => True, |
---|
22 | 'css' => True |
---|
23 | ); |
---|
24 | |
---|
25 | var $nextmatchs; |
---|
26 | var $user; |
---|
27 | var $functions; |
---|
28 | var $current_config; |
---|
29 | var $ldap_functions; |
---|
30 | var $db_functions; |
---|
31 | |
---|
32 | function uiaccounts() |
---|
33 | { |
---|
34 | $this->user = CreateObject('expressoAdmin1_2.user'); |
---|
35 | $this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
36 | $this->functions = CreateObject('expressoAdmin1_2.functions'); |
---|
37 | $this->ldap_functions = CreateObject('expressoAdmin1_2.ldap_functions'); |
---|
38 | $this->db_functions = CreateObject('expressoAdmin1_2.db_functions'); |
---|
39 | |
---|
40 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
41 | $c->read_repository(); |
---|
42 | $this->current_config = $c->config_data; |
---|
43 | |
---|
44 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
45 | { |
---|
46 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
47 | } |
---|
48 | $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao |
---|
49 | $GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','expressoAdmin1_2'); |
---|
50 | $GLOBALS['phpgw']->js->validate_file('jscode','tabs','expressoAdmin1_2'); |
---|
51 | $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2'); |
---|
52 | } |
---|
53 | |
---|
54 | function list_users() |
---|
55 | { |
---|
56 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
57 | $tmp = $this->functions->read_acl($account_lid); |
---|
58 | $context = $tmp[0]['context']; |
---|
59 | $context_display = $tmp[0]['context_display']; |
---|
60 | |
---|
61 | // Verifica se o administrador tem acesso. |
---|
62 | if (!$this->functions->check_acl($account_lid,'list_users')) |
---|
63 | { |
---|
64 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
65 | } |
---|
66 | |
---|
67 | if(isset($_POST['query'])) |
---|
68 | { |
---|
69 | // limit query to limit characters |
---|
70 | if(eregi('^[a-z_0-9_-].+$',$_POST['query'])) |
---|
71 | { |
---|
72 | $GLOBALS['query'] = $_POST['query']; |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
77 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
78 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('User accounts'); |
---|
79 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
80 | |
---|
81 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
82 | $p->set_file(Array('accounts' => 'accounts.tpl')); |
---|
83 | $p->set_block('accounts','body'); |
---|
84 | $p->set_block('accounts','row'); |
---|
85 | $p->set_block('accounts','row_empty'); |
---|
86 | |
---|
87 | $var = Array( |
---|
88 | 'bg_color' => $GLOBALS['phpgw_info']['theme']['bg_color'], |
---|
89 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
90 | |
---|
91 | 'accounts_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'), |
---|
92 | 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), |
---|
93 | 'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.add_users'), |
---|
94 | |
---|
95 | 'create_user_disabled' => $this->functions->check_acl($account_lid,'add_users') ? '' : 'disabled', |
---|
96 | 'context' => $context, |
---|
97 | 'context_display' => $context_display, |
---|
98 | 'imapDelimiter' => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'], |
---|
99 | |
---|
100 | 'lang_create_user' => lang('Create User'), |
---|
101 | 'lang_loginid' => lang('LoginID'), |
---|
102 | 'lang_cn' => lang('Name'), |
---|
103 | 'lang_mail' => lang('E-mail'), |
---|
104 | 'lang_edit' => lang('edit'), |
---|
105 | 'lang_rename' => lang('rename'), |
---|
106 | 'lang_delete' => lang('delete'), |
---|
107 | 'lang_search' => lang('Search'), |
---|
108 | 'lang_back' => lang('back'), |
---|
109 | 'lang_context' => lang('Context') |
---|
110 | |
---|
111 | ); |
---|
112 | $p->set_var($var); |
---|
113 | |
---|
114 | // Save query |
---|
115 | $p->set_var('query', $GLOBALS['query']); |
---|
116 | |
---|
117 | //Admin make a search |
---|
118 | if ($GLOBALS['query'] != '') |
---|
119 | { |
---|
120 | $account_info = $this->functions->get_list('accounts', $GLOBALS['query'], $context); |
---|
121 | } |
---|
122 | |
---|
123 | if (!count($account_info) && $GLOBALS['query'] != '') |
---|
124 | { |
---|
125 | $p->set_var('message',lang('No matches found')); |
---|
126 | $p->parse('rows','row_empty',True); |
---|
127 | } |
---|
128 | else if (count($account_info)) |
---|
129 | { // Can edit, delete or rename users ?? |
---|
130 | if (($this->functions->check_acl($account_lid,'edit_users')) || |
---|
131 | ($this->functions->check_acl($account_lid,'change_users_password')) || |
---|
132 | ($this->functions->check_acl($account_lid,'edit_sambausers_attributes')) || |
---|
133 | ($this->functions->check_acl($account_lid,'change_users_quote'))) |
---|
134 | $can_edit = True; |
---|
135 | elseif ($this->functions->check_acl($account_lid,'view_users')) |
---|
136 | $can_view = True; |
---|
137 | if ($this->functions->check_acl($account_lid,'delete_users')) |
---|
138 | $can_delete = True; |
---|
139 | if ($this->functions->check_acl($account_lid,'rename_users')) |
---|
140 | $can_rename = True; |
---|
141 | |
---|
142 | while (list($null,$account) = each($account_info)) |
---|
143 | { |
---|
144 | $this->nextmatchs->template_alternate_row_color($p); |
---|
145 | |
---|
146 | $var = array( |
---|
147 | 'row_loginid' => $account['account_lid'], |
---|
148 | 'row_cn' => $account['account_cn'], |
---|
149 | 'row_mail' => (!$account['account_mail']?'<font color=red>Sem E-mail</font>':$account['account_mail']) |
---|
150 | ); |
---|
151 | $p->set_var($var); |
---|
152 | |
---|
153 | if ($can_edit) |
---|
154 | $p->set_var('row_edit',$this->row_action('edit','user',$account['account_id'])); |
---|
155 | elseif ($can_view) |
---|
156 | $p->set_var('row_edit',$this->row_action('view','user',$account['account_id'])); |
---|
157 | else |
---|
158 | $p->set_var('row_edit',' '); |
---|
159 | |
---|
160 | if ($can_rename) |
---|
161 | $p->set_var('row_rename',"<a href='#' onClick='javascript:rename_user(\"".$account['account_lid']."\",\"".$account['account_id']."\",\"".$context."\");'>Renomear</a>"); |
---|
162 | else |
---|
163 | $p->set_var('row_rename',' '); |
---|
164 | |
---|
165 | if ($can_delete) |
---|
166 | { |
---|
167 | $p->set_var('row_delete',"<a href='#' onClick='javascript:delete_user(\"".$account['account_lid']."\",\"".$account['account_id']."\",\"".$context."\");'>Excluir</a>"); |
---|
168 | } |
---|
169 | else |
---|
170 | $p->set_var('row_delete',' '); |
---|
171 | |
---|
172 | $p->parse('rows','row',True); |
---|
173 | } |
---|
174 | } |
---|
175 | $p->pfp('out','body'); |
---|
176 | } |
---|
177 | |
---|
178 | function add_users() |
---|
179 | { |
---|
180 | $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2'); |
---|
181 | //$GLOBALS['phpgw']->js->set_onload('get_sectors(document.forms[0].context.value);'); |
---|
182 | $GLOBALS['phpgw']->js->set_onload('get_available_groups(document.forms[0].context.value);'); |
---|
183 | $GLOBALS['phpgw']->js->set_onload('get_available_maillists(document.forms[0].context.value);'); |
---|
184 | |
---|
185 | $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
186 | $tmp = $this->functions->read_acl($manager_lid); |
---|
187 | $manager_context = $tmp[0]['context']; |
---|
188 | // Verifica se tem acesso a este modulo |
---|
189 | if (!$this->functions->check_acl($manager_lid,'add_users')) |
---|
190 | { |
---|
191 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
192 | } |
---|
193 | |
---|
194 | // Imprime nav_bar |
---|
195 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
196 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
197 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create User'); |
---|
198 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
199 | |
---|
200 | // Seta template |
---|
201 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
202 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
203 | $t->set_file(array("body" => "accounts_form.tpl")); |
---|
204 | $t->set_block('body','main'); |
---|
205 | |
---|
206 | // Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou. |
---|
207 | $sectors = $this->functions->get_organizations($manager_context); |
---|
208 | |
---|
209 | // Chama funcao para criar lista de aplicativos disponiveis. |
---|
210 | //$app_list['applications_list'] = $_POST['applications_list']; |
---|
211 | $applications_list = $this->functions->make_list_app($manager_lid, $manager_context, $app_list); |
---|
212 | |
---|
213 | // Cria combo de dominio samba |
---|
214 | if ($this->current_config['expressoAdmin_samba_support'] == 'true') |
---|
215 | { |
---|
216 | $a_sambadomains = $this->db_functions->get_sambadomains_list(); |
---|
217 | $sambadomainname_options = ''; |
---|
218 | if (count($a_sambadomains)) |
---|
219 | { |
---|
220 | foreach ($a_sambadomains as $a_sambadomain) |
---|
221 | { |
---|
222 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
223 | } |
---|
224 | } |
---|
225 | } |
---|
226 | |
---|
227 | // Valores default. |
---|
228 | $var = Array( |
---|
229 | 'row_on' => "#DDDDDD", |
---|
230 | 'row_off' => "#EEEEEE", |
---|
231 | 'color_bg1' => "#E8F0F0", |
---|
232 | 'manager_context' => $manager_context, |
---|
233 | 'type' => 'create_user', |
---|
234 | 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'), |
---|
235 | 'display_samba_suport' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', |
---|
236 | |
---|
237 | // First ABA |
---|
238 | 'display_spam_uid' => 'display:none', |
---|
239 | 'lang_general_information' => lang('General Information'), |
---|
240 | 'lang_email_config' => lang('Email Config'), |
---|
241 | 'lang_groups_permission' => lang('Groups Permission'), |
---|
242 | 'lang_lists_permission' => lang('Email Lists'), |
---|
243 | 'lang_aplication_permission' => lang('Aplication Permission'), |
---|
244 | 'lang_organizations' => lang('Organizations'), |
---|
245 | 'lang_sector' => lang('Sector'), |
---|
246 | 'lang_account_lid' => lang('Login ID'), |
---|
247 | 'lang_firstname' => lang('First Name'), |
---|
248 | 'lang_lastname' => lang('Last Name'), |
---|
249 | 'lang_password' => lang('Password'), |
---|
250 | 'lang_re-password' => lang('Re-Password'), |
---|
251 | 'lang_changepassword' => lang('Change password'), |
---|
252 | 'lang_phone' => lang('Phone'), |
---|
253 | 'lang_photo' => lang('Photo'), |
---|
254 | 'lang_account_active' => lang('Account Active'), |
---|
255 | 'lang_account_invisible' => lang('Account Invisible'), |
---|
256 | 'lang_never' => lang('never'), |
---|
257 | 'lang_back' => lang('Back'), |
---|
258 | 'lang_save' => lang('Save'), |
---|
259 | |
---|
260 | 'sectors' => $sectors, |
---|
261 | 'combo_organizations' => $sectors, |
---|
262 | 'changepassword_checked' => 'CHECKED', |
---|
263 | 'phpgwaccountstatus_checked' => 'CHECKED', |
---|
264 | 'photo_bin' => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png', |
---|
265 | 'disabled_delete_photo' => 'disabled', |
---|
266 | 'display_tr_default_password' => 'none', |
---|
267 | 'minimumSizeLogin' => $this->current_config['expressoAdmin_minimumSizeLogin'], |
---|
268 | 'defaultDomain' => $this->current_config['expressoAdmin_defaultDomain'], |
---|
269 | 'concatenateDomain' => $this->current_config['expressoAdmin_concatenateDomain'], |
---|
270 | 'ldap_context' => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']), |
---|
271 | |
---|
272 | //MAIL |
---|
273 | 'lang_activeemailaccount' => lang('Active email account'), |
---|
274 | 'lang_email' => lang('E-mail'), |
---|
275 | 'lang_aliasemail' => lang('Alias email'), |
---|
276 | 'lang_forwardingemail' => lang('Forwarding email'), |
---|
277 | 'lang_email_quota' => lang('Email quota in MB'), |
---|
278 | 'lang_onlyforwarding' => lang('Only forwarding'), |
---|
279 | 'lang_quote_message' => lang('leave empty for no quota'), |
---|
280 | 'lang_email_quota_used' => lang('Quota used in MB'), |
---|
281 | 'accountstatus_checked' => 'CHECKED', |
---|
282 | 'mailquota' => $this->current_config['expressoAdmin_defaultUserQuota'], |
---|
283 | 'changequote_disabled' => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly', |
---|
284 | 'imapDelimiter' => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'], |
---|
285 | |
---|
286 | //Third ABA |
---|
287 | 'lang_groups' => lang('Groups'), |
---|
288 | 'lang_user_groups' => 'Grupos do Usuário', |
---|
289 | 'lang_available_groups' => 'Grupos disponíveis', |
---|
290 | 'lang_listGroups' => lang('ListGroups'), |
---|
291 | 'lang_primary_group' => lang('Primary Group'), |
---|
292 | 'lang_add' => lang('Add'), |
---|
293 | 'lang_rem' => lang('Remove'), |
---|
294 | |
---|
295 | //Fourd ABA |
---|
296 | 'lang_user_mail_lists' => 'O usuário participa destas Listas de E-mail', |
---|
297 | 'lang_available_mail_lists' => 'Listas de E-mail disponíveis', |
---|
298 | |
---|
299 | //Five ABA |
---|
300 | 'apps' => $applications_list, |
---|
301 | |
---|
302 | //SAMBA ABA |
---|
303 | 'lang_samba_config' => lang('Samba Config'), |
---|
304 | 'lang_use_attrs_samba' => lang('Use samba attributes'), |
---|
305 | 'lang_sambadomain' => lang('Domain'), |
---|
306 | 'lang_sambaAcctFlags' => lang('AcctFlags'), |
---|
307 | 'lang_sambaLogonScript' => lang('Logon Script'), |
---|
308 | 'lang_sambaHomeDirectory' => lang('Home Directory'), |
---|
309 | 'lang_active_user' => lang('Samba User Active'), |
---|
310 | 'lang_desactive_user' => lang('Samba User Desactive'), |
---|
311 | 'use_attrs_samba_checked' => 'CHECKED', |
---|
312 | 'sambadomainname_options' => $sambadomainname_options, |
---|
313 | 'sambalogonscript' => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '', |
---|
314 | 'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false', |
---|
315 | ); |
---|
316 | $t->set_var($var); |
---|
317 | $t->pfp('out','main'); |
---|
318 | } |
---|
319 | |
---|
320 | function view_user() |
---|
321 | { |
---|
322 | ExecMethod('expressoAdmin1_2.uiaccounts.edit_user'); |
---|
323 | return; |
---|
324 | } |
---|
325 | |
---|
326 | function edit_user() |
---|
327 | { |
---|
328 | $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
329 | $tmp = $this->functions->read_acl($manager_account_lid); |
---|
330 | $manager_context = $tmp[0]['context']; |
---|
331 | $alert_warning = ''; |
---|
332 | |
---|
333 | // Verifica se tem acesso a este modulo |
---|
334 | $disabled = 'disabled'; |
---|
335 | $disabled_password = 'disabled'; |
---|
336 | $disabled_samba = 'disabled'; |
---|
337 | if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && |
---|
338 | (!$this->functions->check_acl($manager_account_lid,'change_users_password')) && |
---|
339 | (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) && |
---|
340 | (!$this->functions->check_acl($manager_account_lid,'view_users')) |
---|
341 | ) |
---|
342 | { |
---|
343 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
344 | } |
---|
345 | // SOMENTE ALTERAÇÃO DE SENHA |
---|
346 | if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password'))) |
---|
347 | { |
---|
348 | $disabled = 'disabled'; |
---|
349 | $disabled_password = ''; |
---|
350 | } |
---|
351 | // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA |
---|
352 | if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes'))) |
---|
353 | { |
---|
354 | $disabled = 'disabled'; |
---|
355 | $disabled_samba = ''; |
---|
356 | } |
---|
357 | // TOTAIS MENOS O SAMBA |
---|
358 | if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes'))) |
---|
359 | { |
---|
360 | $disabled = ''; |
---|
361 | $disabled_password = ''; |
---|
362 | $disabled_samba = 'disabled'; |
---|
363 | } |
---|
364 | // TOTAIS |
---|
365 | elseif ($this->functions->check_acl($manager_account_lid,'edit_users')) |
---|
366 | { |
---|
367 | $disabled = ''; |
---|
368 | $disabled_password = ''; |
---|
369 | $disabled_samba = ''; |
---|
370 | } |
---|
371 | |
---|
372 | if (!$this->functions->check_acl($manager_account_lid,'change_users_quote')) |
---|
373 | $disabled_quote = 'readonly'; |
---|
374 | |
---|
375 | // GET all infomations about the user. |
---|
376 | $user_info = $this->user->get_user_info($_GET['account_id'], $manager_context); |
---|
377 | |
---|
378 | // JavaScript |
---|
379 | $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2"); |
---|
380 | $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);"); |
---|
381 | $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);"); |
---|
382 | $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');"); |
---|
383 | |
---|
384 | // Seta header. |
---|
385 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
386 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
387 | |
---|
388 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User'); |
---|
389 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
390 | |
---|
391 | // Seta templates. |
---|
392 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
393 | $t->set_file(array("body" => "accounts_form.tpl")); |
---|
394 | $t->set_block('body','main'); |
---|
395 | |
---|
396 | // ORGANIZATIONS |
---|
397 | $orgs = $this->functions->get_organizations($manager_context, $user_info['context']); |
---|
398 | |
---|
399 | // GROUPS. |
---|
400 | if (count($user_info['groups_info']) > 0) |
---|
401 | { |
---|
402 | foreach ($user_info['groups_info'] as $group) |
---|
403 | { |
---|
404 | $array_groups[$group['gidnumber']] = $group['cn']; |
---|
405 | } |
---|
406 | natcasesort($array_groups); |
---|
407 | foreach ($array_groups as $gidnumber=>$cn) |
---|
408 | { |
---|
409 | // Grupo existe no Banco mas não no Ldap, excluimos grupo do Banco. |
---|
410 | /* |
---|
411 | if (!$this->ldap_functions->group_exist($gidnumber)) |
---|
412 | { |
---|
413 | $this->db_functions->delete_group($gidnumber); |
---|
414 | $this->db_functions->write_log("expressoAdmin deletou o grupo $gidnumber do banco, pois não existia no ldap.",'','','',''); |
---|
415 | continue; |
---|
416 | } |
---|
417 | */ |
---|
418 | |
---|
419 | // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap. |
---|
420 | if (is_null($user_info['groups_ldap'][$gidnumber])) |
---|
421 | { |
---|
422 | $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']); |
---|
423 | $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Incluido memberUid no Ldap]</option>"; |
---|
424 | |
---|
425 | if ($alert_warning == '') |
---|
426 | $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n"; |
---|
427 | $alert_warning .= "Incluido atributo memberUid do usuário no grupo $cn - $gidnumber.\\n"; |
---|
428 | } |
---|
429 | else |
---|
430 | $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>"; |
---|
431 | |
---|
432 | if ($gidnumber == $user_info['gidnumber']) |
---|
433 | { |
---|
434 | $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>"; |
---|
435 | } |
---|
436 | else |
---|
437 | { |
---|
438 | $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>"; |
---|
439 | } |
---|
440 | } |
---|
441 | |
---|
442 | // O memberUid do usuário está somente no Ldap. |
---|
443 | $groups_db = array_flip($user_info['groups']); |
---|
444 | foreach ($user_info['groups_ldap'] as $gidnumber=>$cn) |
---|
445 | { |
---|
446 | if (is_null($groups_db[$gidnumber])) |
---|
447 | { |
---|
448 | /* |
---|
449 | $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']); |
---|
450 | if ($alert_warning == '') |
---|
451 | $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n"; |
---|
452 | $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n"; |
---|
453 | */ |
---|
454 | $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Somente no LDAP]</option>"; |
---|
455 | } |
---|
456 | } |
---|
457 | } |
---|
458 | |
---|
459 | // MAILLISTS |
---|
460 | if (count($user_info['maillists_info']) > 0) |
---|
461 | { |
---|
462 | |
---|
463 | foreach ($user_info['maillists_info'] as $maillist) |
---|
464 | { |
---|
465 | $array_maillist[$maillist['uidnumber']] = $maillist['uid'] . " (" . $maillist['mail'] . ") "; |
---|
466 | } |
---|
467 | natcasesort($array_maillist); |
---|
468 | foreach ($array_maillist as $uidnumber=>$option) |
---|
469 | { |
---|
470 | $ea_select_user_maillists_options .= "<option value=" . $uidnumber . ">" . $option . "</option>"; |
---|
471 | } |
---|
472 | } |
---|
473 | |
---|
474 | // APPS. |
---|
475 | if ($disabled == 'disabled') |
---|
476 | $apps = $this->functions->make_list_app($manager_account_lid, $manager_context, $user_info['apps'], 'disabled'); |
---|
477 | else |
---|
478 | $apps = $this->functions->make_list_app($manager_account_lid, $manager_context, $user_info['apps']); |
---|
479 | |
---|
480 | //PHOTO |
---|
481 | if ($user_info['photo_exist']) |
---|
482 | { |
---|
483 | $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id']."&manager_context=$manager_context"; |
---|
484 | } |
---|
485 | else |
---|
486 | { |
---|
487 | $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png'; |
---|
488 | $disabled_delete_photo = 'disabled'; |
---|
489 | } |
---|
490 | |
---|
491 | // Cria combo de dominios do samba |
---|
492 | if ($this->current_config['expressoAdmin_samba_support'] == 'true') |
---|
493 | { |
---|
494 | $a_sambadomains = $this->db_functions->get_sambadomains_list(); |
---|
495 | $sambadomainname_options = ''; |
---|
496 | if (count($a_sambadomains)) |
---|
497 | { |
---|
498 | foreach ($a_sambadomains as $a_sambadomain) |
---|
499 | { |
---|
500 | if ($a_sambadomain['samba_domain_sid'] == $user_info['sambasid']) |
---|
501 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
502 | else |
---|
503 | $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; |
---|
504 | } |
---|
505 | } |
---|
506 | } |
---|
507 | |
---|
508 | if ($alert_warning != '') |
---|
509 | $alert_warning = "alert('". $alert_warning ."')"; |
---|
510 | |
---|
511 | $var = Array( |
---|
512 | 'uidnumber' => $_GET['account_id'], |
---|
513 | 'manager_context' => $manager_context, |
---|
514 | 'type' => 'edit_user', |
---|
515 | 'photo_exist' => $user_info['photo_exist'], |
---|
516 | 'departmentnumber' => $user_info['departmentnumber'], |
---|
517 | 'user_context' => $user_info['context'], |
---|
518 | |
---|
519 | 'row_on' => "#DDDDDD", |
---|
520 | 'row_off' => "#EEEEEE", |
---|
521 | 'color_bg1' => "#E8F0F0", |
---|
522 | 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'), |
---|
523 | 'back_url' => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users', |
---|
524 | 'display_samba_suport' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', |
---|
525 | 'disabled' => $disabled, |
---|
526 | 'disabled_password' => $disabled_password, |
---|
527 | 'disabled_samba' => $disabled_samba, |
---|
528 | 'changequote_disabled' => $disabled_quote, |
---|
529 | |
---|
530 | // First ABA |
---|
531 | 'alert_warning' => "$alert_warning", |
---|
532 | 'display_input_account_lid' => 'display:none', |
---|
533 | 'lang_general_information' => lang('General Information'), |
---|
534 | 'lang_email_config' => lang('Email Config'), |
---|
535 | 'lang_groups_permission' => lang('Groups Permission'), |
---|
536 | 'lang_lists_permission' => lang('Email Lists'), |
---|
537 | 'lang_aplication_permission' => lang('Aplication Permission'), |
---|
538 | 'lang_organizations' => lang('Organizations'), |
---|
539 | 'lang_sector' => lang('Sector'), |
---|
540 | 'lang_account_lid' => lang('Login ID'), |
---|
541 | 'lang_firstname' => lang('First Name'), |
---|
542 | 'lang_lastname' => lang('Last Name'), |
---|
543 | 'lang_password' => lang('Password'), |
---|
544 | 'lang_phone' => lang('Phone'), |
---|
545 | 'lang_photo' => lang('Photo'), |
---|
546 | 'lang_re-password' => lang('Re-Password'), |
---|
547 | 'lang_changepassword' => lang('Change password'), |
---|
548 | 'lang_account_active' => lang('Account Active'), |
---|
549 | 'lang_account_invisible' => lang('Account Invisible'), |
---|
550 | 'lang_back' => lang('Back'), |
---|
551 | 'lang_save' => lang('Save'), |
---|
552 | |
---|
553 | 'sectors' => $orgs, |
---|
554 | 'combo_organizations' => $orgs, |
---|
555 | |
---|
556 | 'uid' => $user_info['uid'], |
---|
557 | 'givenname' => $user_info['givenname'], |
---|
558 | 'mail1' => $user_info['mail'], |
---|
559 | 'sn' => $user_info['sn'], |
---|
560 | 'telephonenumber' => $user_info['telephonenumber'], |
---|
561 | 'photo_bin' => $photo_bin, |
---|
562 | 'disabled_delete_photo' => $disabled_delete_photo, |
---|
563 | |
---|
564 | 'display_tr_default_password' => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none', |
---|
565 | |
---|
566 | 'changepassword_checked' => $user_info['changepassword'] == '1' ? 'CHECKED' : '', |
---|
567 | 'phpgwaccountstatus_checked' => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '', |
---|
568 | 'phpgwaccountvisible_checked' => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '', |
---|
569 | |
---|
570 | //MAIL BORD |
---|
571 | 'disabled_quota_used' => 'disabled', |
---|
572 | 'lang_activeemailaccount' => lang('Active email account'), |
---|
573 | 'lang_email' => lang('E-mail'), |
---|
574 | 'lang_aliasemail' => lang('Alias email'), |
---|
575 | 'lang_forwardingemail' => lang('Forwarding email'), |
---|
576 | 'lang_email_quota' => lang('Email quota in MB'), |
---|
577 | 'lang_onlyforwarding' => lang('Only forwarding'), |
---|
578 | 'lang_email_quota_used' => lang('Quota used in MB'), |
---|
579 | |
---|
580 | 'accountstatus_checked' => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '', |
---|
581 | 'mail' => $user_info['mail'], |
---|
582 | 'mailalternateaddress' => $user_info['mailalternateaddress'], |
---|
583 | 'mailforwardingaddress' => $user_info['mailforwardingaddress'], |
---|
584 | 'deliverymode_checked' => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '', |
---|
585 | |
---|
586 | 'mailquota' => $user_info['mailquota'], |
---|
587 | 'mailquota_used' => $user_info['mailquota_used'], |
---|
588 | |
---|
589 | //Third ABA |
---|
590 | 'lang_groups' => lang('Groups'), |
---|
591 | 'lang_user_groups' => 'Grupos do Usuário', |
---|
592 | 'lang_available_groups' => 'Grupos disponíveis', |
---|
593 | 'lang_primary_group' => lang('Primary Group'), |
---|
594 | 'lang_add' => lang('Add'), |
---|
595 | 'lang_rem' => lang('Remove'), |
---|
596 | 'ea_select_user_groups_options' => $ea_select_user_groups_options, |
---|
597 | 'ea_combo_primary_user_group_options' => $ea_combo_primary_user_group_options, |
---|
598 | |
---|
599 | //Fourd ABA |
---|
600 | 'lang_user_mail_lists' => 'O usuário participa destas Listas de E-mail', |
---|
601 | 'lang_available_mail_lists' => 'Listas de E-mail disponíveis', |
---|
602 | 'ea_select_user_maillists_options' => $ea_select_user_maillists_options, |
---|
603 | |
---|
604 | //Five ABA |
---|
605 | 'apps' => $apps, |
---|
606 | |
---|
607 | //SAMBA ABA |
---|
608 | 'lang_samba_config' => lang('Samba Config'), |
---|
609 | 'lang_use_attrs_samba' => lang('Use samba attributes'), |
---|
610 | 'lang_sambadomain' => lang('Domain'), |
---|
611 | 'lang_sambaAcctFlags' => lang('AcctFlags'), |
---|
612 | 'lang_sambaLogonScript' => lang('Logon Script'), |
---|
613 | 'lang_sambaHomeDirectory' => lang('Home Directory'), |
---|
614 | 'lang_active_user' => lang('Samba User Active'), |
---|
615 | 'lang_desactive_user' => lang('Samba User Desactive'), |
---|
616 | |
---|
617 | 'userSamba' => $user_info['sambaUser'], |
---|
618 | 'sambadomainname_options' => $sambadomainname_options, |
---|
619 | 'use_attrs_samba_checked' => $user_info['sambaUser'] ? 'CHECKED' : '', |
---|
620 | 'active_user_selected' => $user_info['sambaaccflags'] == '[U ]' ? 'selected' : '', |
---|
621 | 'desactive_user_selected' => $user_info['sambaaccflags'] == '[DU ]' ? 'selected' : '', |
---|
622 | 'sambalogonscript' => $user_info['sambalogonscript'], |
---|
623 | 'sambahomedirectory' => $user_info['homedirectory'], |
---|
624 | 'defaultLogonScript' => $this->current_config['expressoAdmin_defaultLogonScript'], |
---|
625 | 'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false' |
---|
626 | ); |
---|
627 | $t->set_var($var); |
---|
628 | $t->pfp('out','body'); |
---|
629 | } |
---|
630 | |
---|
631 | function row_action($action,$type,$account_id) |
---|
632 | { |
---|
633 | return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( |
---|
634 | 'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type, |
---|
635 | 'account_id' => $account_id |
---|
636 | )).'"> '.lang($action).' </a>'; |
---|
637 | } |
---|
638 | |
---|
639 | function css() |
---|
640 | { |
---|
641 | $appCSS = |
---|
642 | 'th.activetab |
---|
643 | { |
---|
644 | color:#000000; |
---|
645 | background-color:#D3DCE3; |
---|
646 | border-top-width : 1px; |
---|
647 | border-top-style : solid; |
---|
648 | border-top-color : Black; |
---|
649 | border-left-width : 1px; |
---|
650 | border-left-style : solid; |
---|
651 | border-left-color : Black; |
---|
652 | border-right-width : 1px; |
---|
653 | border-right-style : solid; |
---|
654 | border-right-color : Black; |
---|
655 | font-size: 12px; |
---|
656 | font-family: Tahoma, Arial, Helvetica, sans-serif; |
---|
657 | } |
---|
658 | |
---|
659 | th.inactivetab |
---|
660 | { |
---|
661 | color:#000000; |
---|
662 | background-color:#E8F0F0; |
---|
663 | border-bottom-width : 1px; |
---|
664 | border-bottom-style : solid; |
---|
665 | border-bottom-color : Black; |
---|
666 | font-size: 12px; |
---|
667 | font-family: Tahoma, Arial, Helvetica, sans-serif; |
---|
668 | } |
---|
669 | |
---|
670 | .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;} |
---|
671 | .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;} |
---|
672 | |
---|
673 | div.activetab{ display:inline; } |
---|
674 | div.inactivetab{ display:none; }'; |
---|
675 | |
---|
676 | return $appCSS; |
---|
677 | } |
---|
678 | |
---|
679 | function show_photo() |
---|
680 | { |
---|
681 | $uidNumber = $_GET['uidNumber']; |
---|
682 | $manager_context = $_GET['manager_context']; |
---|
683 | $photo = $this->get_photo($uidNumber, $manager_context); |
---|
684 | |
---|
685 | if ($photo) |
---|
686 | { |
---|
687 | header("Content-Type: image/jpeg"); |
---|
688 | $width = imagesx($photo); |
---|
689 | $height = imagesy($photo); |
---|
690 | $twidth = 80; |
---|
691 | $theight = 106; |
---|
692 | $small_photo = imagecreatetruecolor ($twidth, $theight); |
---|
693 | imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); |
---|
694 | imagejpeg($small_photo,"",100); |
---|
695 | return; |
---|
696 | } |
---|
697 | } |
---|
698 | |
---|
699 | function get_photo($uidNumber, $manager_context) |
---|
700 | { |
---|
701 | $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
702 | $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))"; |
---|
703 | $justthese = array("jpegphoto"); |
---|
704 | |
---|
705 | $search = ldap_search($ldap_conn, $manager_context, $filter, $justthese); |
---|
706 | $entry = ldap_first_entry($ldap_conn, $search); |
---|
707 | $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto"); |
---|
708 | $jpegphoto = imagecreatefromstring($jpeg_data[0]); |
---|
709 | return $jpegphoto; |
---|
710 | } |
---|
711 | |
---|
712 | function show_access_log() |
---|
713 | { |
---|
714 | $account_id = $_GET['account_id']; |
---|
715 | |
---|
716 | $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; |
---|
717 | $tmp = $this->functions->read_acl($manager_account_lid); |
---|
718 | $manager_context = $tmp[0]['context']; |
---|
719 | |
---|
720 | // Verifica se tem acesso a este modulo |
---|
721 | if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password'))) |
---|
722 | { |
---|
723 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); |
---|
724 | } |
---|
725 | |
---|
726 | // Seta header. |
---|
727 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
728 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
729 | |
---|
730 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log'); |
---|
731 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
732 | |
---|
733 | // Seta templates. |
---|
734 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
735 | $t->set_file(array("body" => "accesslog.tpl")); |
---|
736 | $t->set_block('body','main'); |
---|
737 | $t->set_block('body','row','row'); |
---|
738 | |
---|
739 | // GET access log from the user. |
---|
740 | $GLOBALS['phpgw']->db->limit_query("select loginid,ip,li,lo,account_id,sessionid from phpgw_access_log WHERE account_id=".$account_id." order by li desc",$start,__LINE__,__FILE__); |
---|
741 | while ($GLOBALS['phpgw']->db->next_record()) |
---|
742 | { |
---|
743 | $records[] = array( |
---|
744 | 'loginid' => $GLOBALS['phpgw']->db->f('loginid'), |
---|
745 | 'ip' => $GLOBALS['phpgw']->db->f('ip'), |
---|
746 | 'li' => $GLOBALS['phpgw']->db->f('li'), |
---|
747 | 'lo' => $GLOBALS['phpgw']->db->f('lo'), |
---|
748 | 'account_id' => $GLOBALS['phpgw']->db->f('account_id'), |
---|
749 | 'sessionid' => $GLOBALS['phpgw']->db->f('sessionid') |
---|
750 | ); |
---|
751 | } |
---|
752 | |
---|
753 | // Seta as vcariaveis |
---|
754 | while (is_array($records) && list(,$record) = each($records)) |
---|
755 | { |
---|
756 | $var = array( |
---|
757 | 'row_loginid' => $record['loginid'], |
---|
758 | 'row_ip' => $record['ip'], |
---|
759 | 'row_li' => date("d/m/Y - H:i:s", $record['li']), |
---|
760 | 'row_lo' => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo']) |
---|
761 | ); |
---|
762 | $t->set_var($var); |
---|
763 | $t->fp('rows','row',True); |
---|
764 | } |
---|
765 | |
---|
766 | $var = Array( |
---|
767 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
768 | 'lang_back' => 'Back', |
---|
769 | 'back_url' => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id", |
---|
770 | 'lang_loginid' => lang('Login ID'), |
---|
771 | 'lang_ip' => lang('IP'), |
---|
772 | 'lang_login' => lang('Log IN'), |
---|
773 | 'lang_logout' => lang('Log OUT') |
---|
774 | ); |
---|
775 | $t->set_var($var); |
---|
776 | $t->pfp('out','body'); |
---|
777 | } |
---|
778 | } |
---|
779 | ?> |
---|