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

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

Alterações feitas por João Alfredo.
Email: jakjr@…

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