source: companies/serpro/expressoAdmin1_2/inc/class.uiaccounts.inc.php @ 903

Revision 903, 32.7 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

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