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

Revision 471, 31.8 KB checked in by niltonneto, 16 years ago (diff)

Alterações feitas por Joao Alfredo:

  • Corrigido bug que gerava tela branca após criação de setor.
  • Corrigido tradução.
  • Escondido Exibir registro de acesso na criação de contas.
  • 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']."\");'>Renomear</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']."\");'>Excluir</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_samba_suport'  => 'none',
237                               
238                                // First ABA
239                                'display_spam_uid'                              => 'display:none',
240                               
241                                'sectors'                                               => $combo_manager_org,
242                                'combo_organizations'                   => $combo_manager_org,
243                                'combo_all_orgs'                                => $combo_all_orgs,
244                                'passwd_expired_checked'                => 'CHECKED',
245                                'changepassword_checked'                => 'CHECKED',
246                                'phpgwaccountstatus_checked'    => 'CHECKED',
247                                'photo_bin'                                             => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
248                                'display_picture'                               => $this->functions->check_acl($manager_lid,'edit_users_picture') ? '' : 'none',
249                                'display_tr_default_password'   => 'none',
250                                'minimumSizeLogin'                              => $this->current_config['expressoAdmin_minimumSizeLogin'],
251                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain'],
252                                'concatenateDomain'                             => $this->current_config['expressoAdmin_concatenateDomain'],
253                                'ldap_context'                                  => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
254                               
255                                // Corporative Information
256                                'display_corporative_information' => $this->functions->check_acl($manager_lid,'manipulate_corporative_information') ? '' : 'none',
257                               
258                                //MAIL
259                                'accountstatus_checked'                 => 'CHECKED',
260                                'mailquota'                                             => $this->current_config['expressoAdmin_defaultUserQuota'],
261                                'changequote_disabled'                  => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
262                                'imapDelimiter'                                 => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
263                                'input_mailalternateaddress_fields' => '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30>',
264                                'input_mailforwardingaddress_fields'=> '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30>',
265                               
266                                'apps'                                                          => $applications_list,
267                               
268                                //SAMBA ABA
269                                'use_attrs_samba_checked'                       => 'CHECKED',
270                                'sambadomainname_options'                       => $sambadomainname_options,
271                                'sambalogonscript'                                      => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '',
272                                'use_suggestion_in_logon_script'        => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false',
273                        );
274                        $t->set_var($var);
275                        $t->set_var($this->functions->make_dinamic_lang($t, 'main'));
276                        $t->pfp('out','main');
277                }
278               
279                function view_user()
280                {
281                        ExecMethod('expressoAdmin1_2.uiaccounts.edit_user');
282                        return;
283                }
284               
285                function edit_user()
286                {
287                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
288                        $acl = $this->functions->read_acl($manager_account_lid);
289                        $raw_context = $acl['raw_context'];
290                        $contexts = $acl['contexts'];           
291                        $alert_warning = '';
292                       
293                        // Verifica se tem acesso a este modulo
294                        $disabled = 'disabled';
295                        $disabled_password = 'disabled';
296                        $disabled_samba = 'disabled';
297                        $disabled_edit_photo = 'disabled';
298                        $disabled_phonenumber = 'disabled';
299                        $disabled_group = 'disabled';
300                       
301                        $display_picture = 'none';
302                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
303                                (!$this->functions->check_acl($manager_account_lid,'change_users_password')) &&
304                                (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) &&
305                                (!$this->functions->check_acl($manager_account_lid,'view_users')) &&
306                                (!$this->functions->check_acl($manager_account_lid,'manipulate_corporative_information')) &&
307                                (!$this->functions->check_acl($manager_account_lid,'edit_users_phonenumber'))
308                                )
309                        {
310                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
311                        }
312                        // SOMENTE ALTERAÇÃO DE SENHA
313                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password')))
314                        {
315                                $disabled = 'disabled';
316                                $disabled_password = '';
317                        }
318                        // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA
319                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
320                        {
321                                $disabled = 'disabled';
322                                $disabled_samba = '';
323                        }
324                        // SOMENTE ALTERAÇÃO DE TELEFONE
325                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_users_phonenumber')))
326                        {
327                                $disabled = 'disabled';
328                                $disabled_phonenumber = '';
329                        }
330                        // SOMENTE GRUPOS
331                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_groups')))
332                        {
333                                $disabled = 'disabled';
334                                $disabled_group = '';
335                        }
336                        // TOTAIS MENOS O SAMBA
337                        if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
338                        {
339                                $disabled = '';
340                                $disabled_password = '';
341                                $disabled_samba = 'disabled';
342                                $disabled_group = '';
343                        }
344                        // TOTAIS
345                        elseif ($this->functions->check_acl($manager_account_lid,'edit_users'))
346                        {
347                                $disabled = '';
348                                $disabled_password = '';
349                                $disabled_samba = '';
350                                $disabled_phonenumber = '';
351                                $disabled_group = '';
352                        }
353                       
354                        if (!$this->functions->check_acl($manager_account_lid,'change_users_quote'))
355                                $disabled_quote = 'readonly';
356                       
357                        if ($this->functions->check_acl($manager_account_lid,'edit_users_picture'))
358                        {
359                                $disabled_edit_photo = '';
360                                $display_picture = '';
361                        }
362                        // GET all infomations about the user.
363                        $user_info = $this->user->get_user_info($_GET['account_id']);
364
365                        // Formata o CPF
366                        if ($user_info['corporative_information_cpf'] != '')
367                        {
368                                if (strlen($user_info['corporative_information_cpf']) < 11)
369                                {
370                                        while (strlen($user_info['corporative_information_cpf']) < 11)
371                                        {
372                                                $user_info['corporative_information_cpf'] = '0' . $user_info['corporative_information_cpf'];
373                                        }
374                                }
375                                if (strlen($user_info['corporative_information_cpf']) == 11)
376                                {
377                                        // Compatível com o php4.
378                                        //$cpf_tmp = str_split($user_info['corporative_information_cpf'], 3);
379                                        $cpf_tmp[0] = $user_info['corporative_information_cpf'][0] . $user_info['corporative_information_cpf'][1] . $user_info['corporative_information_cpf'][2];
380                                        $cpf_tmp[1] = $user_info['corporative_information_cpf'][3] . $user_info['corporative_information_cpf'][4] . $user_info['corporative_information_cpf'][5];
381                                        $cpf_tmp[2] = $user_info['corporative_information_cpf'][6] . $user_info['corporative_information_cpf'][7] . $user_info['corporative_information_cpf'][8];
382                                        $cpf_tmp[3] = $user_info['corporative_information_cpf'][9] . $user_info['corporative_information_cpf'][10];
383                                        $user_info['corporative_information_cpf'] = $cpf_tmp[0] . '.' . $cpf_tmp[1] . '.' . $cpf_tmp[2] . '-' . $cpf_tmp[3];
384                                }
385                        }
386                        // JavaScript
387                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2");
388                        $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);");
389                        $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);");
390                        $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');");
391                       
392                        // Seta header.
393                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
394                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
395
396                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User');
397                        $GLOBALS['phpgw']->common->phpgw_header();
398
399                        // Seta templates.
400                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
401                        $t->set_file(array("body" => "accounts_form.tpl"));
402                        $t->set_block('body','main');
403                                                       
404                        foreach ($contexts as $index=>$context)
405                                $combo_manager_org .= $this->functions->get_organizations($context, $user_info['context']);
406                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], $user_info['context'], true, true, true);                       
407
408                        // GROUPS.
409                        if (count($user_info['groups_info']) > 0)
410                        {
411                                foreach ($user_info['groups_info'] as $group)
412                                {
413                                        $array_groups[$group['gidnumber']] = $group['cn'];
414                                }
415                                natcasesort($array_groups);
416                                foreach ($array_groups as $gidnumber=>$cn)
417                                {
418                                        // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap.
419                                        if (is_null($user_info['groups_ldap'][$gidnumber]))
420                                        {
421                                                $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']);
422                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Incluido memberUid no Ldap]</option>";
423
424                                                if ($alert_warning == '')
425                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
426                                                $alert_warning .= "Incluido atributo memberUid do usuário no grupo:\\n$cn - gidnumber: $gidnumber.";
427                                        }
428                                        else
429                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
430                                       
431                                        if ($gidnumber == $user_info['gidnumber'])
432                                        {
433                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>";
434                                        }
435                                        else
436                                        {
437                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
438                                        }
439                                }
440                               
441                                // O memberUid do usuário está somente no Ldap.
442                                $groups_db = array_flip($user_info['groups']);
443                                foreach ($user_info['groups_ldap'] as $gidnumber=>$cn)
444                                {
445                                        if (is_null($groups_db[$gidnumber]))
446                                        {
447                                                /*
448                                                $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']);
449                                                if ($alert_warning == '')
450                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
451                                                $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n";
452                                                */
453                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Somente no LDAP]</option>";
454                                        }
455                                }
456                        }
457                       
458                        // MAILLISTS
459                        if (count($user_info['maillists_info']) > 0)
460                        {
461                                foreach ($user_info['maillists_info'] as $maillist)
462                                {
463                                        $array_maillist[$maillist['uid']] = $maillist['uid'] . "  (" . $maillist['mail'] . ") ";
464                                }
465                                natcasesort($array_maillist);
466                                foreach ($array_maillist as $uid=>$option)
467                                {
468                                        $ea_select_user_maillists_options .= "<option value=" . $uid . ">" . $option . "</option>";
469                                }
470                        }
471                       
472                        // APPS.
473                        if ($disabled == 'disabled')
474                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps'], 'disabled');
475                        else
476                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps']);
477                       
478                        //PHOTO
479                        if ($user_info['photo_exist'])
480                        {
481                                $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id'];
482                        }
483                        else
484                        {
485                                $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png';
486                                $disabled_delete_photo = 'disabled';
487                        }
488
489                        // Cria combo de dominios do samba
490                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
491                        {
492                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
493                                $sambadomainname_options = '';
494                                if (count($a_sambadomains))
495                                {
496                                        foreach ($a_sambadomains as $a_sambadomain)
497                                        {
498                                                if ($a_sambadomain['samba_domain_sid'] == $user_info['sambasid'])
499                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>";
500                                                else
501                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
502                                        }
503                                }
504                        }
505                       
506                        // Mail Alternate & Forwarding
507                        if (is_array($user_info['mailalternateaddress']))
508                        {
509                                for ($i = 0; $i < $user_info['mailalternateaddress']['count']; $i++)
510                                {
511                                        if ($i > 0)
512                                                $input_mailalternateaddress_fields .= '<br>';
513                                        $input_mailalternateaddress_fields .= '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="'.$user_info['mailalternateaddress'][$i].'" {disabled} size=30>';
514                                }
515                        }
516                        else
517                        {
518                                $input_mailalternateaddress_fields = '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="" {disabled} size=30>';
519                        }
520
521                        if (is_array($user_info['mailforwardingaddress']))
522                        {
523                                for ($i = 0; $i < $user_info['mailforwardingaddress']['count']; $i++)
524                                {
525                                        if ($i > 0)
526                                                $input_mailforwardingaddress_fields .= '<br>';
527                                        $input_mailforwardingaddress_fields .= '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="'.$user_info['mailforwardingaddress'][$i].'" {disabled} size=30>';
528                                }
529                        }
530                        else
531                        {
532                                $input_mailforwardingaddress_fields = '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="" {disabled} size=30>';
533                        }
534
535                        if ($alert_warning != '')
536                                $alert_warning = "alert('". $alert_warning ."')";
537                        $var = Array(
538                                'uidnumber'                                     => $_GET['account_id'],
539                                'type'                                          => 'edit_user',
540                                'photo_exist'                           => $user_info['photo_exist'],
541                                'departmentnumber'                      => $user_info['departmentnumber'],
542                                'user_context'                          => $user_info['context'],
543                               
544                                'row_on'                                        => "#DDDDDD",
545                                'row_off'                                       => "#EEEEEE",
546                                'color_bg1'                                     => "#E8F0F0",
547                                'action'                                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'),
548                                'back_url'                                      => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users',
549                                'disabled'                                      => $disabled,
550                                'disabled_password'                     => $disabled_password,
551                                'disabled_samba'                        => $disabled_samba,
552                                'changequote_disabled'          => $disabled_quote,
553                                'disable_phonenumber'           => $disabled_phonenumber,
554                                'disable_group'                         => $disabled_group,
555                               
556                                // Display ABAS
557                                'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'manipulate_corporative_information') ? '' : 'none',
558                                'display_applications'          => $this->functions->check_acl($manager_account_lid,'display_applications') ? '' : 'none',
559                                'display_emaillists'            => $this->functions->check_acl($manager_account_lid,'display_emaillists') ? '' : 'none',
560                                'display_groups'                        => $this->functions->check_acl($manager_account_lid,'display_groups') ? '' : 'none',
561                                'display_emailconfig'           => $this->functions->check_acl($manager_account_lid,'display_emailconfig') ? '' : 'none',
562                               
563                                // First ABA
564                                'alert_warning'                                 => "$alert_warning",
565                                'display_input_account_lid'             => 'display:none',
566                                'sectors'                                               => $combo_manager_org,
567                                'combo_organizations'                   => $combo_manager_org,
568                                'combo_all_orgs'                                => $combo_all_orgs,
569                                'uid'                                                   => $user_info['uid'],
570                                'givenname'                                             => $user_info['givenname'],
571                                'mail1'                                                 => $user_info['mail'],
572                                'sn'                                                    => $user_info['sn'],
573                                'telephonenumber'                               => $user_info['telephonenumber'],
574                                'photo_bin'                                             => $photo_bin,
575                                'disabled_edit_photo'                   => $disabled_edit_photo,
576                                'display_picture'                               => $display_picture,
577                                'display_tr_default_password'   => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
578                                'passwd_expired_checked'                => $user_info['passwd_expired'] == '0' ? 'CHECKED' : '',
579                                'changepassword_checked'                => $user_info['changepassword'] == '1' ? 'CHECKED' : '',
580                                'phpgwaccountstatus_checked'    => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '',
581                                'phpgwaccountvisible_checked'   => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
582
583                                // Corporative Information
584                                'corporative_information_employeenumber' => $user_info['corporative_information_employeenumber'],
585                                'corporative_information_cpf'                   => $user_info['corporative_information_cpf'],
586                                'corporative_information_rg'                    => $user_info['corporative_information_rg'],
587                                'corporative_information_rguf'                  => $user_info['corporative_information_rguf'],
588                                'corporative_information_description'   => $user_info['corporative_information_description'],
589                               
590                                //MAIL
591                                'disabled_quota_used'           => 'disabled',
592                                'accountstatus_checked'         => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
593                                'mail'                                          => $user_info['mail'],
594                                'input_mailalternateaddress_fields'     => $input_mailalternateaddress_fields,
595                                'input_mailforwardingaddress_fields'=> $input_mailforwardingaddress_fields,
596                                'deliverymode_checked'          => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
597                                'mailquota'                                     => $user_info['mailquota'],
598                                'mailquota_used'                        => $user_info['mailquota_used'],
599
600                                //Third ABA
601                                'ea_select_user_groups_options' => $ea_select_user_groups_options,
602                                'ea_combo_primary_user_group_options'   => $ea_combo_primary_user_group_options,
603                               
604                                //Fourd ABA
605                                'ea_select_user_maillists_options'  => $ea_select_user_maillists_options,
606                                                               
607                                //Five ABA
608                                'apps'  => $apps,
609
610                                //SAMBA ABA
611                                'userSamba'                                     => $user_info['sambaUser'],
612                                'sambadomainname_options'       => $sambadomainname_options,
613                                'use_attrs_samba_checked'       => $user_info['sambaUser'] ? 'CHECKED' : '',
614                                'active_user_selected'          => $user_info['sambaaccflags'] == '[U          ]' ? 'selected' : '',
615                                'desactive_user_selected'       => $user_info['sambaaccflags'] == '[DU         ]' ? 'selected' : '',
616                                'sambalogonscript'                      => $user_info['sambalogonscript'],
617                                'sambahomedirectory'            => $user_info['homedirectory'],
618                                'defaultLogonScript'            => $this->current_config['expressoAdmin_defaultLogonScript'],
619                                'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false'
620                        );
621                        $t->set_var($var);
622                        $t->set_var($this->functions->make_dinamic_lang($t, 'main'));
623                       
624                        // Devo mostrar aba SAMBA ??
625                        if ( ($this->current_config['expressoAdmin_samba_support'] == 'true') && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) )
626                                $t->set_var('display_samba_suport', '');
627                        else
628                                $t->set_var('display_samba_suport', 'none');
629                       
630                        $t->pfp('out','body');                 
631                }
632               
633                function row_action($action,$type,$account_id)
634                {
635                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
636                                'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type,
637                                'account_id' => $account_id
638                        )).'"> '.lang($action).' </a>';
639                }
640
641                function css()
642                {
643                        $appCSS =
644                        'th.activetab
645                        {
646                                color:#000000;
647                                background-color:#D3DCE3;
648                                border-top-width : 1px;
649                                border-top-style : solid;
650                                border-top-color : Black;
651                                border-left-width : 1px;
652                                border-left-style : solid;
653                                border-left-color : Black;
654                                border-right-width : 1px;
655                                border-right-style : solid;
656                                border-right-color : Black;
657                                font-size: 12px;
658                                font-family: Tahoma, Arial, Helvetica, sans-serif;
659                        }
660                       
661                        th.inactivetab
662                        {
663                                color:#000000;
664                                background-color:#E8F0F0;
665                                border-bottom-width : 1px;
666                                border-bottom-style : solid;
667                                border-bottom-color : Black;
668                                font-size: 12px;
669                                font-family: Tahoma, Arial, Helvetica, sans-serif;                             
670                        }
671                       
672                        .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
673                        .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
674                       
675                        div.activetab{ display:inline; }
676                        div.inactivetab{ display:none; }';
677                       
678                        return $appCSS;
679                }
680
681                function show_photo()
682                {
683                        $uidNumber = $_GET['uidNumber'];
684                        $photo = $this->get_photo($uidNumber);
685                       
686                if ($photo)
687                        {
688                        header("Content-Type: image/jpeg");
689                                $width = imagesx($photo);
690                                $height = imagesy($photo);
691                    $twidth = 80;
692                $theight = 106;
693                                $small_photo = imagecreatetruecolor ($twidth, $theight);
694                                imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
695                                imagejpeg($small_photo,"",100);
696                                return;
697                        }
698                }
699               
700                function get_photo($uidNumber)
701                {
702                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
703                        $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))";
704                        $justthese = array("jpegphoto");
705
706                        $search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
707                        $entry = ldap_first_entry($ldap_conn, $search);
708                        $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto");
709                        $jpegphoto = imagecreatefromstring($jpeg_data[0]);
710                        return $jpegphoto;
711                }
712               
713                function show_access_log()
714                {       
715                        $account_id = $_GET['account_id'];
716                       
717                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
718                        $tmp = $this->functions->read_acl($manager_account_lid);
719                        $manager_context = $tmp[0]['context'];
720                       
721                        // Verifica se tem acesso a este modulo
722                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password')))
723                        {
724                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
725                        }
726
727                        // Seta header.
728                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
729                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
730
731                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log');
732                        $GLOBALS['phpgw']->common->phpgw_header();
733
734                        // Seta templates.
735                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
736                        $t->set_file(array("body" => "accesslog.tpl"));
737                        $t->set_block('body','main');
738                        $t->set_block('body','row','row');
739
740                        // GET access log from the user.
741                        $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__);
742                        while ($GLOBALS['phpgw']->db->next_record())
743                        {
744                                $records[] = array(
745                                        'loginid'    => $GLOBALS['phpgw']->db->f('loginid'),
746                                        'ip'         => $GLOBALS['phpgw']->db->f('ip'),
747                                        'li'         => $GLOBALS['phpgw']->db->f('li'),
748                                        'lo'         => $GLOBALS['phpgw']->db->f('lo'),
749                                        'account_id' => $GLOBALS['phpgw']->db->f('account_id'),
750                                        'sessionid'  => $GLOBALS['phpgw']->db->f('sessionid')
751                                );
752                        }
753
754                        // Seta as vcariaveis
755                        while (is_array($records) && list(,$record) = each($records))
756                        {
757                                $var = array(
758                                        'row_loginid' => $record['loginid'],
759                                        'row_ip'      => $record['ip'],
760                                        'row_li'      => date("d/m/Y - H:i:s", $record['li']),
761                                        'row_lo'      => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo'])
762                                );
763                                $t->set_var($var);
764                                $t->fp('rows','row',True);
765                        }
766
767                        $var = Array(
768                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
769                                'back_url'              => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id",
770                        );
771                        $t->set_var($var);
772                        $t->set_var($this->functions->make_dinamic_lang($t, 'body'));
773                        $t->pfp('out','body');
774                }
775        }
776?>
Note: See TracBrowser for help on using the repository browser.