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

Revision 64, 32.8 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

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