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

Revision 11, 28.7 KB checked in by niltonneto, 17 years ago (diff)

verificar change log.

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