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

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