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

Revision 2, 27.0 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

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