source: trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php @ 493

Revision 493, 32.0 KB checked in by niltonneto, 16 years ago (diff)

Correção de tradução

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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                        $acl = $this->functions->read_acl($account_lid);
58                        $raw_context = $acl['raw_context'];
59                        $contexts = $acl['contexts'];
60                        foreach ($acl['contexts_display'] as $index=>$tmp_context)
61                        {
62                                $context_display .= '<br>'.$tmp_context;
63                        }
64                        // Verifica se o administrador tem acesso.
65                        if (!$this->functions->check_acl($account_lid,'list_users'))
66                        {
67                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
68                        }
69
70                        if(isset($_POST['query']))
71                        {
72                                // limit query to limit characters
73                                if(eregi('^[a-z_0-9_-].+$',$_POST['query']))
74                                {
75                                        $GLOBALS['query'] = $_POST['query'];
76                                }
77                        }
78                       
79                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
80                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
81                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('User accounts');
82                        $GLOBALS['phpgw']->common->phpgw_header();
83
84                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
85                        $p->set_file(Array('accounts' => 'accounts.tpl'));
86                        $p->set_block('accounts','body');
87                        $p->set_block('accounts','row');
88                        $p->set_block('accounts','row_empty');
89
90                        $var = Array(
91                                'bg_color'                                      => $GLOBALS['phpgw_info']['theme']['bg_color'],
92                                'th_bg'                                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
93                                'accounts_url'                          => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
94                                'back_url'                                      => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
95                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.add_users'),
96                                'create_user_disabled'          => $this->functions->check_acl($account_lid,'add_users') ? '' : 'disabled',
97                                'context'                                       => $raw_context,
98                                'context_display'                       => $context_display,
99                                'imapDelimiter'                         => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter']
100                        );
101                        $p->set_var($var);
102                        $p->set_var($this->functions->make_dinamic_lang($p, 'body'));
103
104                        $p->set_var('query', $GLOBALS['query']);
105                       
106                        //Admin make a search
107                        if ($GLOBALS['query'] != '')
108                        {
109                                $account_info = $this->functions->get_list('accounts', $GLOBALS['query'], $contexts);
110                        }
111                       
112                        if (!count($account_info) && $GLOBALS['query'] != '')
113                        {
114                                $p->set_var('message',lang('No matches found'));
115                                $p->parse('rows','row_empty',True);
116                        }
117                        else if (count($account_info))
118                        {  // Can edit, delete or rename users ??
119                                if (($this->functions->check_acl($account_lid,'edit_users')) ||
120                                        ($this->functions->check_acl($account_lid,'change_users_password')) ||
121                                        ($this->functions->check_acl($account_lid,'edit_sambausers_attributes')) || 
122                                        ($this->functions->check_acl($account_lid,'change_users_quote')) ||
123                                        ($this->functions->check_acl($account_lid,'manipulate_corporative_information')) ||
124                                        ($this->functions->check_acl($account_lid,'edit_users_phonenumber'))
125                                        )
126                                        $can_edit = True;
127                                elseif ($this->functions->check_acl($account_lid,'view_users'))
128                                        $can_view = True;
129                                if ($this->functions->check_acl($account_lid,'delete_users'))
130                                        $can_delete = True;
131                                if ($this->functions->check_acl($account_lid,'rename_users'))
132                                        $can_rename = True;
133
134                                while (list($null,$account) = each($account_info))
135                                {
136                                        $this->nextmatchs->template_alternate_row_color($p);
137
138                                        $var = array(
139                                                'row_loginid'   => $account['account_lid'],
140                                                'row_cn'                => $account['account_cn'],
141                                                'row_mail'              => (!$account['account_mail']?'<font color=red>Sem E-mail</font>':$account['account_mail'])
142                                        );
143                                        $p->set_var($var);
144
145                                        if ($can_edit)
146                                                $p->set_var('row_edit',$this->row_action('edit','user',$account['account_id']));
147                                        elseif ($can_view)
148                                                $p->set_var('row_edit',$this->row_action('view','user',$account['account_id']));
149                                        else
150                                                $p->set_var('row_edit','&nbsp;');
151
152                                        if ($can_rename)
153                                                $p->set_var('row_rename',"<a href='#' onClick='javascript:rename_user(\"".$account['account_lid']."\",\"".$account['account_id']."\");'>".lang('to rename')."</a>");
154                                        else
155                                                $p->set_var('row_rename','&nbsp;');
156
157                                        if ($can_delete)
158                                        {
159                                                $p->set_var('row_delete',"<a href='#' onClick='javascript:delete_user(\"".$account['account_lid']."\",\"".$account['account_id']."\");'>".lang('to delete')."</a>");
160                                        }
161                                        else
162                                                $p->set_var('row_delete','&nbsp;');
163
164                                        $p->parse('rows','row',True);
165                                }
166                        }
167                        $p->pfp('out','body');
168                }
169
170                function add_users()
171                {
172                        $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2');
173                       
174                        $GLOBALS['phpgw']->js->set_onload('get_available_groups(document.forms[0].context.value);');
175                        $GLOBALS['phpgw']->js->set_onload('get_available_maillists(document.forms[0].context.value);');
176                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
177                                $GLOBALS['phpgw']->js->set_onload('get_available_sambadomains(document.forms[0].context.value, \'create_user\');');
178                       
179                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
180                        $acl = $this->functions->read_acl($manager_lid);
181                       
182                        $manager_contexts = $acl['contexts'];
183                       
184                        // Verifica se tem acesso a este modulo
185                        if (!$this->functions->check_acl($manager_lid,'add_users'))
186                        {
187                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
188                        }
189                               
190                        // Imprime nav_bar
191                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
192                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
193                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create User');
194                        $GLOBALS['phpgw']->common->phpgw_header();
195                       
196                        // Seta template
197                        $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
198                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
199                        $t->set_file(array("body" => "accounts_form.tpl"));
200                        $t->set_block('body','main');
201
202                        // Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou.
203                        foreach ($manager_contexts as $index=>$context)
204                                $combo_manager_org .= $this->functions->get_organizations($context);
205                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], '', true, true, true);
206
207                        // Chama funcao para criar lista de aplicativos disponiveis.
208                        $applications_list = $this->functions->make_list_app($manager_lid);
209
210                        // Cria combo de dominio samba
211                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
212                        {
213                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
214                                $sambadomainname_options = '';
215                                if (count($a_sambadomains))
216                                {
217                                        foreach ($a_sambadomains as $a_sambadomain)
218                                        {
219                                                // So mostra os sambaDomainName do contexto do manager
220                                                if ($this->ldap_functions->exist_sambadomains($manager_contexts, $a_sambadomain['samba_domain_name']))
221                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
222                                        }
223                                }
224                        }
225                       
226                        // Valores default.
227                        $var = Array(
228                                'row_on'                                => "#DDDDDD",
229                                'row_off'                               => "#EEEEEE",
230                                'color_bg1'                             => "#E8F0F0",
231                                //'manager_context'             => $manager_context,
232                                'type'                                  => 'create_user',
233                                'back_url'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
234                                'display_samba_suport'  => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'none',
235                                'disabled_access_button'=> 'disabled',
236                                'display_access_log_button'     => 'none',
237                                'display_access_log_button'     => 'none',
238                                'display_empty_user_inbox'      =>'none',
239                                'display_quota_used'            => 'none',
240                               
241                                // First ABA
242                                'display_spam_uid'                              => 'display:none',
243                               
244                                'sectors'                                               => $combo_manager_org,
245                                'combo_organizations'                   => $combo_manager_org,
246                                'combo_all_orgs'                                => $combo_all_orgs,
247                                'passwd_expired_checked'                => 'CHECKED',
248                                'changepassword_checked'                => 'CHECKED',
249                                'phpgwaccountstatus_checked'    => 'CHECKED',
250                                'photo_bin'                                             => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
251                                'display_picture'                               => $this->functions->check_acl($manager_lid,'edit_users_picture') ? '' : 'none',
252                                'display_tr_default_password'   => 'none',
253                                'minimumSizeLogin'                              => $this->current_config['expressoAdmin_minimumSizeLogin'],
254                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain'],
255                                'concatenateDomain'                             => $this->current_config['expressoAdmin_concatenateDomain'],
256                                'ldap_context'                                  => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
257                               
258                                // Corporative Information
259                                'display_corporative_information' => $this->functions->check_acl($manager_lid,'manipulate_corporative_information') ? '' : 'none',
260                               
261                                //MAIL
262                                'accountstatus_checked'                 => 'CHECKED',
263                                'mailquota'                                             => $this->current_config['expressoAdmin_defaultUserQuota'],
264                                'changequote_disabled'                  => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
265                                'imapDelimiter'                                 => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
266                                'input_mailalternateaddress_fields' => '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30>',
267                                'input_mailforwardingaddress_fields'=> '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30>',
268                               
269                                'apps'                                                          => $applications_list,
270                               
271                                //SAMBA ABA
272                                'use_attrs_samba_checked'                       => 'CHECKED',
273                                'sambadomainname_options'                       => $sambadomainname_options,
274                                'sambalogonscript'                                      => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '',
275                                'use_suggestion_in_logon_script'        => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false',
276                        );
277                        $t->set_var($var);
278                        $t->set_var($this->functions->make_dinamic_lang($t, 'main'));
279                        $t->pfp('out','main');
280                }
281               
282                function view_user()
283                {
284                        ExecMethod('expressoAdmin1_2.uiaccounts.edit_user');
285                        return;
286                }
287               
288                function edit_user()
289                {
290                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
291                        $acl = $this->functions->read_acl($manager_account_lid);
292                        $raw_context = $acl['raw_context'];
293                        $contexts = $acl['contexts'];           
294                        $alert_warning = '';
295                       
296                        // Verifica se tem acesso a este modulo
297                        $disabled = 'disabled';
298                        $disabled_password = 'disabled';
299                        $disabled_samba = 'disabled';
300                        $disabled_edit_photo = 'disabled';
301                        $disabled_phonenumber = 'disabled';
302                        $disabled_group = 'disabled';
303                       
304                        $display_picture = 'none';
305                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
306                                (!$this->functions->check_acl($manager_account_lid,'change_users_password')) &&
307                                (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) &&
308                                (!$this->functions->check_acl($manager_account_lid,'view_users')) &&
309                                (!$this->functions->check_acl($manager_account_lid,'manipulate_corporative_information')) &&
310                                (!$this->functions->check_acl($manager_account_lid,'edit_users_phonenumber'))
311                                )
312                        {
313                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
314                        }
315                        // SOMENTE ALTERAÇÃO DE SENHA
316                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password')))
317                        {
318                                $disabled = 'disabled';
319                                $disabled_password = '';
320                        }
321                        // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA
322                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
323                        {
324                                $disabled = 'disabled';
325                                $disabled_samba = '';
326                        }
327                        // SOMENTE ALTERAÇÃO DE TELEFONE
328                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_users_phonenumber')))
329                        {
330                                $disabled = 'disabled';
331                                $disabled_phonenumber = '';
332                        }
333                        // SOMENTE GRUPOS
334                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_groups')))
335                        {
336                                $disabled = 'disabled';
337                                $disabled_group = '';
338                        }
339                        // TOTAIS MENOS O SAMBA
340                        if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
341                        {
342                                $disabled = '';
343                                $disabled_password = '';
344                                $disabled_samba = 'disabled';
345                                $disabled_group = '';
346                        }
347                        // TOTAIS
348                        elseif ($this->functions->check_acl($manager_account_lid,'edit_users'))
349                        {
350                                $disabled = '';
351                                $disabled_password = '';
352                                $disabled_samba = '';
353                                $disabled_phonenumber = '';
354                                $disabled_group = '';
355                        }
356                       
357                        if (!$this->functions->check_acl($manager_account_lid,'change_users_quote'))
358                                $disabled_quote = 'readonly';
359                       
360                        if ($this->functions->check_acl($manager_account_lid,'edit_users_picture'))
361                        {
362                                $disabled_edit_photo = '';
363                                $display_picture = '';
364                        }
365                        // GET all infomations about the user.
366                        $user_info = $this->user->get_user_info($_GET['account_id']);
367
368                        // Formata o CPF
369                        if ($user_info['corporative_information_cpf'] != '')
370                        {
371                                if (strlen($user_info['corporative_information_cpf']) < 11)
372                                {
373                                        while (strlen($user_info['corporative_information_cpf']) < 11)
374                                        {
375                                                $user_info['corporative_information_cpf'] = '0' . $user_info['corporative_information_cpf'];
376                                        }
377                                }
378                                if (strlen($user_info['corporative_information_cpf']) == 11)
379                                {
380                                        // Compatível com o php4.
381                                        //$cpf_tmp = str_split($user_info['corporative_information_cpf'], 3);
382                                        $cpf_tmp[0] = $user_info['corporative_information_cpf'][0] . $user_info['corporative_information_cpf'][1] . $user_info['corporative_information_cpf'][2];
383                                        $cpf_tmp[1] = $user_info['corporative_information_cpf'][3] . $user_info['corporative_information_cpf'][4] . $user_info['corporative_information_cpf'][5];
384                                        $cpf_tmp[2] = $user_info['corporative_information_cpf'][6] . $user_info['corporative_information_cpf'][7] . $user_info['corporative_information_cpf'][8];
385                                        $cpf_tmp[3] = $user_info['corporative_information_cpf'][9] . $user_info['corporative_information_cpf'][10];
386                                        $user_info['corporative_information_cpf'] = $cpf_tmp[0] . '.' . $cpf_tmp[1] . '.' . $cpf_tmp[2] . '-' . $cpf_tmp[3];
387                                }
388                        }
389                        // JavaScript
390                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2");
391                        $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);");
392                        $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);");
393                        $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');");
394                       
395                        // Seta header.
396                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
397                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
398
399                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User');
400                        $GLOBALS['phpgw']->common->phpgw_header();
401
402                        // Seta templates.
403                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
404                        $t->set_file(array("body" => "accounts_form.tpl"));
405                        $t->set_block('body','main');
406                                                       
407                        foreach ($contexts as $index=>$context)
408                                $combo_manager_org .= $this->functions->get_organizations($context, $user_info['context']);
409                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], $user_info['context'], true, true, true);                       
410
411                        // GROUPS.
412                        if (count($user_info['groups_info']) > 0)
413                        {
414                                foreach ($user_info['groups_info'] as $group)
415                                {
416                                        $array_groups[$group['gidnumber']] = $group['cn'];
417                                }
418                                natcasesort($array_groups);
419                                foreach ($array_groups as $gidnumber=>$cn)
420                                {
421                                        // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap.
422                                        if (is_null($user_info['groups_ldap'][$gidnumber]))
423                                        {
424                                                $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']);
425                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [" . lang('included memberuid on ldap')."]</option>";
426
427                                                if ($alert_warning == '')
428                                                        $alert_warning = lang("the expressoadmin corrected the following inconsistencies") . ":\\n";
429                                                $alert_warning .= lang("included user on group") . ":\\n$cn - gidnumber: $gidnumber.";
430                                        }
431                                        else
432                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
433                                       
434                                        if ($gidnumber == $user_info['gidnumber'])
435                                        {
436                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>";
437                                        }
438                                        else
439                                        {
440                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
441                                        }
442                                }
443                               
444                                // O memberUid do usuário está somente no Ldap.
445                                $groups_db = array_flip($user_info['groups']);
446                                foreach ($user_info['groups_ldap'] as $gidnumber=>$cn)
447                                {
448                                        if (is_null($groups_db[$gidnumber]))
449                                        {
450                                                /*
451                                                $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']);
452                                                if ($alert_warning == '')
453                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
454                                                $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n";
455                                                */
456                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [".lang('only on ldap')."]</option>";
457                                        }
458                                }
459                        }
460                       
461                        // MAILLISTS
462                        if (count($user_info['maillists_info']) > 0)
463                        {
464                                foreach ($user_info['maillists_info'] as $maillist)
465                                {
466                                        $array_maillist[$maillist['uid']] = $maillist['uid'] . "  (" . $maillist['mail'] . ") ";
467                                }
468                                natcasesort($array_maillist);
469                                foreach ($array_maillist as $uid=>$option)
470                                {
471                                        $ea_select_user_maillists_options .= "<option value=" . $uid . ">" . $option . "</option>";
472                                }
473                        }
474                       
475                        // APPS.
476                        if ($disabled == 'disabled')
477                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps'], 'disabled');
478                        else
479                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps']);
480                       
481                        //PHOTO
482                        if ($user_info['photo_exist'])
483                        {
484                                $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id'];
485                        }
486                        else
487                        {
488                                $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png';
489                                $disabled_delete_photo = 'disabled';
490                        }
491
492                        // Cria combo de dominios do samba
493                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
494                        {
495                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
496                                $sambadomainname_options = '';
497                                if (count($a_sambadomains))
498                                {
499                                        foreach ($a_sambadomains as $a_sambadomain)
500                                        {
501                                                if ($a_sambadomain['samba_domain_sid'] == $user_info['sambasid'])
502                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>";
503                                                else
504                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
505                                        }
506                                }
507                        }
508                       
509                        // Mail Alternate & Forwarding
510                        if (is_array($user_info['mailalternateaddress']))
511                        {
512                                for ($i = 0; $i < $user_info['mailalternateaddress']['count']; $i++)
513                                {
514                                        if ($i > 0)
515                                                $input_mailalternateaddress_fields .= '<br>';
516                                        $input_mailalternateaddress_fields .= '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="'.$user_info['mailalternateaddress'][$i].'" {disabled} size=30>';
517                                }
518                        }
519                        else
520                        {
521                                $input_mailalternateaddress_fields = '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="" {disabled} size=30>';
522                        }
523
524                        if (is_array($user_info['mailforwardingaddress']))
525                        {
526                                for ($i = 0; $i < $user_info['mailforwardingaddress']['count']; $i++)
527                                {
528                                        if ($i > 0)
529                                                $input_mailforwardingaddress_fields .= '<br>';
530                                        $input_mailforwardingaddress_fields .= '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="'.$user_info['mailforwardingaddress'][$i].'" {disabled} size=30>';
531                                }
532                        }
533                        else
534                        {
535                                $input_mailforwardingaddress_fields = '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="" {disabled} size=30>';
536                        }
537
538                        if ($alert_warning != '')
539                                $alert_warning = "alert('". $alert_warning ."')";
540                        $var = Array(
541                                'uidnumber'                                     => $_GET['account_id'],
542                                'type'                                          => 'edit_user',
543                                'photo_exist'                           => $user_info['photo_exist'],
544                                'departmentnumber'                      => $user_info['departmentnumber'],
545                                'user_context'                          => $user_info['context'],
546                               
547                                'row_on'                                        => "#DDDDDD",
548                                'row_off'                                       => "#EEEEEE",
549                                'color_bg1'                                     => "#E8F0F0",
550                                'action'                                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'),
551                                'back_url'                                      => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users',
552                                'disabled'                                      => $disabled,
553                                'disabled_password'                     => $disabled_password,
554                                'disabled_samba'                        => $disabled_samba,
555                                'changequote_disabled'          => $disabled_quote,
556                                'disable_phonenumber'           => $disabled_phonenumber,
557                                'disable_group'                         => $disabled_group,
558                               
559                                // Display ABAS
560                                'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'manipulate_corporative_information') ? '' : 'none',
561                                'display_applications'          => $this->functions->check_acl($manager_account_lid,'display_applications') ? '' : 'none',
562                                'display_emaillists'            => $this->functions->check_acl($manager_account_lid,'display_emaillists') ? '' : 'none',
563                                'display_groups'                        => $this->functions->check_acl($manager_account_lid,'display_groups') ? '' : 'none',
564                                'display_emailconfig'           => $this->functions->check_acl($manager_account_lid,'display_emailconfig') ? '' : 'none',
565                               
566                                // First ABA
567                                'alert_warning'                                 => "$alert_warning",
568                                'display_input_account_lid'             => 'display:none',
569                                'sectors'                                               => $combo_manager_org,
570                                'combo_organizations'                   => $combo_manager_org,
571                                'combo_all_orgs'                                => $combo_all_orgs,
572                                'uid'                                                   => $user_info['uid'],
573                                'givenname'                                             => $user_info['givenname'],
574                                'mail1'                                                 => $user_info['mail'],
575                                'sn'                                                    => $user_info['sn'],
576                                'telephonenumber'                               => $user_info['telephonenumber'],
577                                'photo_bin'                                             => $photo_bin,
578                                'disabled_edit_photo'                   => $disabled_edit_photo,
579                                'display_picture'                               => $display_picture,
580                                'display_tr_default_password'   => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
581                                'passwd_expired_checked'                => $user_info['passwd_expired'] == '0' ? 'CHECKED' : '',
582                                'changepassword_checked'                => $user_info['changepassword'] == '1' ? 'CHECKED' : '',
583                                'phpgwaccountstatus_checked'    => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '',
584                                'phpgwaccountvisible_checked'   => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
585
586                                // Corporative Information
587                                'corporative_information_employeenumber' => $user_info['corporative_information_employeenumber'],
588                                'corporative_information_cpf'                   => $user_info['corporative_information_cpf'],
589                                'corporative_information_rg'                    => $user_info['corporative_information_rg'],
590                                'corporative_information_rguf'                  => $user_info['corporative_information_rguf'],
591                                'corporative_information_description'   => $user_info['corporative_information_description'],
592                               
593                                //MAIL
594                                'disabled_quota_used'           => 'disabled',
595                                'accountstatus_checked'         => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
596                                'mail'                                          => $user_info['mail'],
597                                'input_mailalternateaddress_fields'     => $input_mailalternateaddress_fields,
598                                'input_mailforwardingaddress_fields'=> $input_mailforwardingaddress_fields,
599                                'deliverymode_checked'          => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
600                                'mailquota'                                     => $user_info['mailquota'],
601                                'mailquota_used'                        => $user_info['mailquota_used'],
602
603                                //Third ABA
604                                'ea_select_user_groups_options' => $ea_select_user_groups_options,
605                                'ea_combo_primary_user_group_options'   => $ea_combo_primary_user_group_options,
606                               
607                                //Fourd ABA
608                                'ea_select_user_maillists_options'  => $ea_select_user_maillists_options,
609                                                               
610                                //Five ABA
611                                'apps'  => $apps,
612
613                                //SAMBA ABA
614                                'userSamba'                                     => $user_info['sambaUser'],
615                                'sambadomainname_options'       => $sambadomainname_options,
616                                'use_attrs_samba_checked'       => $user_info['sambaUser'] ? 'CHECKED' : '',
617                                'active_user_selected'          => $user_info['sambaaccflags'] == '[U          ]' ? 'selected' : '',
618                                'desactive_user_selected'       => $user_info['sambaaccflags'] == '[DU         ]' ? 'selected' : '',
619                                'sambalogonscript'                      => $user_info['sambalogonscript'],
620                                'sambahomedirectory'            => $user_info['homedirectory'],
621                                'defaultLogonScript'            => $this->current_config['expressoAdmin_defaultLogonScript'],
622                                'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false'
623                        );
624                        $t->set_var($var);
625                        $t->set_var($this->functions->make_dinamic_lang($t, 'main'));
626                       
627                        // Devo mostrar aba SAMBA ??
628                        if ( ($this->current_config['expressoAdmin_samba_support'] == 'true') && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) )
629                                $t->set_var('display_samba_suport', '');
630                        else
631                                $t->set_var('display_samba_suport', 'none');
632                       
633                        $t->pfp('out','body');                 
634                }
635               
636                function row_action($action,$type,$account_id)
637                {
638                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
639                                'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type,
640                                'account_id' => $account_id
641                        )).'"> '.lang($action).' </a>';
642                }
643
644                function css()
645                {
646                        $appCSS =
647                        'th.activetab
648                        {
649                                color:#000000;
650                                background-color:#D3DCE3;
651                                border-top-width : 1px;
652                                border-top-style : solid;
653                                border-top-color : Black;
654                                border-left-width : 1px;
655                                border-left-style : solid;
656                                border-left-color : Black;
657                                border-right-width : 1px;
658                                border-right-style : solid;
659                                border-right-color : Black;
660                                font-size: 12px;
661                                font-family: Tahoma, Arial, Helvetica, sans-serif;
662                        }
663                       
664                        th.inactivetab
665                        {
666                                color:#000000;
667                                background-color:#E8F0F0;
668                                border-bottom-width : 1px;
669                                border-bottom-style : solid;
670                                border-bottom-color : Black;
671                                font-size: 12px;
672                                font-family: Tahoma, Arial, Helvetica, sans-serif;                             
673                        }
674                       
675                        .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
676                        .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
677                       
678                        div.activetab{ display:inline; }
679                        div.inactivetab{ display:none; }';
680                       
681                        return $appCSS;
682                }
683
684                function show_photo()
685                {
686                        $uidNumber = $_GET['uidNumber'];
687                        $photo = $this->get_photo($uidNumber);
688                       
689                if ($photo)
690                        {
691                        header("Content-Type: image/jpeg");
692                                $width = imagesx($photo);
693                                $height = imagesy($photo);
694                    $twidth = 80;
695                $theight = 106;
696                                $small_photo = imagecreatetruecolor ($twidth, $theight);
697                                imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
698                                imagejpeg($small_photo,"",100);
699                                return;
700                        }
701                }
702               
703                function get_photo($uidNumber)
704                {
705                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
706                        $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))";
707                        $justthese = array("jpegphoto");
708
709                        $search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
710                        $entry = ldap_first_entry($ldap_conn, $search);
711                        $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto");
712                        $jpegphoto = imagecreatefromstring($jpeg_data[0]);
713                        return $jpegphoto;
714                }
715               
716                function show_access_log()
717                {       
718                        $account_id = $_GET['account_id'];
719                       
720                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
721                        $tmp = $this->functions->read_acl($manager_account_lid);
722                        $manager_context = $tmp[0]['context'];
723                       
724                        // Verifica se tem acesso a este modulo
725                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password')))
726                        {
727                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
728                        }
729
730                        // Seta header.
731                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
732                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
733
734                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log');
735                        $GLOBALS['phpgw']->common->phpgw_header();
736
737                        // Seta templates.
738                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
739                        $t->set_file(array("body" => "accesslog.tpl"));
740                        $t->set_block('body','main');
741                        $t->set_block('body','row','row');
742
743                        // GET access log from the user.
744                        $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__);
745                        while ($GLOBALS['phpgw']->db->next_record())
746                        {
747                                $records[] = array(
748                                        'loginid'    => $GLOBALS['phpgw']->db->f('loginid'),
749                                        'ip'         => $GLOBALS['phpgw']->db->f('ip'),
750                                        'li'         => $GLOBALS['phpgw']->db->f('li'),
751                                        'lo'         => $GLOBALS['phpgw']->db->f('lo'),
752                                        'account_id' => $GLOBALS['phpgw']->db->f('account_id'),
753                                        'sessionid'  => $GLOBALS['phpgw']->db->f('sessionid')
754                                );
755                        }
756
757                        // Seta as vcariaveis
758                        while (is_array($records) && list(,$record) = each($records))
759                        {
760                                $var = array(
761                                        'row_loginid' => $record['loginid'],
762                                        'row_ip'      => $record['ip'],
763                                        'row_li'      => date("d/m/Y - H:i:s", $record['li']),
764                                        'row_lo'      => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo'])
765                                );
766                                $t->set_var($var);
767                                $t->fp('rows','row',True);
768                        }
769
770                        $var = Array(
771                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
772                                'back_url'              => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id",
773                        );
774                        $t->set_var($var);
775                        $t->set_var($this->functions->make_dinamic_lang($t, 'body'));
776                        $t->pfp('out','body');
777                }
778        }
779?>
Note: See TracBrowser for help on using the repository browser.