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

Revision 9, 28.1 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

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