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

Revision 107, 35.2 KB checked in by niltonneto, 16 years ago (diff)

Inclusão de funcionalidade

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