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

Revision 180, 35.4 KB checked in by niltonneto, 16 years ago (diff)
  • 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
216                        // Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou.
217                        foreach ($manager_contexts as $index=>$context)
218                                $sectors .= $this->functions->get_organizations($context);
219
220                        // Chama funcao para criar lista de aplicativos disponiveis.
221                        $applications_list = $this->functions->make_list_app($manager_lid);
222
223                        // Cria combo de dominio samba
224                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
225                        {
226                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
227                                $sambadomainname_options = '';
228                                if (count($a_sambadomains))
229                                {
230                                        foreach ($a_sambadomains as $a_sambadomain)
231                                        {
232                                                // So mostra os sambaDomainName do contexto do manager
233                                                if ($this->ldap_functions->exist_sambadomains($manager_contexts, $a_sambadomain['samba_domain_name']))
234                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
235                                        }
236                                }
237                        }
238                       
239                        // Valores default.
240                        $var = Array(
241                                'row_on'                                => "#DDDDDD",
242                                'row_off'                               => "#EEEEEE",
243                                'color_bg1'                             => "#E8F0F0",
244                                //'manager_context'             => $manager_context,
245                                'type'                                  => 'create_user',
246                                'back_url'                              => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'),
247                                'display_samba_suport'  => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'none',
248                                'disabled_access_button'=> 'disabled',
249                               
250                                // First ABA
251                                'display_spam_uid'                              => 'display:none',
252                                'lang_general_information'              => lang('General Information'),
253                                'lang_corporative_information'  => lang('Corporative Information'),
254                                'lang_email_config'                             => lang('Email Config'),
255                                'lang_groups_permission'                => lang('Groups Permission'),
256                                'lang_lists_permission'                 => lang('Email Lists'),
257                                'lang_aplication_permission'    => lang('Aplication Permission'),       
258                                'lang_search_organization'              => lang('Search Organiztion'),
259                                'lang_organizations'                    => lang('Organizations'),
260                                'lang_sector'                                   => lang('Sector'),
261                                'lang_account_lid'                              => lang('Login ID'),
262                                'lang_firstname'                                => lang('First Name'),
263                                'lang_lastname'                                 => lang('Last Name'),
264                                'lang_password'                                 => lang('Password'),
265                                'lang_re-password'                              => lang('Re-Password'),
266                                'lang_passwd_expired'                   => lang('Password expired'),
267                                'lang_changepassword'                   => lang('Change password'),                             
268                                'lang_phone'                                    => lang('Phone'),
269                                'lang_photo'                                    => lang('Photo'),
270                                'lang_account_active'                   => lang('Account Active'),
271                                'lang_account_invisible'                => lang('Account Invisible'),
272                                'lang_never'                                    => lang('never'),
273                                'lang_back'                                             => lang('Back'),
274                                'lang_save'                                             => lang('Save'),
275                               
276                                'sectors'                                               => $sectors,
277                                'combo_organizations'                   => $sectors,
278                                'passwd_expired_checked'                => 'CHECKED',
279                                'changepassword_checked'                => 'CHECKED',
280                                'phpgwaccountstatus_checked'    => 'CHECKED',
281                                'photo_bin'                                             => $GLOBALS['phpgw_info']['server']['webserver_url'].'/expressoAdmin1_2/templates/default/images/photo_celepar.png',
282                                'display_picture'                               => $this->functions->check_acl($manager_lid,'edit_users_picture') ? '' : 'none',
283                                'display_tr_default_password'   => 'none',
284                                'minimumSizeLogin'                              => $this->current_config['expressoAdmin_minimumSizeLogin'],
285                                'defaultDomain'                                 => $this->current_config['expressoAdmin_defaultDomain'],
286                                'concatenateDomain'                             => $this->current_config['expressoAdmin_concatenateDomain'],
287                                'ldap_context'                                  => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
288                               
289                                // Corporative Information
290                                'display_corporative_information' => $this->functions->check_acl($manager_lid,'manipulate_corporative_information') ? '' : 'none',
291                                'lang_employeenumber'                   => lang('Employee number'),
292                                'lang_cpf'                                              => lang('cpf'),
293                                'lang_rg'                                               => lang('rg'),
294                                'lang_rguf'                                             => lang('rguf'),
295                               
296                                //MAIL
297                                'lang_activeemailaccount'               => lang('Active email account'),
298                                'lang_email'                                    => lang('E-mail'),
299                                'lang_aliasemail'                               => lang('Alias email'),
300                                'lang_forwardingemail'                  => lang('Forwarding email'),
301                                'lang_email_quota'                              => lang('Email quota in MB'),
302                                'lang_onlyforwarding'                   => lang('Only forwarding'),
303                                'lang_quote_message'                    => lang('leave empty for no quota'),
304                                'lang_email_quota_used'                 => lang('Quota used in MB'),
305                                'accountstatus_checked'                 => 'CHECKED',
306                                'mailquota'                                             => $this->current_config['expressoAdmin_defaultUserQuota'],
307                                'changequote_disabled'                  => $this->functions->check_acl($manager_lid,'change_users_quote') ? '' : 'readonly',
308                                'imapDelimiter'                                 => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'],
309                                'input_mailalternateaddress_fields' => '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="{mailalternateaddress}" {disabled} size=30>',
310                                'input_mailforwardingaddress_fields'=> '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="{mailforwardingaddress}" {disabled} size=30>',
311
312                                //Third ABA
313                                'lang_groups'                                   => lang('Groups'),
314                                'lang_user_groups'                              => 'Grupos do Usuário',
315                                'lang_available_groups'                 => 'Grupos disponíveis',
316                                'lang_listGroups'                               => lang('ListGroups'),
317                                'lang_primary_group'                    => lang('Primary Group'),
318                                'lang_add'                                              => lang('Add'),
319                                'lang_rem'                                              => lang('Remove'),
320                               
321                                //Fourd ABA
322                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
323                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
324                               
325                                //Five ABA
326                                'apps'                                                          => $applications_list,
327                               
328                                //SAMBA ABA
329                                'lang_samba_config'                                     => lang('Samba Config'),
330                                'lang_use_attrs_samba'                          => lang('Use samba attributes'),
331                                'lang_sambadomain'                                      => lang('Domain'),
332                                'lang_sambaAcctFlags'                           => lang('AcctFlags'),
333                                'lang_sambaLogonScript'                         => lang('Logon Script'),
334                                'lang_sambaHomeDirectory'                       => lang('Home Directory'),
335                                'lang_active_user'                                      => lang('Samba User Active'),
336                                'lang_desactive_user'                           => lang('Samba User Desactive'),
337                                'use_attrs_samba_checked'                       => 'CHECKED',
338                                'sambadomainname_options'                       => $sambadomainname_options,
339                                'sambalogonscript'                                      => $this->current_config['expressoAdmin_defaultLogonScript'] != '' ? $this->current_config['expressoAdmin_defaultLogonScript'] : '',
340                                'use_suggestion_in_logon_script'        => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false',
341                        );
342                        $t->set_var($var);
343                        $t->pfp('out','main');
344                }
345               
346                function view_user()
347                {
348                        ExecMethod('expressoAdmin1_2.uiaccounts.edit_user');
349                        return;
350                }
351               
352                function edit_user()
353                {
354                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
355                        $acl = $this->functions->read_acl($manager_account_lid);
356                        $raw_context = $acl['raw_context'];
357                        $contexts = $acl['contexts'];           
358                        $alert_warning = '';
359                       
360                        // Verifica se tem acesso a este modulo
361                        $disabled = 'disabled';
362                        $disabled_password = 'disabled';
363                        $disabled_samba = 'disabled';
364                        $disabled_edit_photo = 'disabled';
365                        $display_picture = 'none';
366                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
367                                (!$this->functions->check_acl($manager_account_lid,'change_users_password')) &&
368                                (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) &&
369                                (!$this->functions->check_acl($manager_account_lid,'view_users')) &&
370                                (!$this->functions->check_acl($manager_account_lid,'manipulate_corporative_information'))
371                                )
372                        {
373                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
374                        }
375                        // SOMENTE ALTERAÇÃO DE SENHA
376                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'change_users_password')))
377                        {
378                                $disabled = 'disabled';
379                                $disabled_password = '';
380                        }
381                        // SOMENTE ALTERAÇÃO DOS ATRIBUTOS SAMBA
382                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
383                        {
384                                $disabled = 'disabled';
385                                $disabled_samba = '';
386                        }
387                        // TOTAIS MENOS O SAMBA
388                        if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')))
389                        {
390                                $disabled = '';
391                                $disabled_password = '';
392                                $disabled_samba = 'disabled';
393                        }
394                        // TOTAIS
395                        elseif ($this->functions->check_acl($manager_account_lid,'edit_users'))
396                        {
397                                $disabled = '';
398                                $disabled_password = '';
399                                $disabled_samba = '';
400                        }
401                       
402                        if (!$this->functions->check_acl($manager_account_lid,'change_users_quote'))
403                                $disabled_quote = 'readonly';
404                       
405                        if ($this->functions->check_acl($manager_account_lid,'edit_users_picture'))
406                        {
407                                $disabled_edit_photo = '';
408                                $display_picture = '';
409                        }
410                        // GET all infomations about the user.
411                        $user_info = $this->user->get_user_info($_GET['account_id']);
412                       
413                        // JavaScript
414                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2");
415                        $GLOBALS['phpgw']->js->set_onload("get_available_groups(document.forms[0].context.value);");
416                        $GLOBALS['phpgw']->js->set_onload("get_available_maillists(document.forms[0].context.value);");
417                        $GLOBALS['phpgw']->js->set_onload("use_samba_attrs('".$user_info['sambaUser']."');");
418                       
419                        // Seta header.
420                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
421                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
422
423                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit User');
424                        $GLOBALS['phpgw']->common->phpgw_header();
425
426                        // Seta templates.
427                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
428                        $t->set_file(array("body" => "accounts_form.tpl"));
429                        $t->set_block('body','main');
430                                                       
431                // ORGANIZATIONS
432                        foreach ($contexts as $index=>$context)
433                                $orgs .= $this->functions->get_organizations($context, $user_info['context']);
434
435                        // GROUPS.
436                        if (count($user_info['groups_info']) > 0)
437                        {
438                                foreach ($user_info['groups_info'] as $group)
439                                {
440                                        $array_groups[$group['gidnumber']] = $group['cn'];
441                                }
442                                natcasesort($array_groups);
443                                foreach ($array_groups as $gidnumber=>$cn)
444                                {
445                                        // Grupo existe no Banco mas não no Ldap, excluimos grupo do Banco.
446                                        /*
447                                        if (!$this->ldap_functions->group_exist($gidnumber))
448                                        {
449                                                $this->db_functions->delete_group($gidnumber);
450                                                $this->db_functions->write_log("expressoAdmin deletou o grupo $gidnumber do banco, pois não existia no ldap.",'','','','');
451                                                continue;
452                                        }
453                                        */
454                                       
455                                        // O memberUid do usuário está somente no Banco, então adicionamos o memberUid no Ldap.
456                                        if (is_null($user_info['groups_ldap'][$gidnumber]))
457                                        {
458                                                $this->ldap_functions->add_user2group($gidnumber, $user_info['uid']);
459                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Incluido memberUid no Ldap]</option>";
460
461                                                if ($alert_warning == '')
462                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
463                                                $alert_warning .= "Incluido atributo memberUid do usuário no grupo:\\n$cn - gidnumber: $gidnumber.";
464                                        }
465                                        else
466                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
467                                       
468                                        if ($gidnumber == $user_info['gidnumber'])
469                                        {
470                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . " selected>" . $cn . "</option>";
471                                        }
472                                        else
473                                        {
474                                                $ea_combo_primary_user_group_options .= "<option value=" . $gidnumber . ">" . $cn . "</option>";
475                                        }
476                                }
477                               
478                                // O memberUid do usuário está somente no Ldap.
479                                $groups_db = array_flip($user_info['groups']);
480                                foreach ($user_info['groups_ldap'] as $gidnumber=>$cn)
481                                {
482                                        if (is_null($groups_db[$gidnumber]))
483                                        {
484                                                /*
485                                                $this->ldap_functions->remove_user2group($gidnumber, $user_info['uid']);
486                                                if ($alert_warning == '')
487                                                        $alert_warning = "O expressoAdmin corrigiu as seguintes inconsistências:\\n";
488                                                $alert_warning .= "Removido atributo memberUid do usuário do grupo $cn.\\n";
489                                                */
490                                                $ea_select_user_groups_options .= "<option value=" . $gidnumber . ">" . $cn . " [Somente no LDAP]</option>";
491                                        }
492                                }
493                        }
494                       
495                        // MAILLISTS
496                        if (count($user_info['maillists_info']) > 0)
497                        {
498                                foreach ($user_info['maillists_info'] as $maillist)
499                                {
500                                        $array_maillist[$maillist['uidnumber']] = $maillist['uid'] . "  (" . $maillist['mail'] . ") ";
501                                }
502                                natcasesort($array_maillist);
503                                foreach ($array_maillist as $uidnumber=>$option)
504                                {
505                                        $ea_select_user_maillists_options .= "<option value=" . $uidnumber . ">" . $option . "</option>";
506                                }
507                        }
508                       
509                        // APPS.
510                        if ($disabled == 'disabled')
511                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps'], 'disabled');
512                        else
513                                $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps']);
514                       
515                        //PHOTO
516                        if ($user_info['photo_exist'])
517                        {
518                                $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id'];
519                        }
520                        else
521                        {
522                                $photo_bin = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/expressoAdmin1_2/templates/default/images/photo_celepar.png';
523                                $disabled_delete_photo = 'disabled';
524                        }
525
526                        // Cria combo de dominios do samba
527                        if ($this->current_config['expressoAdmin_samba_support'] == 'true')
528                        {
529                                $a_sambadomains = $this->db_functions->get_sambadomains_list();
530                                $sambadomainname_options = '';
531                                if (count($a_sambadomains))
532                                {
533                                        foreach ($a_sambadomains as $a_sambadomain)
534                                        {
535                                                if ($a_sambadomain['samba_domain_sid'] == $user_info['sambasid'])
536                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "' SELECTED>" . $a_sambadomain['samba_domain_name'] . "</option>";
537                                                else
538                                                        $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>";
539                                        }
540                                }
541                        }
542                       
543                        // Mail Alternate & Forwarding
544                        if (is_array($user_info['mailalternateaddress']))
545                        {
546                                for ($i = 0; $i < $user_info['mailalternateaddress']['count']; $i++)
547                                {
548                                        if ($i > 0)
549                                                $input_mailalternateaddress_fields .= '<br>';
550                                        $input_mailalternateaddress_fields .= '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="'.$user_info['mailalternateaddress'][$i].'" {disabled} size=30>';
551                                }
552                        }
553                        else
554                        {
555                                $input_mailalternateaddress_fields = '<input type="text" name="mailalternateaddress[]" id="mailalternateaddress" autocomplete="off" value="" {disabled} size=30>';
556                        }
557
558                        if (is_array($user_info['mailforwardingaddress']))
559                        {
560                                for ($i = 0; $i < $user_info['mailforwardingaddress']['count']; $i++)
561                                {
562                                        if ($i > 0)
563                                                $input_mailforwardingaddress_fields .= '<br>';
564                                        $input_mailforwardingaddress_fields .= '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="'.$user_info['mailforwardingaddress'][$i].'" {disabled} size=30>';
565                                }
566                        }
567                        else
568                        {
569                                $input_mailforwardingaddress_fields = '<input type="text" name="mailforwardingaddress[]" id="mailforwardingaddress" autocomplete="off" value="" {disabled} size=30>';
570                        }
571
572                        if ($alert_warning != '')
573                                $alert_warning = "alert('". $alert_warning ."')";
574                        $var = Array(
575                                'uidnumber'                                     => $_GET['account_id'],
576                                'type'                                          => 'edit_user',
577                                'photo_exist'                           => $user_info['photo_exist'],
578                                'departmentnumber'                      => $user_info['departmentnumber'],
579                                'user_context'                          => $user_info['context'],
580                               
581                                'row_on'                                        => "#DDDDDD",
582                                'row_off'                                       => "#EEEEEE",
583                                'color_bg1'                                     => "#E8F0F0",
584                                'action'                                        => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'),
585                                'back_url'                                      => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users',
586                                'disabled'                                      => $disabled,
587                                'disabled_password'                     => $disabled_password,
588                                'disabled_samba'                        => $disabled_samba,
589                                'changequote_disabled'          => $disabled_quote,
590                               
591                                // Display ABAS
592                                'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'manipulate_corporative_information') ? '' : 'none',
593                                'display_applications'          => $this->functions->check_acl($manager_account_lid,'display_applications') ? '' : 'none',
594                                'display_emaillists'            => $this->functions->check_acl($manager_account_lid,'display_emaillists') ? '' : 'none',
595                                'display_groups'                        => $this->functions->check_acl($manager_account_lid,'display_groups') ? '' : 'none',
596                                'display_emailconfig'           => $this->functions->check_acl($manager_account_lid,'display_emailconfig') ? '' : 'none',
597                               
598                                // First ABA
599                                'alert_warning'                                 => "$alert_warning",
600                                'display_input_account_lid'             => 'display:none',
601                                'lang_general_information'              => lang('General Information'),
602                                'lang_corporative_information'  => lang('Corporative Information'),
603                                'lang_email_config'                             => lang('Email Config'),
604                                'lang_groups_permission'                => lang('Groups Permission'),
605                                'lang_lists_permission'                 => lang('Email Lists'),
606                                'lang_aplication_permission'    => lang('Aplication Permission'),       
607                                'lang_organizations'                    => lang('Organizations'),
608                                'lang_search_organization'              => lang('Search Organiztion'),
609                                'lang_sector'                                   => lang('Sector'),
610                                'lang_account_lid'                              => lang('Login ID'),
611                                'lang_firstname'                                => lang('First Name'),
612                                'lang_lastname'                                 => lang('Last Name'),
613                                'lang_passwd_expired'                   => lang('Password expired'),
614                                'lang_password'                                 => lang('Password'),
615                                'lang_phone'                                    => lang('Phone'),
616                                'lang_photo'                                    => lang('Photo'),
617                                'lang_re-password'                              => lang('Re-Password'),
618                                'lang_changepassword'                   => lang('Change password'),                             
619                                'lang_account_active'                   => lang('Account Active'),
620                                'lang_account_invisible'                => lang('Account Invisible'),
621                                'lang_back'                                             => lang('Back'),
622                                'lang_save'                                             => lang('Save'),
623                               
624                                'sectors'                                               => $orgs,
625                                'combo_organizations'                   => $orgs,
626                               
627                                'uid'                                                   => $user_info['uid'],
628                                'givenname'                                             => $user_info['givenname'],
629                                'mail1'                                                 => $user_info['mail'],
630                                'sn'                                                    => $user_info['sn'],
631                                'telephonenumber'                               => $user_info['telephonenumber'],
632                                'photo_bin'                                             => $photo_bin,
633                                'disabled_edit_photo'                   => $disabled_edit_photo,
634                                //'display_picture'                             => $this->functions->check_acl($manager_account_lid,'edit_users_picture') ? '' : 'none',
635                                'display_picture'                               => $display_picture,
636                               
637                                'display_tr_default_password'   => $this->functions->check_acl($manager_account_lid,'set_user_default_password') ? '' : 'none',
638                               
639                                'passwd_expired_checked'                => $user_info['passwd_expired'] == '0' ? 'CHECKED' : '',
640                                'changepassword_checked'                => $user_info['changepassword'] == '1' ? 'CHECKED' : '',
641                                'phpgwaccountstatus_checked'    => $user_info['phpgwaccountstatus'] == 'A' ? 'CHECKED' : '',
642                                'phpgwaccountvisible_checked'   => $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
643
644                                // Corporative Information
645                                'lang_employeenumber'                   => lang('Employee number'),
646                                'lang_cpf'                                              => lang('cpf'),
647                                'lang_rg'                                               => lang('rg'),
648                                'lang_rguf'                                             => lang('rguf'),
649                                'corporative_information_employeenumber' => $user_info['corporative_information_employeenumber'],
650                                'corporative_information_cpf'                   => $user_info['corporative_information_cpf'],
651                                'corporative_information_rg'                    => $user_info['corporative_information_rg'],
652                                'corporative_information_rguf'                  => $user_info['corporative_information_rguf'],
653                               
654                                //MAIL
655                                'disabled_quota_used'           => 'disabled',
656                                'lang_activeemailaccount'       => lang('Active email account'),
657                                'lang_email'                            => lang('E-mail'),
658                                'lang_aliasemail'                       => lang('Alias email'),
659                                'lang_forwardingemail'          => lang('Forwarding email'),
660                                'lang_email_quota'                      => lang('Email quota in MB'),
661                                'lang_onlyforwarding'           => lang('Only forwarding'),
662                                'lang_email_quota_used'         => lang('Quota used in MB'),
663                               
664                                'accountstatus_checked'         => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '',
665                                'mail'                                          => $user_info['mail'],
666                               
667                                //'mailalternateaddress'                => $user_info['mailalternateaddress'],
668                                //'mailforwardingaddress'               => $user_info['mailforwardingaddress'],
669                                'input_mailalternateaddress_fields'     => $input_mailalternateaddress_fields,
670                                'input_mailforwardingaddress_fields'=> $input_mailforwardingaddress_fields,
671                               
672                                'deliverymode_checked'          => $user_info['deliverymode'] == 'forwardOnly' ? 'CHECKED' : '',
673                               
674                                'mailquota'                                     => $user_info['mailquota'],
675                                'mailquota_used'                        => $user_info['mailquota_used'],
676
677                                //Third ABA
678                                'lang_groups'                           => lang('Groups'),
679                                'lang_user_groups'                      => 'Grupos do Usuário',
680                                'lang_available_groups'         => 'Grupos disponíveis',
681                                'lang_primary_group'            => lang('Primary Group'),
682                                'lang_add'                                      => lang('Add'),
683                                'lang_rem'                                      => lang('Remove'),
684                                'ea_select_user_groups_options' => $ea_select_user_groups_options,
685                                'ea_combo_primary_user_group_options'   => $ea_combo_primary_user_group_options,
686                               
687                                //Fourd ABA
688                                'lang_user_mail_lists'                  => 'O usuário participa destas Listas de E-mail',
689                                'lang_available_mail_lists'             => 'Listas de E-mail disponíveis',
690                                'ea_select_user_maillists_options'  => $ea_select_user_maillists_options,
691                                                               
692                                //Five ABA
693                                'apps'  => $apps,
694
695                                //SAMBA ABA
696                                'lang_samba_config'                     => lang('Samba Config'),
697                                'lang_use_attrs_samba'          => lang('Use samba attributes'),
698                                'lang_sambadomain'                      => lang('Domain'),
699                                'lang_sambaAcctFlags'           => lang('AcctFlags'),
700                                'lang_sambaLogonScript'         => lang('Logon Script'),
701                                'lang_sambaHomeDirectory'       => lang('Home Directory'),
702                                'lang_active_user'                      => lang('Samba User Active'),
703                                'lang_desactive_user'           => lang('Samba User Desactive'),
704                               
705                                'userSamba'                                     => $user_info['sambaUser'],
706                                'sambadomainname_options'       => $sambadomainname_options,
707                                'use_attrs_samba_checked'       => $user_info['sambaUser'] ? 'CHECKED' : '',
708                                'active_user_selected'          => $user_info['sambaaccflags'] == '[U          ]' ? 'selected' : '',
709                                'desactive_user_selected'       => $user_info['sambaaccflags'] == '[DU         ]' ? 'selected' : '',
710                                'sambalogonscript'                      => $user_info['sambalogonscript'],
711                                'sambahomedirectory'            => $user_info['homedirectory'],
712                                'defaultLogonScript'            => $this->current_config['expressoAdmin_defaultLogonScript'],
713                                'use_suggestion_in_logon_script' => $this->current_config['expressoAdmin_defaultLogonScript'] == '' ? 'true' : 'false'
714                        );
715                        $t->set_var($var);
716                       
717                        // Devo mostrar aba SAMBA ??
718                        if ( ($this->current_config['expressoAdmin_samba_support'] == 'true') && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) )
719                                $t->set_var('display_samba_suport', '');
720                        else
721                                $t->set_var('display_samba_suport', 'none');
722                       
723                        $t->pfp('out','body');                 
724                }
725               
726                function row_action($action,$type,$account_id)
727                {
728                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
729                                'menuaction' => 'expressoAdmin1_2.uiaccounts.'.$action.'_'.$type,
730                                'account_id' => $account_id
731                        )).'"> '.lang($action).' </a>';
732                }
733
734                function css()
735                {
736                        $appCSS =
737                        'th.activetab
738                        {
739                                color:#000000;
740                                background-color:#D3DCE3;
741                                border-top-width : 1px;
742                                border-top-style : solid;
743                                border-top-color : Black;
744                                border-left-width : 1px;
745                                border-left-style : solid;
746                                border-left-color : Black;
747                                border-right-width : 1px;
748                                border-right-style : solid;
749                                border-right-color : Black;
750                                font-size: 12px;
751                                font-family: Tahoma, Arial, Helvetica, sans-serif;
752                        }
753                       
754                        th.inactivetab
755                        {
756                                color:#000000;
757                                background-color:#E8F0F0;
758                                border-bottom-width : 1px;
759                                border-bottom-style : solid;
760                                border-bottom-color : Black;
761                                font-size: 12px;
762                                font-family: Tahoma, Arial, Helvetica, sans-serif;                             
763                        }
764                       
765                        .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
766                        .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
767                       
768                        div.activetab{ display:inline; }
769                        div.inactivetab{ display:none; }';
770                       
771                        return $appCSS;
772                }
773
774                function show_photo()
775                {
776                        $uidNumber = $_GET['uidNumber'];
777                        $photo = $this->get_photo($uidNumber);
778                       
779                if ($photo)
780                        {
781                        header("Content-Type: image/jpeg");
782                                $width = imagesx($photo);
783                                $height = imagesy($photo);
784                    $twidth = 80;
785                $theight = 106;
786                                $small_photo = imagecreatetruecolor ($twidth, $theight);
787                                imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
788                                imagejpeg($small_photo,"",100);
789                                return;
790                        }
791                }
792               
793                function get_photo($uidNumber)
794                {
795                        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect();
796                        $filter="(&(phpgwAccountType=u)(uidNumber=".$uidNumber."))";
797                        $justthese = array("jpegphoto");
798
799                        $search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
800                        $entry = ldap_first_entry($ldap_conn, $search);
801                        $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto");
802                        $jpegphoto = imagecreatefromstring($jpeg_data[0]);
803                        return $jpegphoto;
804                }
805               
806                function show_access_log()
807                {       
808                        $account_id = $_GET['account_id'];
809                       
810                        $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
811                        $tmp = $this->functions->read_acl($manager_account_lid);
812                        $manager_context = $tmp[0]['context'];
813                       
814                        // Verifica se tem acesso a este modulo
815                        if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'change_users_password')))
816                        {
817                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
818                        }
819
820                        // Seta header.
821                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
822                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
823
824                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Access Log');
825                        $GLOBALS['phpgw']->common->phpgw_header();
826
827                        // Seta templates.
828                        $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
829                        $t->set_file(array("body" => "accesslog.tpl"));
830                        $t->set_block('body','main');
831                        $t->set_block('body','row','row');
832
833                        // GET access log from the user.
834                        $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__);
835                        while ($GLOBALS['phpgw']->db->next_record())
836                        {
837                                $records[] = array(
838                                        'loginid'    => $GLOBALS['phpgw']->db->f('loginid'),
839                                        'ip'         => $GLOBALS['phpgw']->db->f('ip'),
840                                        'li'         => $GLOBALS['phpgw']->db->f('li'),
841                                        'lo'         => $GLOBALS['phpgw']->db->f('lo'),
842                                        'account_id' => $GLOBALS['phpgw']->db->f('account_id'),
843                                        'sessionid'  => $GLOBALS['phpgw']->db->f('sessionid')
844                                );
845                        }
846
847                        // Seta as vcariaveis
848                        while (is_array($records) && list(,$record) = each($records))
849                        {
850                                $var = array(
851                                        'row_loginid' => $record['loginid'],
852                                        'row_ip'      => $record['ip'],
853                                        'row_li'      => date("d/m/Y - H:i:s", $record['li']),
854                                        'row_lo'      => $record['lo'] == 0 ? 0 : date("d/m/Y - H:i:s", $record['lo'])
855                                );
856                                $t->set_var($var);
857                                $t->fp('rows','row',True);
858                        }
859
860                        $var = Array(
861                                'th_bg'                 => $GLOBALS['phpgw_info']['theme']['th_bg'],
862                                'lang_back'             => 'Back',
863                                'back_url'              => "./index.php?menuaction=expressoAdmin1_2.uiaccounts.edit_user&account_id=$account_id",
864                                'lang_loginid'  => lang('Login ID'),
865                                'lang_ip'               => lang('IP'),
866                                'lang_login'    => lang('Log IN'),
867                                'lang_logout'   => lang('Log OUT')
868                        );
869                        $t->set_var($var);
870                        $t->pfp('out','body');
871                }
872        }
873?>
Note: See TracBrowser for help on using the repository browser.