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

Revision 233, 38.8 KB checked in by wmerlotto, 16 years ago (diff)

Internacionalizacao do ExpressoAdmin

  • 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                       
65                        // Verifica se o administrador tem acesso.
66                        if (!$this->functions->check_acl($account_lid,'list_users'))
67                        {
68                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
69                        }
70
71                        if(isset($_POST['query']))
72                        {
73                                // limit query to limit characters
74                                if(eregi('^[a-z_0-9_-].+$',$_POST['query']))
75                                {
76                                        $GLOBALS['query'] = $_POST['query'];
77                                }
78                        }
79                       
80                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
81                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
82                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('User accounts');
83                        $GLOBALS['phpgw']->common->phpgw_header();
84
85                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
86                        $p->set_file(Array('accounts' => 'accounts.tpl'));
87                        $p->set_block('accounts','body');
88                        $p->set_block('accounts','row');
89                        $p->set_block('accounts','row_empty');
90
91                        $var = Array(
92                                'bg_color'                                      => $GLOBALS['phpgw_info']['theme']['bg_color'],
93                                'th_bg'                                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
94                               
95                                'accounts_url'                          => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
96                                'back_url'                                      => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
97                                'add_action'                            => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.add_users'),
98                               
99                                'create_user_disabled'          => $this->functions->check_acl($account_lid,'add_users') ? '' : 'disabled',
100                                'context'                                       => $raw_context,
101                                'context_display'                       => $context_display,
102                                'imapDelimiter'                         => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
103                               
104                                'lang_create_user'                      => lang('Create User'),
105                                'lang_loginid'                          => lang('LoginID'),
106                                'lang_cn'                                       => lang('Name'),
107                                'lang_mail'                                     => lang('E-mail'),
108                                'lang_edit'                                     => lang('edit'),
109                                'lang_rename'                           => lang('rename'),
110                                'lang_delete'                           => lang('delete'),
111                                'lang_search'                           => lang('Search'),
112                                'lang_back'                                     => lang('back'),
113                                'lang_contexts'                         => lang('Contexts')
114                               
115                        );
116                        $p->set_var($var);
117                       
118                        // Save query
119                        $p->set_var('query', $GLOBALS['query']);
120                       
121                        //Admin make a search
122                        if ($GLOBALS['query'] != '')
123                        {
124                                $account_info = $this->functions->get_list('accounts', $GLOBALS['query'], $contexts);
125                        }
126                       
127                        if (!count($account_info) && $GLOBALS['query'] != '')
128                        {
129                                $p->set_var('message',lang('No matches found'));
130                                $p->parse('rows','row_empty',True);
131                        }
132                        else if (count($account_info))
133                        {  // Can edit, delete or rename users ??
134                                if (($this->functions->check_acl($account_lid,'edit_users')) ||
135                                        ($this->functions->check_acl($account_lid,'change_users_password')) ||
136                                        ($this->functions->check_acl($account_lid,'edit_sambausers_attributes')) || 
137                                        ($this->functions->check_acl($account_lid,'change_users_quote')) ||
138                                        ($this->functions->check_acl($account_lid,'manipulate_corporative_information'))
139                                        )
140                                        $can_edit = True;
141                                elseif ($this->functions->check_acl($account_lid,'view_users'))
142                                        $can_view = True;
143                                if ($this->functions->check_acl($account_lid,'delete_users'))
144                                        $can_delete = True;
145                                if ($this->functions->check_acl($account_lid,'rename_users'))
146                                        $can_rename = True;
147
148                                while (list($null,$account) = each($account_info))
149                                {
150                                        $this->nextmatchs->template_alternate_row_color($p);
151
152                                        $var = array(
153                                                'row_loginid'   => $account['account_lid'],
154                                                'row_cn'                => $account['account_cn'],
155                                                'row_mail'              => (!$account['account_mail']?'<font color=red>Sem E-mail</font>':$account['account_mail'])
156                                        );
157                                        $p->set_var($var);
158
159                                        if ($can_edit)
160                                                $p->set_var('row_edit',$this->row_action('edit','user',$account['account_id']));
161                                        elseif ($can_view)
162                                                $p->set_var('row_edit',$this->row_action('view','user',$account['account_id']));
163                                        else
164                                                $p->set_var('row_edit','&nbsp;');
165
166                                        if ($can_rename)
167                                                $p->set_var('row_rename',"<a href='#' onClick='javascript:rename_user(\"".$account['account_lid']."\",\"".$account['account_id']."\");'>Renomear</a>");
168                                        else
169                                                $p->set_var('row_rename','&nbsp;');
170
171                                        if ($can_delete)
172                                        {
173                                                $p->set_var('row_delete',"<a href='#' onClick='javascript:delete_user(\"".$account['account_lid']."\",\"".$account['account_id']."\");'>Excluir</a>");
174                                        }
175                                        else
176                                                $p->set_var('row_delete','&nbsp;');
177
178                                        $p->parse('rows','row',True);
179                                }
180                        }
181                        $p->pfp('out','body');
182                }
183
184                function add_users()
185                {
186                        $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2');
187                       
188                        $GLOBALS['phpgw']->js->set_onload('get_available_groups(document.forms[0].context.value);');
189                        $GLOBALS['phpgw']->js->set_onload('get_available_maillists(document.forms[0].context.value);');
190                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
191                                $GLOBALS['phpgw']->js->set_onload('get_available_sambadomains(document.forms[0].context.value, \'create_user\');');
192                       
193                        $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
194                        $acl = $this->functions->read_acl($manager_lid);
195                       
196                        $manager_contexts = $acl['contexts'];
197                       
198                        // Verifica se tem acesso a este modulo
199                        if (!$this->functions->check_acl($manager_lid,'add_users'))
200                        {
201                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
202                        }
203                               
204                        // Imprime nav_bar
205                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
206                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
207                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create User');
208                        $GLOBALS['phpgw']->common->phpgw_header();
209                       
210                        // Seta template
211                        $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
212                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
213                        $t->set_file(array("body" => "accounts_form.tpl"));
214                        $t->set_block('body','main');
215                        $var = array(
216                               
217                'login_field_empty'     =>      lang('Login field is empty'),
218                'login_field_must_have' =>      lang('Login field must have more than characters '),
219                'characters'    =>      lang(' characters'),
220                'login_field_contains_not_allowed'      =>      lang('Login field contains characters not allowed. characters'),
221                'password_field_empty'  =>      lang('Password field is empty'),
222                're-pass_field_empty'   =>      lang('Re-Password field is empty'),
223                'pass_re-pass_diferents'        =>      lang('Password and Re-Password are differentes'),
224                'register_field_contains_not_allowed'   =>      lang('Field register contains characters not allowed. Numbers are only allowed.'),
225                'cpf_field_not_allowed' =>      lang('Field cpf contains characters not allowed. Numbers are only allowed.'),
226                'email_field_empty'     =>      lang('Email field is empty.'),
227                'first_name_empty'      =>      lang('First name field is empty'),
228                'last_name_empty'       =>      lang('Last name field is empty'),
229                'telephone_empty'       =>      lang('Telphone field is empty'),
230                'redirect_email_empty'  =>      lang('Redirect email field is empty'),
231                'without_quota' =>      lang('User without quota'),
232                'no_group_selected'     =>      lang('No groups selected'),
233                'user_logon_script_empty'       =>      lang('User logon script is empty'),
234                'user_home_path_empty'  =>      lang('User home path is empty'),
235                'user_successfully_created'     =>      lang('User successfully created!'),
236                'user_successfully_saved'       =>      lang('User successfully saved!'),
237                'default_password_successfully_registered_cadastre'     =>      lang('Default password successfully registered in cadastre'),
238                'user_password_returned_with_success'   =>      lang('User password returned with success'),
239                'user_deleted_with_success'     =>      lang('User deleted with success'),
240                'login_field_contains_not_allowed'      =>      lang('Login field contains not allowed characters'),
241                'page_not_found'        =>      lang('Page Not Found!'),
242                'type_name_new_manager' =>      lang('Type the name of the new manager'),
243                'list_login_field_incomplete'   =>      lang('The List LOGIN field is incomplete\nThe name of the list must be created like this:\nlist-ORGANIZATION-NAME_OF_LIST.\nEx: lista-celepar-rh.'),
244                'email_field_not_valid' =>      lang('Email field is not valid'),
245                'searching'     =>      lang('Searching...'),
246                'delete_the_list'       =>      lang('Delete the list '),
247                'group_name_field_incomplete'   =>      lang('The group NAME field is incomplete.\nThe group name must be created like this:\ngroup-ORGANIZATION-NAME_OF_GROUP.\nEx: grupo-celepar-rh.'),
248                'delete_the_group'      =>      lang('Delete the group '),
249                'cpf_invalid_field' =>  lang('Invalid cpf field'),
250                'email_field_not_valid' =>      lang('Invalid E-mail field'),
251                'incorrect_telephone_field'     =>      lang('Incorrect Telephone Field'),
252                'delete_the_user'       => lang('Delete the user '),
253                'change_user_login'     => lang('Change user login'),
254                'to'    => lang('to'),                 
255                'user_renamed_success'  =>      lang('user_renamed_success'),
256                'removed'       =>      lang('removed'),
257                'mb_from_the_user_mailbox'      =>      lang('mb_from_the_user_mailbox'),
258                'cleaning_users_inbox'  =>      lang('cleaning_users_inbox')
259                );
260                $t->set_var($var);
261
262                        // Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou.
263                        foreach ($manager_contexts as $index=>$context)
264                                $combo_manager_org .= $this->functions->get_organizations($context);
265                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], '', true, true, true);
266
267                        // Chama funcao para criar lista de aplicativos disponiveis.
268                        $applications_list = $this->functions->make_list_app($manager_lid);
269
270                        // Cria combo de dominio samba
271                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
272                        {
273                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
274                                $sambadomainname_options = '';
275                                if (count($a_sambadomains))
276                                {
277                                        foreach ($a_sambadomains as $a_sambadomain)
278                                        {
279                                                // So mostra os sambaDomainName do contexto do manager
280                                                if ($this->ldap_functions->exist_sambadomains($manager_contexts, $a_sambadomain['samba_domain_name']))
281                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
282                                        }
283                                }
284                        }
285                       
286                        // Valores default.
287                        $var = Array(
288                                'row_on'                                => "#DDDDDD",
289                                'row_off'                               => "#EEEEEE",
290                                'color_bg1'                             => "#E8F0F0",
291                                //'manager_context'             => $manager_context,
292                                'type'                                  => 'create_user',
293                                'back_url'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
294                                'display_samba_suport'  => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'none',
295                                'disabled_access_button'=> 'disabled',
296                               
297                                // First ABA
298                                'display_spam_uid'                              => 'display:none',
299                                'lang_general_information'              => lang('General Information'),
300                                'lang_corporative_information'  => lang('Corporative Information'),
301                                'lang_email_config'                             => lang('Email Config'),
302                                'lang_groups_permission'                => lang('Groups Permission'),
303                                'lang_lists_permission'                 => lang('Email Lists'),
304                                'lang_aplication_permission'    => lang('Aplication Permission'),       
305                                'lang_search_organization'              => lang('Search Organiztion'),
306                                'lang_organizations'                    => lang('Organizations'),
307                                'lang_sector'                                   => lang('Sector'),
308                                'lang_account_lid'                              => lang('Login ID'),
309                                'lang_firstname'                                => lang('First Name'),
310                                'lang_lastname'                                 => lang('Last Name'),
311                                'lang_password'                                 => lang('Password'),
312                                'lang_re-password'                              => lang('Re-Password'),
313                                'lang_passwd_expired'                   => lang('Password expired'),
314                                'lang_changepassword'                   => lang('Change password'),                             
315                                'lang_phone'                                    => lang('Phone'),
316                                'lang_photo'                                    => lang('Photo'),
317                                'lang_account_active'                   => lang('Account Active'),
318                                'lang_account_invisible'                => lang('Account Invisible'),
319                                'lang_never'                                    => lang('never'),
320                                'lang_back'                                             => lang('Back'),
321                                'lang_save'                                             => lang('Save'),
322                                'sectors'                                               => $combo_manager_org,
323                                'combo_organizations'                   => $combo_manager_org,
324                                'combo_all_orgs'                                => $combo_all_orgs,
325                                'passwd_expired_checked'                => 'CHECKED',
326                                'changepassword_checked'                => 'CHECKED',
327                                'phpgwaccountstatus_checked'    => 'CHECKED',
328                                'photo_bin'                                             => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
329                                'display_picture'                               => $this->functions->check_acl($manager_lid,'edit_users_picture') ? '' : 'none',
330                                'display_tr_default_password'   => 'none',
331                                'minimumSizeLogin'                              => $this->current_config['expressoAdmin_minimumSizeLogin'],
332                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain'],
333                                'concatenateDomain'                             => $this->current_config['expressoAdmin_concatenateDomain'],
334                                'ldap_context'                                  => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
335                               
336                                // Corporative Information
337                                'display_corporative_information' => $this->functions->check_acl($manager_lid,'manipulate_corporative_information') ? '' : 'none',
338                                'lang_employeenumber'                   => lang('Employee number'),
339                                'lang_cpf'                                              => lang('cpf'),
340                                'lang_rg'                                               => lang('rg'),
341                                'lang_rguf'                                             => lang('rguf'),
342                               
343                                //MAIL
344                                'lang_activeemailaccount'               => lang('Active email account'),
345                                'lang_email'                                    => lang('E-mail'),
346                                'lang_aliasemail'                               => lang('Alias email'),
347                                'lang_forwardingemail'                  => lang('Forwarding email'),
348                                'lang_email_quota'                              => lang('Email quota in MB'),
349                                'lang_onlyforwarding'                   => lang('Only forwarding'),
350                                'lang_quote_message'                    => lang('leave empty for no quota'),
351                                'lang_email_quota_used'                 => lang('Quota used in MB'),
352                                'accountstatus_checked'                 => 'CHECKED',
353                                'mailquota'                                             => $this->current_config['expressoAdmin_defaultUserQuota'],
354                                'changequote_disabled'                  => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
355                                'imapDelimiter'                                 => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
356                                'input_mailalternateaddress_fields' => '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30>',
357                                'input_mailforwardingaddress_fields'=> '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30>',
358
359                                //Third ABA
360                                'lang_groups'                                   => lang('Groups'),
361                                'lang_user_groups'                              => 'Grupos do Usuário',
362                                'lang_available_groups'                 => 'Grupos disponíveis',
363                                'lang_listGroups'                               => lang('ListGroups'),
364                                'lang_primary_group'                    => lang('Primary Group'),
365                                'lang_add'                                              => lang('Add'),
366                                'lang_rem'                                              => lang('Remove'),
367                               
368                                //Fourd ABA
369                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
370                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
371                               
372                                //Five ABA
373                                'apps'                                                          => $applications_list,
374                               
375                                //SAMBA ABA
376                                'lang_samba_config'                                     => lang('Samba Config'),
377                                'lang_use_attrs_samba'                          => lang('Use samba attributes'),
378                                'lang_sambadomain'                                      => lang('Domain'),
379                                'lang_sambaAcctFlags'                           => lang('AcctFlags'),
380                                'lang_sambaLogonScript'                         => lang('Logon Script'),
381                                'lang_sambaHomeDirectory'                       => lang('Home Directory'),
382                                'lang_active_user'                                      => lang('Samba User Active'),
383                                'lang_desactive_user'                           => lang('Samba User Desactive'),
384                                'use_attrs_samba_checked'                       => 'CHECKED',
385                                'sambadomainname_options'                       => $sambadomainname_options,
386                                'sambalogonscript'                                      => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '',
387                                'use_suggestion_in_logon_script'        => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false',
388                        );
389                        $t->set_var($var);
390                        $t->pfp('out','main');
391                }
392               
393                function view_user()
394                {
395                        ExecMethod('expressoAdmin1_2.uiaccounts.edit_user');
396                        return;
397                }
398               
399                function edit_user()
400                {
401                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
402                        $acl = $this->functions->read_acl($manager_account_lid);
403                        $raw_context = $acl['raw_context'];
404                        $contexts = $acl['contexts'];           
405                        $alert_warning = '';
406                       
407                        // Verifica se tem acesso a este modulo
408                        $disabled = 'disabled';
409                        $disabled_password = 'disabled';
410                        $disabled_samba = 'disabled';
411                        $disabled_edit_photo = 'disabled';
412                        $display_picture = 'none';
413                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
414                                (!$this->functions->check_acl($manager_account_lid,'change_users_password')) &&
415                                (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) &&
416                                (!$this->functions->check_acl($manager_account_lid,'view_users')) &&
417                                (!$this->functions->check_acl($manager_account_lid,'manipulate_corporative_information'))
418                                )
419                        {
420                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
421                        }
422                        // SOMENTE ALTERAÇÃO DE SENHA
423                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password')))
424                        {
425                                $disabled = 'disabled';
426                                $disabled_password = '';
427                        }
428                        // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA
429                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
430                        {
431                                $disabled = 'disabled';
432                                $disabled_samba = '';
433                        }
434                        // TOTAIS MENOS O SAMBA
435                        if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
436                        {
437                                $disabled = '';
438                                $disabled_password = '';
439                                $disabled_samba = 'disabled';
440                        }
441                        // TOTAIS
442                        elseif ($this->functions->check_acl($manager_account_lid,'edit_users'))
443                        {
444                                $disabled = '';
445                                $disabled_password = '';
446                                $disabled_samba = '';
447                        }
448                       
449                        if (!$this->functions->check_acl($manager_account_lid,'change_users_quote'))
450                                $disabled_quote = 'readonly';
451                       
452                        if ($this->functions->check_acl($manager_account_lid,'edit_users_picture'))
453                        {
454                                $disabled_edit_photo = '';
455                                $display_picture = '';
456                        }
457                        // GET all infomations about the user.
458                        $user_info = $this->user->get_user_info($_GET['account_id']);
459                       
460                        // JavaScript
461                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2");
462                        $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);");
463                        $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);");
464                        $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');");
465                       
466                        // Seta header.
467                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
468                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
469
470                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User');
471                        $GLOBALS['phpgw']->common->phpgw_header();
472
473                        // Seta templates.
474                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
475                        $t->set_file(array("body" => "accounts_form.tpl"));
476                        $t->set_block('body','main');
477                                                       
478                // ORGANIZATIONS
479                /*
480                        foreach ($contexts as $index=>$context)
481                                $orgs .= $this->functions->get_organizations($context, $user_info['context']);
482                        */
483                               
484                        foreach ($contexts as $index=>$context)
485                                $combo_manager_org .= $this->functions->get_organizations($context, $user_info['context']);
486                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], $user_info['context'], true, true, true);                       
487
488
489                        // GROUPS.
490                        if (count($user_info['groups_info']) > 0)
491                        {
492                                foreach ($user_info['groups_info'] as $group)
493                                {
494                                        $array_groups[$group['gidnumber']] = $group['cn'];
495                                }
496                                natcasesort($array_groups);
497                                foreach ($array_groups as $gidnumber=>$cn)
498                                {
499                                        // Grupo existe no Banco mas não no Ldap, excluimos grupo do Banco.
500                                        /*
501                                        if (!$this->ldap_functions->group_exist($gidnumber))
502                                        {
503                                                $this->db_functions->delete_group($gidnumber);
504                                                $this->db_functions->write_log("expressoAdmin deletou o grupo $gidnumber do banco, pois não existia no ldap.",'','','','');
505                                                continue;
506                                        }
507                                        */
508                                       
509                                        // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap.
510                                        if (is_null($user_info['groups_ldap'][$gidnumber]))
511                                        {
512                                                $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']);
513                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Incluido memberUid no Ldap]</option>";
514
515                                                if ($alert_warning == '')
516                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
517                                                $alert_warning .= "Incluido atributo memberUid do usuário no grupo:\\n$cn - gidnumber: $gidnumber.";
518                                        }
519                                        else
520                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
521                                       
522                                        if ($gidnumber == $user_info['gidnumber'])
523                                        {
524                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>";
525                                        }
526                                        else
527                                        {
528                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
529                                        }
530                                }
531                               
532                                // O memberUid do usuário está somente no Ldap.
533                                $groups_db = array_flip($user_info['groups']);
534                                foreach ($user_info['groups_ldap'] as $gidnumber=>$cn)
535                                {
536                                        if (is_null($groups_db[$gidnumber]))
537                                        {
538                                                /*
539                                                $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']);
540                                                if ($alert_warning == '')
541                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
542                                                $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n";
543                                                */
544                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Somente no LDAP]</option>";
545                                        }
546                                }
547                        }
548                       
549                        // MAILLISTS
550                        if (count($user_info['maillists_info']) > 0)
551                        {
552                                foreach ($user_info['maillists_info'] as $maillist)
553                                {
554                                        $array_maillist[$maillist['uid']] = $maillist['uid'] . "  (" . $maillist['mail'] . ") ";
555                                }
556                                natcasesort($array_maillist);
557                                foreach ($array_maillist as $uid=>$option)
558                                {
559                                        $ea_select_user_maillists_options .= "<option value=" . $uid . ">" . $option . "</option>";
560                                }
561                        }
562                       
563                        // APPS.
564                        if ($disabled == 'disabled')
565                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps'], 'disabled');
566                        else
567                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps']);
568                       
569                        //PHOTO
570                        if ($user_info['photo_exist'])
571                        {
572                                $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id'];
573                        }
574                        else
575                        {
576                                $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png';
577                                $disabled_delete_photo = 'disabled';
578                        }
579
580                        // Cria combo de dominios do samba
581                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
582                        {
583                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
584                                $sambadomainname_options = '';
585                                if (count($a_sambadomains))
586                                {
587                                        foreach ($a_sambadomains as $a_sambadomain)
588                                        {
589                                                if ($a_sambadomain['samba_domain_sid'] == $user_info['sambasid'])
590                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>";
591                                                else
592                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
593                                        }
594                                }
595                        }
596                       
597                        // Mail Alternate & Forwarding
598                        if (is_array($user_info['mailalternateaddress']))
599                        {
600                                for ($i = 0; $i < $user_info['mailalternateaddress']['count']; $i++)
601                                {
602                                        if ($i > 0)
603                                                $input_mailalternateaddress_fields .= '<br>';
604                                        $input_mailalternateaddress_fields .= '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="'.$user_info['mailalternateaddress'][$i].'" {disabled} size=30>';
605                                }
606                        }
607                        else
608                        {
609                                $input_mailalternateaddress_fields = '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="" {disabled} size=30>';
610                        }
611
612                        if (is_array($user_info['mailforwardingaddress']))
613                        {
614                                for ($i = 0; $i < $user_info['mailforwardingaddress']['count']; $i++)
615                                {
616                                        if ($i > 0)
617                                                $input_mailforwardingaddress_fields .= '<br>';
618                                        $input_mailforwardingaddress_fields .= '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="'.$user_info['mailforwardingaddress'][$i].'" {disabled} size=30>';
619                                }
620                        }
621                        else
622                        {
623                                $input_mailforwardingaddress_fields = '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="" {disabled} size=30>';
624                        }
625
626                        if ($alert_warning != '')
627                                $alert_warning = "alert('". $alert_warning ."')";
628                        $var = Array(
629                                'uidnumber'                                     => $_GET['account_id'],
630                                'type'                                          => 'edit_user',
631                                'photo_exist'                           => $user_info['photo_exist'],
632                                'departmentnumber'                      => $user_info['departmentnumber'],
633                                'user_context'                          => $user_info['context'],
634                               
635                                'row_on'                                        => "#DDDDDD",
636                                'row_off'                                       => "#EEEEEE",
637                                'color_bg1'                                     => "#E8F0F0",
638                                'action'                                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'),
639                                'back_url'                                      => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users',
640                                'disabled'                                      => $disabled,
641                                'disabled_password'                     => $disabled_password,
642                                'disabled_samba'                        => $disabled_samba,
643                                'changequote_disabled'          => $disabled_quote,
644                               
645                                // Display ABAS
646                                'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'manipulate_corporative_information') ? '' : 'none',
647                                'display_applications'          => $this->functions->check_acl($manager_account_lid,'display_applications') ? '' : 'none',
648                                'display_emaillists'            => $this->functions->check_acl($manager_account_lid,'display_emaillists') ? '' : 'none',
649                                'display_groups'                        => $this->functions->check_acl($manager_account_lid,'display_groups') ? '' : 'none',
650                                'display_emailconfig'           => $this->functions->check_acl($manager_account_lid,'display_emailconfig') ? '' : 'none',
651                               
652                                // First ABA
653                                'alert_warning'                                 => "$alert_warning",
654                                'display_input_account_lid'             => 'display:none',
655                                'lang_general_information'              => lang('General Information'),
656                                'lang_corporative_information'  => lang('Corporative Information'),
657                                'lang_email_config'                             => lang('Email Config'),
658                                'lang_groups_permission'                => lang('Groups Permission'),
659                                'lang_lists_permission'                 => lang('Email Lists'),
660                                'lang_aplication_permission'    => lang('Aplication Permission'),       
661                                'lang_organizations'                    => lang('Organizations'),
662                                'lang_search_organization'              => lang('Search Organiztion'),
663                                'lang_sector'                                   => lang('Sector'),
664                                'lang_account_lid'                              => lang('Login ID'),
665                                'lang_firstname'                                => lang('First Name'),
666                                'lang_lastname'                                 => lang('Last Name'),
667                                'lang_passwd_expired'                   => lang('Password expired'),
668                                'lang_password'                                 => lang('Password'),
669                                'lang_phone'                                    => lang('Phone'),
670                                'lang_photo'                                    => lang('Photo'),
671                                'lang_re-password'                              => lang('Re-Password'),
672                                'lang_changepassword'                   => lang('Change password'),                             
673                                'lang_account_active'                   => lang('Account Active'),
674                                'lang_account_invisible'                => lang('Account Invisible'),
675                                'lang_back'                                             => lang('Back'),
676                                'lang_save'                                             => lang('Save'),
677                               
678                                'sectors'                                               => $combo_manager_org,
679                                'combo_organizations'                   => $combo_manager_org,
680                                'combo_all_orgs'                                => $combo_all_orgs,
681                               
682                                'uid'                                                   => $user_info['uid'],
683                                'givenname'                                             => $user_info['givenname'],
684                                'mail1'                                                 => $user_info['mail'],
685                                'sn'                                                    => $user_info['sn'],
686                                'telephonenumber'                               => $user_info['telephonenumber'],
687                                'photo_bin'                                             => $photo_bin,
688                                'disabled_edit_photo'                   => $disabled_edit_photo,
689                                //'display_picture'                             => $this->functions->check_acl($manager_account_lid,'edit_users_picture') ? '' : 'none',
690                                'display_picture'                               => $display_picture,
691                               
692                                'display_tr_default_password'   => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
693                               
694                                'passwd_expired_checked'                => $user_info['passwd_expired'] == '0' ? 'CHECKED' : '',
695                                'changepassword_checked'                => $user_info['changepassword'] == '1' ? 'CHECKED' : '',
696                                'phpgwaccountstatus_checked'    => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '',
697                                'phpgwaccountvisible_checked'   => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
698
699                                // Corporative Information
700                                'lang_employeenumber'                   => lang('Employee number'),
701                                'lang_cpf'                                              => lang('cpf'),
702                                'lang_rg'                                               => lang('rg'),
703                                'lang_rguf'                                             => lang('rguf'),
704                                'corporative_information_employeenumber' => $user_info['corporative_information_employeenumber'],
705                                'corporative_information_cpf'                   => $user_info['corporative_information_cpf'],
706                                'corporative_information_rg'                    => $user_info['corporative_information_rg'],
707                                'corporative_information_rguf'                  => $user_info['corporative_information_rguf'],
708                               
709                                //MAIL
710                                'disabled_quota_used'           => 'disabled',
711                                'lang_activeemailaccount'       => lang('Active email account'),
712                                'lang_email'                            => lang('E-mail'),
713                                'lang_aliasemail'                       => lang('Alias email'),
714                                'lang_forwardingemail'          => lang('Forwarding email'),
715                                'lang_email_quota'                      => lang('Email quota in MB'),
716                                'lang_onlyforwarding'           => lang('Only forwarding'),
717                                'lang_email_quota_used'         => lang('Quota used in MB'),
718                               
719                                'accountstatus_checked'         => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
720                                'mail'                                          => $user_info['mail'],
721                               
722                                //'mailalternateaddress'                => $user_info['mailalternateaddress'],
723                                //'mailforwardingaddress'               => $user_info['mailforwardingaddress'],
724                                'input_mailalternateaddress_fields'     => $input_mailalternateaddress_fields,
725                                'input_mailforwardingaddress_fields'=> $input_mailforwardingaddress_fields,
726                               
727                                'deliverymode_checked'          => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
728                               
729                                'mailquota'                                     => $user_info['mailquota'],
730                                'mailquota_used'                        => $user_info['mailquota_used'],
731
732                                //Third ABA
733                                'lang_groups'                           => lang('Groups'),
734                                'lang_user_groups'                      => 'Grupos do Usuário',
735                                'lang_available_groups'         => 'Grupos disponíveis',
736                                'lang_primary_group'            => lang('Primary Group'),
737                                'lang_add'                                      => lang('Add'),
738                                'lang_rem'                                      => lang('Remove'),
739                                'ea_select_user_groups_options' => $ea_select_user_groups_options,
740                                'ea_combo_primary_user_group_options'   => $ea_combo_primary_user_group_options,
741                               
742                                //Fourd ABA
743                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
744                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
745                                'ea_select_user_maillists_options'  => $ea_select_user_maillists_options,
746                                                               
747                                //Five ABA
748                                'apps'  => $apps,
749
750                                //SAMBA ABA
751                                'lang_samba_config'                     => lang('Samba Config'),
752                                'lang_use_attrs_samba'          => lang('Use samba attributes'),
753                                'lang_sambadomain'                      => lang('Domain'),
754                                'lang_sambaAcctFlags'           => lang('AcctFlags'),
755                                'lang_sambaLogonScript'         => lang('Logon Script'),
756                                'lang_sambaHomeDirectory'       => lang('Home Directory'),
757                                'lang_active_user'                      => lang('Samba User Active'),
758                                'lang_desactive_user'           => lang('Samba User Desactive'),
759                               
760                                'userSamba'                                     => $user_info['sambaUser'],
761                                'sambadomainname_options'       => $sambadomainname_options,
762                                'use_attrs_samba_checked'       => $user_info['sambaUser'] ? 'CHECKED' : '',
763                                'active_user_selected'          => $user_info['sambaaccflags'] == '[U          ]' ? 'selected' : '',
764                                'desactive_user_selected'       => $user_info['sambaaccflags'] == '[DU         ]' ? 'selected' : '',
765                                'sambalogonscript'                      => $user_info['sambalogonscript'],
766                                'sambahomedirectory'            => $user_info['homedirectory'],
767                                'defaultLogonScript'            => $this->current_config['expressoAdmin_defaultLogonScript'],
768                                'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false'
769                        );
770                        $t->set_var($var);
771                       
772                        // Devo mostrar aba SAMBA ??
773                        if ( ($this->current_config['expressoAdmin_samba_support'] == 'true') && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) )
774                                $t->set_var('display_samba_suport', '');
775                        else
776                                $t->set_var('display_samba_suport', 'none');
777                       
778                        $t->pfp('out','body');                 
779                }
780               
781                function row_action($action,$type,$account_id)
782                {
783                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
784                                'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type,
785                                'account_id' => $account_id
786                        )).'"> '.lang($action).' </a>';
787                }
788
789                function css()
790                {
791                        $appCSS =
792                        'th.activetab
793                        {
794                                color:#000000;
795                                background-color:#D3DCE3;
796                                border-top-width : 1px;
797                                border-top-style : solid;
798                                border-top-color : Black;
799                                border-left-width : 1px;
800                                border-left-style : solid;
801                                border-left-color : Black;
802                                border-right-width : 1px;
803                                border-right-style : solid;
804                                border-right-color : Black;
805                                font-size: 12px;
806                                font-family: Tahoma, Arial, Helvetica, sans-serif;
807                        }
808                       
809                        th.inactivetab
810                        {
811                                color:#000000;
812                                background-color:#E8F0F0;
813                                border-bottom-width : 1px;
814                                border-bottom-style : solid;
815                                border-bottom-color : Black;
816                                font-size: 12px;
817                                font-family: Tahoma, Arial, Helvetica, sans-serif;                             
818                        }
819                       
820                        .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
821                        .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
822                       
823                        div.activetab{ display:inline; }
824                        div.inactivetab{ display:none; }';
825                       
826                        return $appCSS;
827                }
828
829                function show_photo()
830                {
831                        $uidNumber = $_GET['uidNumber'];
832                        $photo = $this->get_photo($uidNumber);
833                       
834                if ($photo)
835                        {
836                        header("Content-Type: image/jpeg");
837                                $width = imagesx($photo);
838                                $height = imagesy($photo);
839                    $twidth = 80;
840                $theight = 106;
841                                $small_photo = imagecreatetruecolor ($twidth, $theight);
842                                imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
843                                imagejpeg($small_photo,"",100);
844                                return;
845                        }
846                }
847               
848                function get_photo($uidNumber)
849                {
850                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
851                        $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))";
852                        $justthese = array("jpegphoto");
853
854                        $search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
855                        $entry = ldap_first_entry($ldap_conn, $search);
856                        $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto");
857                        $jpegphoto = imagecreatefromstring($jpeg_data[0]);
858                        return $jpegphoto;
859                }
860               
861                function show_access_log()
862                {       
863                        $account_id = $_GET['account_id'];
864                       
865                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
866                        $tmp = $this->functions->read_acl($manager_account_lid);
867                        $manager_context = $tmp[0]['context'];
868                       
869                        // Verifica se tem acesso a este modulo
870                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password')))
871                        {
872                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
873                        }
874
875                        // Seta header.
876                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
877                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
878
879                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log');
880                        $GLOBALS['phpgw']->common->phpgw_header();
881
882                        // Seta templates.
883                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
884                        $t->set_file(array("body" => "accesslog.tpl"));
885                        $t->set_block('body','main');
886                        $t->set_block('body','row','row');
887
888                        // GET access log from the user.
889                        $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__);
890                        while ($GLOBALS['phpgw']->db->next_record())
891                        {
892                                $records[] = array(
893                                        'loginid'    => $GLOBALS['phpgw']->db->f('loginid'),
894                                        'ip'         => $GLOBALS['phpgw']->db->f('ip'),
895                                        'li'         => $GLOBALS['phpgw']->db->f('li'),
896                                        'lo'         => $GLOBALS['phpgw']->db->f('lo'),
897                                        'account_id' => $GLOBALS['phpgw']->db->f('account_id'),
898                                        'sessionid'  => $GLOBALS['phpgw']->db->f('sessionid')
899                                );
900                        }
901
902                        // Seta as vcariaveis
903                        while (is_array($records) && list(,$record) = each($records))
904                        {
905                                $var = array(
906                                        'row_loginid' => $record['loginid'],
907                                        'row_ip'      => $record['ip'],
908                                        'row_li'      => date("d/m/Y - H:i:s", $record['li']),
909                                        'row_lo'      => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo'])
910                                );
911                                $t->set_var($var);
912                                $t->fp('rows','row',True);
913                        }
914
915                        $var = Array(
916                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
917                                'lang_back'             => 'Back',
918                                'back_url'              => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id",
919                                'lang_loginid'  => lang('Login ID'),
920                                'lang_ip'               => lang('IP'),
921                                'lang_login'    => lang('Log IN'),
922                                'lang_logout'   => lang('Log OUT')
923                        );
924                        $t->set_var($var);
925                        $t->pfp('out','body');
926                }
927        }
928?>
Note: See TracBrowser for help on using the repository browser.